Text to Speech

juliusbangert, if Apple adds support for file save in iOS, I will reflect that in the plugin, but for now - not likely.

Audio file is generated quickly, you can wait for it to be generated and play it.

A separate function like texttospeech.save() should have all the parameters of the speek() function, they would be too similar to be broken apart.

You can get the speech time by saving to a file and reading it’s length, no other way so far.

Hi Lerg,

Is it possible to use other voices besides the lists below for iOS?

“voices”:{

                        “com.apple.speech.synthesis.voice.Bruce”:“en-US”,

                        “com.apple.speech.synthesis.voice.yelda”:“tr-TR”,

                        “com.apple.speech.synthesis.voice.Boing”:“en-US”,

                        “com.apple.speech.synthesis.voice.Hysterical”:“en-US”,

                        “com.apple.speech.synthesis.voice.kanya”:“th-TH”,

                        “com.apple.speech.synthesis.voice.Trinoids”:“en-US”,

                        “com.apple.speech.synthesis.voice.Zarvox”:“en-US”,

                        “com.apple.speech.synthesis.voice.joana”:“pt-PT”,

                        “com.apple.speech.synthesis.voice.damayanti”:“id-ID”,

                        “com.apple.speech.synthesis.voice.veena”:“en-IN”,

                        “com.apple.speech.synthesis.voice.alice”:“it-IT”,

                        “com.apple.speech.synthesis.voice.tessa”:“en-ZA”,

                        “com.apple.speech.synthesis.voice.kyoko”:“ja-JP”,

                        “com.apple.speech.synthesis.voice.daniel”:“en-GB”,

                        “com.apple.speech.synthesis.voice.ting-ting”:“zh-CN”,

                        “com.apple.speech.synthesis.voice.Vicki”:“en-US”,

                        “com.apple.speech.synthesis.voice.carmit”:“he-IL”,

                        “com.apple.speech.synthesis.voice.xander”:“nl-NL”,

                        “com.apple.speech.synthesis.voice.mariska”:“hu-HU”,

                        “com.apple.speech.synthesis.voice.ellen”:“nl-BE”,

                        “com.apple.speech.synthesis.voice.Fred”:“en-US”,

                        “com.apple.speech.synthesis.voice.nora”:“nb-NO”,

                        “com.apple.speech.synthesis.voice.Bahh”:“en-US”,

                        “com.apple.speech.synthesis.voice.diego”:“es-AR”,

                        “com.apple.speech.synthesis.voice.Victoria”:“en-US”,

                        “com.apple.speech.synthesis.voice.monica”:“es-ES”,

                        “com.apple.speech.synthesis.voice.satu”:“fi-FI”,

                        “com.apple.speech.synthesis.voice.Cellos”:“en-US”,

                        “com.apple.speech.synthesis.voice.GoodNews”:“en-US”,

                        “com.apple.speech.synthesis.voice.karen”:“en-AU”,

                        “com.apple.speech.synthesis.voice.moira”:“en-IE”,

                        “com.apple.speech.synthesis.voice.Organ”:“en-US”,

                        “com.apple.speech.synthesis.voice.fiona”:“en-scotland”,

                        “com.apple.speech.synthesis.voice.paulina”:“es-MX”,

                        “com.apple.speech.synthesis.voice.melina”:“el-GR”,

                        “com.apple.speech.synthesis.voice.thomas”:“fr-FR”,

                        “com.apple.speech.synthesis.voice.zosia”:“pl-PL”,

                        “com.apple.speech.synthesis.voice.zuzana”:“cs-CZ”,

                        “com.apple.speech.synthesis.voice.ioana”:“ro-RO”,

                        “com.apple.speech.synthesis.voice.Agnes”:“en-US”,

                        “com.apple.speech.synthesis.voice.Ralph”:“en-US”,

                        “com.apple.speech.synthesis.voice.Kathy”:“en-US”,

                        “com.apple.speech.synthesis.voice.lekha”:“hi-IN”,

                        “com.apple.speech.synthesis.voice.Deranged”:“en-US”,

                        “com.apple.speech.synthesis.voice.milena”:“ru-RU”,

                        “com.apple.speech.synthesis.voice.Whisper”:“en-US”,

                        “com.apple.speech.synthesis.voice.alva”:“sv-SE”,

                        “com.apple.speech.synthesis.voice.yuna”:“ko-KR”,

                        “com.apple.speech.synthesis.voice.Junior”:“en-US”,

                        “com.apple.speech.synthesis.voice.samantha”:“en-US”,

                        “com.apple.speech.synthesis.voice.Bubbles”:“en-US”,

                        “com.apple.speech.synthesis.voice.luciana.premium”:“pt-BR”,

                        “com.apple.speech.synthesis.voice.Princess”:“en-US”,

                        “com.apple.speech.synthesis.voice.Alex”:“en-US”,

                        “com.apple.speech.synthesis.voice.amelie”:“fr-CA”,

                        “com.apple.speech.synthesis.voice.Albert”:“en-US”,

                        “com.apple.speech.synthesis.voice.laura”:“sk-SK”,

                        “com.apple.speech.synthesis.voice.sin-ji”:“zh-HK”,

                        “com.apple.speech.synthesis.voice.maged”:“ar-SA”,

                        “com.apple.speech.synthesis.voice.BadNews”:“en-US”,

                        “com.apple.speech.synthesis.voice.anna”:“de-DE”,

                        “com.apple.speech.synthesis.voice.Bells”:“en-US”,

                        “com.apple.speech.synthesis.voice.mei-jia”:“zh-TW”,

                        “com.apple.speech.synthesis.voice.sara”:“da-DK”

                    }

Thanks.

Hi Lerg,

first of all I’m glad, that there is this TextToSpeech plugin, because I want to use it for my project. Thanks for providing this.

 

I’ve bought the plugin, but some things don’t work, so currently I cannot use it at all.  :frowning:

 

I currently encounter these problems using your newest sample code:

 

On the Mac using the Simulator

On my mobile device

  • output in english language, not spanish like configured, even if spanish is set as default text-to-speech output language
  • the command for silencing in between words is not interpreted as silence but is spoken. e.g. “blabla [[slnc 1000]] blabla”
  • the pause button of your example does not work

I use this setup:

Corona Version v2016.2992

MacBook Pro with macOS Sierra 10.12.3 (16D32)

Mobile Sony Xperia E6533 with Android 6.0.1

 

Is there somebody else experiencing these problems?

 

I hope these issues can be reproduced and fixed soon.  :) 

 

Thanks,

Jörg

dev179, there is an option of downloading more voices, but that has to be done by the user.

info36013, simulator uses the same code, it just might be an issue of the simulator, I will look at it at some point, but later.

You might be using wrong language string for the engine, or the spanish simply absent from the chosen text-to-speech engine. Check with getLanguagesAndVoices and see what engines are available and what is selected.

Where did you get that silencing command from?

Pause doesn’t work on Android, it’s simply not available in Android API. You can however synthesize to a file and play/pause it.

Hey Lerg, great plugin!

Currently on Mac simulator the pitch value seems not to have an impact on the voice.

Like info36013 wrote the voice is quite low and the pitch setting does not change it.

Is this a bug?

Simulator:

After I had experienced the simulator crashes, I’ve contacted CoronaLabs first. They suggested to contact you. :wink:

I’ll forward you the message by email, also with the technical details.

Language string:

Thanks for the hint. Indeed it is possible, that I use the wrong language string. I’ll check this soon.

Silencing command: 

I’m used to the silencing command because of using the Apple voices on the mac (using the ‘say’ shell command).

These commands can be found here:

https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/SpeechSynthesisProgrammingGuide/FineTuning/FineTuning.html
Now it got clear for me, why the ‘slnc’ command is only working in the Corona simulator, but not on the mobile. The simulator obviously makes use of the mac’s text to speech engine, which is not available on the mobile.

Pause button/command:

Ok, then if the Android API does not support the pause command natively, I would regard it helpful to disable this button in your example code for Android (or at least place a big comment in the code), not to confuse the plugin users. :wink:

There seems to be some need for the pause command out there, as somebody made an “Implementation of the missing feature in Android SDK: audio recorder with a pause.”
https://github.com/lassana/continuous-audiorecorder

update to my previous post

Language string:

I’ve used these language strings now for testing and both work well on my mobile:

texttospeech.speak(text, {language = “es-ES”, voice = “es-es-x-ana-network”, …

and

texttospeech.speak(text, {language = “es-US”, voice = “es-US-language”, …

Simulator:

Lerg, could you get in contact with the Corona Simulator Crew? Any news on this?

There’s a new Corona SDK version (2017.3068 (2017.3.31)) available since yesterday and I will try if it’s also crashing in conjuction with the plugin or if it is more stable.

DevilSquid , indeed pitch option is broken and no longer works. Looks like it’s an Apple bug, I can’t get it working either.
I’ve removed the pitch option for now.

info36013, I’ve fixed the crash. No idea how it helped, just added a redundant memory cleaning code and that seems like it worked.
There is warning the console if something is not supported.

I just purchased textToSpeech Plugin.
I download the sample project from here : https://github.com/Lerg/plugins-sample-texttospeech

i run the code and getting this error…


Platform: iPhone / x86_64 / 10.12.3 / Intel HD Graphics 4000 OpenGL Engine / 2.1 INTEL-10.22.29 / 2016.3009 / en-IN | IN | en_IN | en

Apr 21 07:49:07.727 ERROR: Runtime error

                    main.lua:15: attempt to call field ‘enableDebug’ (a nil value)

                    stack traceback:

                    main.lua:15: in main chunk


i am using corona Build: 2016.3009

Please help me…

Bhavin 
 

BK PANARA, try the latest daily build.

This works for me too…

Thanks you so much Lerag for reply.

Bhavin :slight_smile:
 

Hey Lerg,

I’m seeing this backtrace reported from some users when I call init(callback):

Tts.lua:68: java.lang.IllegalArgumentException: Service not registered: android.speech.tts.TextToSpeechConnection4248d3f8
Java Stack Trace:
    android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:926)
    android.app.ContextImpl.unbindService(ContextImpl.java:1991)
    android.content.ContextWrapper.unbindService(ContextWrapper.java:541)
    android.speech.tts.TextToSpeechConnection.disconnect(TextToSpeech.java:1578)
    android.speech.tts.TextToSpeech1.run(TextToSpeech.java:732)
    android.speec

Anything I can do to detect and gracefully handle such a situation?

Cheers,

Per

Our App reported 63 crashes in what appears to be related to text to speech - and this is in a LIVE version of the App that has been published and working fine for more than a month.

This makes me wonder, are the plugins not compiled at build time? So that every time we had a plugin to our app, we are creating a new dependency that requires online connectivity and could result in such a problem? So my question is two-fold.
 

  1. how is Corona (non-enterprise) structured and what are its dependencies?

  2. can you please help us to resolve this asap? We’re about to release a new version tomorrow and the timing of this couldn’t be worse - our LIVE version has stopped working and we can’t publish a new version until this problem is resolved.

Here is the crash info from Google Play ANRs & Crashes

java.lang.IllegalStateException:

at com.naef.jnlua.LuaState.lua_settable(Native Method:0)

at com.naef.jnlua.LuaState.setTable(Unknown Source:0)

at plugin.texttospeech.LuaUtils.pushHashtable(LuaUtils.java:695)

at plugin.texttospeech.LuaUtils$1.executeUsing(LuaUtils.java:89)

at com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:170)

at com.ansca.corona.events.EventManager.sendEvents(EventManager.java:91)

at com.ansca.corona.Controller.updateRuntimeState(Controller.java:308)

at com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:421)

at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1623)

at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1378)

I can answer the first one

When you build an app the plugins are added at build time. There is no way for a plugin developer to change plugins code at all once the app is built.

Hi. I will take a look soon.

Does anyone know if the “utterance” events, from the Android TTS API, are exposed with this plugin?

Here’s a reference from the Android Developer site:

https://developer.android.com/reference/android/speech/tts/TextToSpeech.OnUtteranceCompletedListener.html

Thanks!

troylyndon, I couldn’t find the issue on my own. If you have more details or can reproduce it - please share.

LarryKing, yes, it’s onComplete listener in the speak() params.

Lerg, thank you for the response, I’ll give it a shot!

Hi there!, i was trying to implement the plugin to my app, but in Android the app crash when i move between scenes, this is my log:

*With iOS the app works perfect

07-09 21:19:17.130  21595-21641/? D/plugin.texttospeech﹕ init()

07-09 21:19:17.145  21595-21641/? I/TextToSpeech﹕ Sucessfully bound to com.google.android.tts

07-09 21:19:17.187  14851-14851/? I/TTS﹕ Creating Google TTS service, version 3.11.12

07-09 21:19:17.187  14851-14851/? I/TTS﹕ Loading library tts_android_neon

07-09 21:19:17.189  14851-14851/? I/TTS﹕ Couldn’t read preferred locale from settings.

07-09 21:19:17.191  14851-15594/? I/TTS﹕ Initializing es-us-x-sfb-lstm-embedded from disk

07-09 21:19:17.192  21595-21595/? I/TextToSpeech﹕ Connected to ComponentInfo{com.google.android.tts/com.google.android.tts.service.GoogleTTSService}

07-09 21:19:17.195  14851-14862/? I/TTS﹕ Couldn’t read preferred locale from settings.

07-09 21:19:17.198  14851-14862/? I/TTS﹕ Couldn’t read preferred locale from settings.

07-09 21:19:17.198  14851-14862/? I/TTS﹕ For default lang es-us is name es-US-language (es-us-x-sfb-server)

07-09 21:19:17.200  21595-21721/? I/TextToSpeech﹕ Set up connection to ComponentInfo{com.google.android.tts/com.google.android.tts.service.GoogleTTSService}

07-09 21:19:17.201  21595-21595/? D/plugin.texttospeech﹕ onInit()

07-09 21:19:17.235      253-253/? I/SFPerfTracer﹕ triggers: (rate: 9:2423) (compose: 0:37) (post: 0:1014) (render: 1:157) (253:200245 frames) (254:225850)

07-09 21:19:17.235      253-253/? D/SFPerfTracer﹕ layers: (2:10) (FocusedStackFrame (0xb73d2878): 0:1185)* (DimLayer (0xb73d4cf0): 0:78)* (DimLayer (0xb742c6e8): 0:2)* (StatusBar (0xb7429028): 5:23365)* (com.android.systemui.ImageWallpaper (0xb73ae418): 0:800)* (NavigationBar (0xb74099d0): 36:2145) (DimLayer (0xb73ab758): 0:94)* (DimLayer (0xb741d3b8): 0:10)* (com.gmail.pablovydra.Turismo_1_2/com.ansca.corona.CoronaActivity (0xb7405988): 0:6)* (SurfaceView (0xb7370a18): 237:769)

07-09 21:19:17.551  21595-21641/? I/Corona﹕ Init callback

07-09 21:19:17.551  21595-21641/? I/Corona﹕ Android

07-09 21:19:17.551  21595-21641/? I/Corona﹕ Engines: {

    “Motor de texto a voz de Google”:“com.google.android.tts”

    }

07-09 21:19:17.551  21595-21641/? I/Corona﹕ Default engine: com.google.android.tts

07-09 21:19:17.551  21595-21641/? D/plugin.texttospeech﹕ getLanguagesAndVoices()

07-09 21:19:17.986    2234-7001/? I/WindowState﹕ WIN DEATH: Window{8ffedda u0 SurfaceView}

07-09 21:19:17.986    2234-3439/? D/GraphicsStats﹕ Buffer count: 4

07-09 21:19:17.990    2234-3439/? I/WindowState﹕ WIN DEATH: Window{3c3b428 u0 com.gmail.pablovydra.Turismo_1_2/com.ansca.corona.CoronaActivity}

07-09 21:19:18.001    3440-3697/? I/NetworkController.MotorolaMobileSignalController(4)﹕ MotorolaMobilePhoneStateListener.onDataActivity: Entered: direction=4

07-09 21:19:18.006      315-315/? I/Zygote﹕ Process 21595 exited cleanly (1)

Is there any chance you will be able to implement onProgress for Android?