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

The place to discuss anything and everything about running your LiveCode on Android

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
lodijoe
Posts: 20
Joined: Mon Sep 23, 2013 5:20 pm

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

Post by lodijoe » Tue Sep 30, 2014 11:34 pm

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

ChrisMukrow
Posts: 73
Joined: Mon Nov 12, 2012 4:13 pm

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

Post by ChrisMukrow » Wed Oct 01, 2014 9:56 am

Thanks! Nice one!

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2400
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

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

Post by jmburnod » Wed Oct 01, 2014 9:57 am

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

newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

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

Post by newtronsols » Fri Oct 03, 2014 10:19 am

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.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2400
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

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

Post by jmburnod » Fri Oct 03, 2014 7:31 pm

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

newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

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

Post by newtronsols » Sat Oct 04, 2014 2:56 pm

lodijoe,

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

Ledigimate
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 132
Joined: Mon Jan 14, 2013 3:37 pm

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

Post by Ledigimate » Wed Oct 08, 2014 5:51 pm

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.
010100000110010101100001011000110110010100111101010011000110111101110110011001010010101101010100011100100111010101110100011010000010101101001010011101010111001101110100011010010110001101100101

newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

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

Post by newtronsols » Wed Oct 08, 2014 11:57 pm

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?

Post Reply

Return to “Android Deployment”