Page 1 of 1

I Found a way to do Text to Speech in Android.

Posted: Tue Sep 30, 2014 11:34 pm
by lodijoe
In the Feature Requests and Building Externals Forums, I asked to have text to speech for Android . No one replied with a suggestion so I searched the forums.
I found a script by Terryho that sends some text out to Google and returns a wave file which speaks the text:
http://forums.livecode.com/viewtopic.ph ... ate#p92097
This worked on my iMac but wouldn't on Android.
I spent days trying to figure it out until I found I needed to check the internet box in the Application Permissions in the
Standalone Settings for the Android app.
I had the code make an mp3 file.
Here is the code I use:
on mouseUp
set the defaultFolder to specialFolderPath("Documents")
put "Hello World" into tpostsound
replace space with "%20" in tpostsound
put "http://translate.google.com/translate_tts?tl=en&q=" & tpostsound into tpostURL
get URL(tpostURL)
put it into URL ("binfile:abc.mp3")
if the environment is "mobile" then
play specialFolderPath("Documents") & "/"&abc.mp3
end if
end mouseUp

Re: I Found a way to do Text to Speech in Android.

Posted: Wed Oct 01, 2014 9:56 am
by ChrisMukrow
Thanks! Nice one!

Re: I Found a way to do Text to Speech in Android.

Posted: Wed Oct 01, 2014 9:57 am
by jmburnod
Hi lodijoe,
Thanks for this good new
You said it worked on your mac
It works fine with a player but not with a simple "play myFile" which just make noise.
I noticed a strange player's behavior when i tried use .aif files although the file exists and the finder can play it.
I dont understand what is the problem. I use "play myFile" with a lot of .aif files on OSX and it works fine
Best regards
Jean-Marc

Re: I Found a way to do Text to Speech in Android.

Posted: Fri Oct 03, 2014 10:19 am
by newtronsols
Works really well.

I was thinking that this approach may work with https://foauth.org/ so you can access a whole range of services with a few lines of code.

Re: I Found a way to do Text to Speech in Android.

Posted: Fri Oct 03, 2014 7:31 pm
by jmburnod
Wow
The size of files created with this method are very small compared same sounds recorded with the resident textToSpeech.
First tries in french are good. I will test some specialities of french langage like
"Les poules du couvent couvent"
Good new this sentence is correctly spoken and the size of the file is only 8 Ko
How is it possible ?
best regards
Jean-Marc

Re: I Found a way to do Text to Speech in Android.

Posted: Sat Oct 04, 2014 2:56 pm
by newtronsols
lodijoe,

Is there a limit to the size of the text file you can pass this way?

Re: I Found a way to do Text to Speech in Android.

Posted: Wed Oct 08, 2014 5:51 pm
by Ledigimate
If implemented this way, the feature would only be available when the device has internet access and for as long as Google makes the service available online.

Re: I Found a way to do Text to Speech in Android.

Posted: Wed Oct 08, 2014 11:57 pm
by newtronsols
Ivona voices are the best and they have a cloud service.

Anyone know how to convert:

https://tts.eu-west-1.ivonacloud.com/CreateSpeech
?Input.Data=Does%20Mary%20have%20a%20little%20lamb%3F
&Input.Type=text%2Fplain
&OutputFormat.Codec=MP3
&OutputFormat.SampleRate=22050
&Parameters.Rate=slow
&Voice.Name=Amy
&Voice.Language=en-GB
&X-Amz-Date=20130913T092054Z
&X-Amz-Algorithm=AWS4-HMAC-SHA256
&X-Amz-Credential=MyAccessKey%2F20130913%2Feu-west-1%2Ftts%2Faws4_request
&X-Amz-SignedHeaders=host
&X-Amz-Signature=2cdfef28d5c5f6682280600a6141a8940c608cfefacb47f172329cbadb5864cc

To Livecode?