Text to Speech

Yea, I thought of timing the speech of phrases using the new onComplete callback and storing them to a table for future reference and also calculating average length per syllable etc from that… But because there is sometimes a delay at the start of the texttospeech.speak() function call it would need an onStart callback as well.  Doesn’t really give a solid solution to predicting time of speech anyway so I’ll forget about it.
The iOS rate problem is really the thing now.

Hm. I can add onStart.

onStart would be really useful too.
In my case it could be used for starting the speech progress view and disabling some UI during speech.

Ok, wait for it. Probably next weekend.

Extreme awesomeness. Callback works like a charm on iOS. Fantastic work!

Hi Lerg.
The rate for iOS 7 is really messed up since this update. It used to be ok and I didn’t mind that the default needed to be set to 0.8 rather than 1.0. But now even putting the rate right down to the minimum ( 0.5 ) is really too fast. Is there any suggestions about getting this working again because at the moment the speech can’t be understood it’s so fast. Should I be going lower than 0.5 ?

 

Also… Calling texttospeech.getLanguagesAndVoices() crashes my app straight away on iOS 7. 

Yes, I *think* allowed values here are from 0.0 to 1.0. You can send any value and see if it works.

Please post a crash report here so I can figure out what’s wrong.

Ok, I’ll give that a go with values lower than 0.5.
So in your documentation where it says : options.rate - float, adjust speaking speed, Android value from 0.5 to 2.0, default is 1.0.
Is that incorrect? And is the range for pitch also incorrect?

The device’s syslog in the Corona simulator shows nothing when it crashes but it mentions TextToSpeechPluginLibrary::getLanguagesAndVoices  in the crash report from xCode. I’ve attached the crash report in a txt file.

 

This is correct, this is for Android. For iOS docs say - no idea.

 

Pitch is correct, it’s the same on Android and iOS (at least should be).

 

Updated the plugin.
 

New options for texttospeech.speak()

options.onStart(id) - called on start.

options.onProgress(id, start, count) - iOS only, called to indicate what portion of the text is being spoken. Values are for UTF-8 string.

See updated docs and sample.

@juliusbangert, possibly fixed the crash.

This is great news Lerg. But how can I test it? Do we have to wait for the next daily build? The latest one ( 2843 ) was pushed up on Thursday.

All plugin updates are decoupled from daily builds, because they are downloaded separately. So just use any recent version and you should be having the latest version of the plugin.

Thanks for the ongoing great work Lerg.
The bug with **texttospeech.getLanguagesAndVoices() **seems to be fixed. 

I’m having an issue with onStart now though, it seems to not get called if texttospeech.speak() is called with the same text more than once. It’s strange but I’ve been trying to trace this bug for hours and it seems to point to that.

What platform? The plugin now ties up with the official SDK pretty tight, so if you do find a bug, probably it will have to go as a bug report for the OS. I’ll check myself of course.

One way of solving it could be setting up some delays between calls to the tts plugin, you know, so the engine can cool down.

Platform is iOS haven’t checked Android yet. But the problem isn’t solved by forced timers because I have a ‘re-play’ button that re-speaks the phrase just spoken. I can wait any amount of time before pressing this and it will always fail to call the onStart from texttospeech.speak() because it’s speaking the same text.
I’m going to rake through my code again to see if my observations are wrong but it seems that way. I’ve tried feeding the text in as an id to override the default random id in case that helped at all but it didn’t make a difference.

In my sample I always receive onStart on iOS, it is the same text. Can you run the sample?
Another possible workaround - add spaces, dots or some other unspeakable elements. Or call speak(’ ') with a blank string before repeating.

It’s weird that it’s working for you. When I run your sample it does the same thing that I observed in mine. It gets the onStart only the first time. Here you can see the output from running it three times ( this is your sample just with the long test replaced with ‘Short Test’ ) :
 

Mar 22 08:53:49.067 [Device] Speech "1804289383" has started. Mar 22 08:53:49.071 [Device] Speech "1804289383" progress: Short Mar 22 08:53:49.356 [Device] Speech "1804289383" progress: test. Mar 22 08:53:49.976 [Device] Speech "1804289383" has ended. Mar 22 08:54:01.188 [Device] Speech "846930886" progress: Short Mar 22 08:54:01.362 [Device] Speech "846930886" progress: test. Mar 22 08:54:01.970 [Device] Speech "846930886" has ended. Mar 22 08:55:37.666 [Device] Speech "1681692777" progress: Short Mar 22 08:55:38.037 [Device] Speech "1681692777" progress: test. Mar 22 08:55:38.568 [Device] Speech "1681692777" has ended.

I’m testing it on iOS 7, still waiting on a new iOS device so haven’t run on iOS 8 or 9 yet but the only thing I can do in my code for now is the following until we can figure it out …
 

speakOnStart( phrase ) -- TEMP -- texttospeech.speak( phrase, { language = preferences.language, voice = preferences.voice, rate = preferences.rate, pitch = preferences.pitch, volume = preferences.volume, id = phrase, --onStart = speakOnStart, onComplete = speakOnComplete } )

Hi Lerg.
Do you think this is something in the plugin or a bug with the native implementation of AVSpeechUtterance on iOS7?