Text to Speech

Hi Lerg. Is there a recommended time to wait for texttospeech.setEngine() to complete before I use texttospeech.getLanguagesAndVoices() … or is there an undocumented onComplete method that I can use? I was trying something like this, but I guess it doesn’t exist?

texttospeech.setEngine('com.google.android.tts', function() print( 'engine ready' ) end)

juliusbangert, you don’t need to wait anything. It returns true/false depending on if the operation was successful or not.
The engine will actually load next time you call speak().

Thanks Lerg.
It doesn’t seem to be doing the right thing for me, I can’t get anything from getLanguagesAndVoices() after changing the engine. Do I need to call init() again after setEngine()? Because in your documentation it says ‘Engine might require some time to be initialized’ I thought maybe it needed a delay. Please see my code and output below.

local preferredEngine = 'com.google.android.tts' local function texttospeechInitOnComplete( event ) print( '\_\_texttospeechInitOnComplete\_\_') if not event.isError then local function getLanguages() local languagesAndVoices = texttospeech.getLanguagesAndVoices() print( 'languagesAndVoices : ' ) table.print( languagesAndVoices ) end if device.isAndroid and event.engines and event.defaultEngine then if event.defaultEngine ~= preferredEngine and table.contains( event.engines, preferredEngine ) then local engineIsSet = texttospeech.setEngine( preferredEngine ) print( 'setting engine to ' .. preferredEngine .. ' : ' .. tostring( engineIsSet ) ) print( 'getLanguages for android' ) getLanguages() end else print( 'getLanguages for apple' ) getLanguages() end end end texttospeech.init( texttospeechInitOnComplete )

NOTE : the above uses some of my own convenience functions table.contains() and table.print() as well as the device library.

Output :

SM-T715: \_\_texttospeechInitOnComplete\_\_ SM-T715: setting engine to com.google.android.tts : true SM-T715: getLanguages for android SM-T715: languagesAndVoices : SM-T715: nil

I’ll check it later.

Thanks Lerg. I suspect it’s something to do with the workaround you added for Samsung TTS that returns nil if an error occurs. But I don’t really know. It still works on HTC.

Hi Lerg. Any news on this?

Hi Lerg.

Sorry to seem like I’m pestering, I want you to know I really appreciate all the work you’re doing on this plugin.

So, as well as the Samsung voices problem I mentioned above, on iOS 9, I’m only getting ‘default’ returned in the voices table when calling getLanguagesAndVoices(). I’m expected to see more options like you mentioned_ ‘alex’_ in your documentation. The resultant voice on iOS 9 for me is really bad ( worse than iOS 7 ). Even though the voice used by Siri is really good. Any ideas on this?

Hi juliusbangert,

So indeed after calling setEngine, you have to wait before calling getLanguagesAndVoices(). My measurement showed that the minimal time to wait is 100ms. So waiting for a second should be enough. Unfortunately there is no callback.

What is your iOS 9 device?

Hi Lerg.

What did you mean when you said “indeed after calling setEngine, you have to wait before calling getLanguagesAndVoices()”? Were you referring to the Samsung voices problem? I still can’t get anything even after a 500ms delay.

__________

The iOS9 test devices I have tried have been an iPad Pro 12.9" and an iPad 4th generation Model A1458. Both of these have extremely poor quality voices with your plugin. The voice on an iPhone 4 iOS 7 sounds much better. Could it be to do with the fact that voices table from **getLanguagesAndVoices() **only contains ‘default’? Any ideas if I’m doing something wrong?

No, I was saying in general.
The issue with samsung is a bug in samsung TTS engine, it is not related to the plugin, I just included a workaround for it. It will always return nothing until the bug is fixed.

Regarding iOS, yes, it seems that the alex voice is not there for some reason. I don’t have such devices, so it’s hard for me to look into it. I’ll think about it later, be sure to ping me in a week.

Hi Lerg;

Love the plugin. I am confident that it is going to be a popular feature on a word game we are developing.

Say, I had “hoped” that the Android coverage would also include Amazon devices (a really good market for our games). But on our test Kindle Fire HD 7" tablet, it doesn’t produce any sound.

Interestingly, it doesn’t create any error when I create the instance of the plugin and it fails silently when I actually try to speak with it. It doesn’t produce any log errors or messages. It simply doesn’t speak. The Kindle is running Amazon’s Fire OS 5.1.1 which is based on Android 5.1 SDK Level 22. Hence, the Android version seems modern enough.

The device does show that Text-to-Speech is a feature on the device (in a Settings screen) with a default voice of “Salli (USA)”. And being a Kindle, it will read books to me.

Simply wondering if you have any insight on this. Thanks.

Steve

Hi guys

I’m using Corona Enterprise and I would like to add your TTS plugin

I’ve tried to do it as you explain in your sample but I’ve got an issue (cf screenshot below)

I’ve downloaded Plugin Enterprise too, but your Plugin is not on the directory, so same result.

How can I do?

Where should I declare this plugin if I want to use it with Corona Enterprise?

Any help would be very appreciated :slight_smile:

Best regards

Olivier

issue.jpg

sbullock, does the plugin see any engines? From the init event list.

oromanetti, you need to download the plugin from the Corona’s bitbucket repository. I don’t remember the link, but you can find it.

Ok thank you Lerg!

Can you help me get settled?

here is the link: https://bitbucket.org/coronalabs/store-hosted-texttospeech/downloads

Best

Olivier

I’ve downloaded the Plugin.

  • Do you know what is the difference between “iphone” and “iphone-sim” directories?

  • Which libplugin_texttospeech.a  should I add in my XCode project?

  • What is the role of the metadata.lua file?

Thank you very much for your help

Best,

Olivier

Hi Lerg;

Thanks for getting back. After your question, I realized that the last time I had built the amazon version and tested the speech on a device was back in February when an “init” wasn’t even a part of the process. That’s what was missing in my Amazon code. Sorry about that. BTW – these are the engines on the Kindle Fire HD:

I/Corona  ( 7805): =================  initCallback   =================

I/Corona  ( 7805):  engines :

I/Corona  ( 7805):      Key: Pico TTS        Value: com.svox.pico

I/Corona  ( 7805):      Key: IVONA TTS    Value: com.ivona.tts.oem

I/Corona  ( 7805): =================================================

I/Corona  ( 7805): =================================================

I/Corona  ( 7805): Key: isError   Value = false

I/Corona  ( 7805): =================================================

I/Corona  ( 7805): Key: defaultEngine   Value = com.ivona.tts.oem

I/Corona  ( 7805): =================================================

Thanks;

Steve

oromanetti, iphone is for real device (you should use it), iphone-sim is for iphone simulator (use only when testing in iphone simulator).
metadata.lua can hold special configuration for the plugin, luckily there isn’t any for texttospeech.

sbullock, also see what getLanguagesAndVoices are returned for that com.ivona.tts.oem engine. If it doesn’t work, switch to com.svox.pico using setEngine() function.

Thanks Lerg :slight_smile:

Thanks Lerg.

Hi,

I’ve got a problem with the dot “.”

For example, if I want the plugin to say this sentence : “a red tie. a big bike. ride a bike. hide and seek. I like this bike. find the dog. back pack. sun shine.

it completely ignores the dot.

Did I miss something?

Thanks for your help