Art*_*uro 0 android text-to-speech speech-synthesis google-voice
是否可以安装和配置一些男性声音android.speech.tts.Voice?我读过一些消息,说Android最近已经提供了一些消息,但是我找不到或配置任何消息。我尝试使用命令的tts.setLanguage(Locale.ITALY);都是女性。
为了增强@brandall的答案,可以使用男声/女声并从应用程序用户界面动态更改它。像这样定义 TTS(在构造函数中添加 tts 引擎):
tts = new TextToSpeech(context, this, "com.google.android.tts");
Run Code Online (Sandbox Code Playgroud)
上下文=活动/应用程序
这= TextToSpeech.OnInitListener
从tts.getVoices()列表中,通过名称选择您想要的声音,如下所示:
for (Voice tmpVoice : tts.getVoices()) {
if (tmpVoice.getName().equals(_voiceName)) {
return tmpVoice;
break;
}
}
Run Code Online (Sandbox Code Playgroud)
注意:您需要_voiceName通过从 中获取硬编码的 voice_name 来设置tts.getVoices()。例如:对于英国男性,则为:“en-us-x-sfg#male_1-local”
| 归档时间: |
|
| 查看次数: |
7184 次 |
| 最近记录: |