Text to Speech

WARNING: The 'plugin.texttospeech' library is not available on this platform.

I’m getting this warning in my simulator

Most plugins don’t work in the simulator because they depend on SDKs that are only available on actual devices. Build for device and install on a real device to test this feature.

Rob

Great work! Thank you so much! But I have a problem with speak rate, on iOS 8 , i set rate  = 0.6, on iOS 9 rate = 1. What if the rate changes in the update of iOS, is there a function to get the right speak rate from the OS? How about on android which rate is proper to which android OS version ? Does the rate depend on the android device? Is there a function to get the correct speak rate across the board? 

It would be so great if there were a onComplete callback function. I want to do some stuff  after an instruction text is read completely. Without this, I have to use timer.performWithDelay() function , but it is so hard to know how long it takes to finish reading the text.

Hi. I tested sample code on my Xiaomi Redmi Note 3 (with USB debuging enable) and run with no errors, but  also NO SOUND - no speech in any language :frowning: Corona is in last version 2016.2830.

Any idea what is wrong ?

Thanks

Can I test this on iOS simulator(not corona simulator)?

yes you do starting from iOS 8.x simulator

@goofeenoodle… Did you come to a nice conclusion with the rate? I have a setting option for users to set the rate but want to initiate the app with a default. I guess I can do a device detect and set 0.6 or 1.0 for ios… but what should I do for Android ? Is one the default value for Android now? 

Also is the flowing still true :

local rateRange = { min = 0.5, max = 2.0 } local pitchRange = { min = 0.5, max = 2.0 } local volumeRange = { min = 0.0, max = 1.0 }

I find the inconsistencies in the ranges and defaults a bit confusing.

Me to. The pitch settings make some sort of sense on my Android devices, but on my iPad (iOS 9.2.1) the above pitch range is not what I experience at all…

Here’s how it behaves on my iPad:

https://youtu.be/NTBkNf-V5zU

The pitch is shown in the upper left corner of the screen.

I my experience the pitch works like this:

0.500 - 0.999  Slow to normal

1.000 - 2.000 Stupid fast (and seems to be the same from 1.0 and up)

On Android pitch and rate should work as intendent (1 - normal, 0.5 - slow, 2 - fast). But on iOS it’s trickier. I’ll see how I can improve it.

Also I’ve been working on the Android version and it now has callback and other features. It’s not yet published, but you can preview the new API here http://spiralcodestudio.com/plugin-texttospeech/
I’ll publish when I update iOS version. Keep in mind that it is a breaking change - you must now call texttospeech.init() before calling anything else.

Thanks Lerg! Callback news just what I’d been hoping to hear - and the addition of voices will also be extremely useful. Will that be available on iOS?

Yes! The workflow will be a little different on iOS and Android, but I try to make it similar.

Just uploaded a new version of the plugin. To use it you have to have Corona version 2830 or later.

What’s new:

texttospeech.init(callback) to prepare the system. Breaking change.

texttospeech.getLanguagesAndVoices() to get available languages and voices.

texttospeech.setEngine(engine) to set a different engine on Android.

texttospeech.isSpeaking() returns true if speaking.

New options for texttospeech.speak()

options.voice - specify voice

option.id - just a tag value

options.onComplete(id) - called when speech has ended

Changed  options.rate behavior on iOS (breaking change). Apparently it’s a complete mess on iOS, so I decided not to make any adjustments of the value and directly submit your value into the guts of the speech engine. On Android it stays the same.

If nothing is submitted, default is default by OS.

So you have to find optimal rate values for different iOS versions and for Android.

Please see the updated docs:
http://spiralcodestudio.com/plugin-texttospeech/

And updated sample:
https://github.com/Lerg/plugins-sample-texttospeech

Not sure how plugin updates work. Does the new plugin load automatically, or do we grab it again from the store?

Its automatic. Just build your app. It should pick up the latest. If you don’t see the latest, give it a couple of hours to clear any caching involved.

Rob

Excellent work Lerg!

This is a great development in the plugin, I will update my code to integrate the new functionalities.
Thanks for making the onComplete callback, it will be very useful for a lot of people.

I have no idea how the native C and Java APIs differ but did you say there’s no possibility for predicting speech time for use in a progress bar?

I don’t have any use for the changes made lately (the only thing I’ve not got a grasp on is the iOS rate), but still applaud the work being continued on this project  :slight_smile:

Thanks!

No, there is no way of getting the length of the speech. You can only measure it yourself and put in the code the durations.

Thanks!

@everyone, when somebody get’s the rates values across iOS versions/devices, please share. Also please test the Alex voice, my iPad doesn’t have it.