capacitor-community / text-to-speech

⚡️ Capacitor plugin for synthesizing speech from text.
MIT License
93 stars 23 forks source link

bug: Picking Google Voice on a Samsung Device doesn't work #115

Closed eyedean closed 1 day ago

eyedean commented 1 month ago

Plugin version: I am on a fork version of an old version (limitation on Capacitor Upgrade), but I am afraid it happens everywhere.

Platform(s): Android

Current behavior: On Samsung devices, when openInstall() is called a pop-up appears to select the Engine ("Continue using ...") between Samsung's TTS and Google's TTS.

Choosing Google doesn't do anything.

Screenshot at May 29 11-34-14

Expected behavior: Choosing Google should switch to Google TTS Engine.

Steps to reproduce:

  1. You can get a Samsung device Real-Time emulator (which can connect to Android Studio using RDB <> ADB bridge) at https://developer.samsung.com/remotetestlab/devices/125/galaxy-s.
  2. Call openInstall()

Related code: The only way I could get a Samsung device use Google's TTS (voices and etc.) is by hardcoding the engine name (com.google.android.tts) in the constructor of the tts object as instructed by @robingenz here.

Other than than, there is no way for it to dynamically switch.

Other information:

  1. I tried so hard to even get the user's choice on that pop-up to reconstruct the global tts with Google's if that's what is chosen. But, unfortunately, I couldn't find any function in Android that would tell which choice was made. (I am not an Android Expert, but I spent 3 hours researching!)
  2. Note that .getEngines() returns 2 engines, but, regardless of the user's choice, the .getDefaultEngine() is always Samsung's over there.
  3. My understanding is that the pop-up (for engine selection by the user) is there to do two things: A) install a TTS engine if it's not there, B) let the user choose between Samsung and Google. The installation is not currently happening in the plugin (it should be like this) and honestly, I don't know if it's needed at all in 2024. The Engine Selection, however, is not working currently. So, perhaps it should be replaced by a set of manual functions to getEngines() and useEngine() (again as asked in https://github.com/capacitor-community/text-to-speech/issues/88).

Thank you guys for making and maintaining this amazing plugin!

robingenz commented 1 month ago

Thank you for your request!

Choosing Google should switch to Google TTS Engine.

The OS is responsible for this. The plugin only opens this modal. For this reason i am closing this issue.

Feel free to create a PR for #88.

eyedean commented 1 month ago

Thank you for your response, @robingenz, and I respect your decision.

I still believe that the way this plugin creates the tts object (in the constructor or plugin load time, before popping the modal via openInstall) is not dynamic enough to update itself after the User has chosen a different engine.

Now, your theory is that it's on the OS. And, once the user makes a decision, the OS should update all the new android.speech.tts.TextToSpeech(...) instances (with no fixed engine) to point to this engine. I don't think that's quite true, though -- the user's choice is only for one action (one speak) and not for all the flying tts objects. So, I believe there must be a way in the plugin to tie this tts object to that user response!

I understand that this request is not a common case, and there are definitely higher-priority items to focus on in an open-source package. So, I will not continue this discussion unless I bring in a PR. :)

Thank you again for your dedication and help!

robingenz commented 1 month ago

I still believe that the way this plugin creates the tts object (in the constructor or plugin load time, before popping the modal via openInstall) is not dynamic enough to update itself after the User has chosen a different engine.

You're right. Now I understand what you mean. I added a new initialize() method which can be called to update the TTS instance. Please give this dev build a try and let me know if your issue is resolve:

npm i @capacitor-community/text-to-speech@4.0.1-dev.1d4e158.1717578191
github-actions[bot] commented 1 day ago

It looks like there hasn't been a reply in 30 days, so I'm closing this issue.