Changing the default voice of Android's Text To Speech

梦想的初衷 提交于 2019-12-03 10:07:54

问题


I'm using the Android's Text To Speech default engine in my app, however the female's voice sounds like a woman over 40 and her voice is somewhat robotic.

I saw other apps that seems to use Google's built in TTS, but it sounds a lot better i.e young woman with a more natural voice.

That "natural" voice is also being used in the Android main Google Search e.g. when you press on the mic and ask a question (Siri style) like "who is the president of the US", the woman's voice will tell you the answer.

How can this voice be achieved in the code?

Basically this is what I do in my code:

    TextToSpeech tts = new TextToSpeech(this, this);
          .
          .
          .
    tts.setLanguage(Locale.US);
    tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);

回答1:


Here is my code to use KEY_FEATURE_NETWORK_SYNTHESIS param:

HashMap<String, String> onlineSpeech = new HashMap<>();
onlineSpeech.put(TextToSpeech.Engine.KEY_FEATURE_NETWORK_SYNTHESIS, "true");
tts.speak(speech, TextToSpeech.QUEUE_FLUSH, onlineSpeech);



回答2:


You cannot change this within the TextToSpeech. You can download other applications that replace it however, with the current system you can only set the language and set the pitch. If you are just wanting something different you can get a British accent by setting it to English UK. Ivona is one of the biggest alternatives to googles text to speech voice.




回答3:


I've eventually managed to find a solution. I just needed to use the KEY_FEATURE_NETWORK_SYNTHESIS param which is available on jellybean. The default offline mode has the awful robotic sound



来源:https://stackoverflow.com/questions/17914297/changing-the-default-voice-of-androids-text-to-speech

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!