【问题标题】:Android TTS male voicesAndroid TTS 男声
【发布时间】:2016-08-09 10:31:31
【问题描述】:

android.speech.tts.Voice可以安装配置一些男声吗?我读过一些新闻,Android 最近提供了一些,但我找不到或配置任何内容。我用命令tts.setLanguage(Locale.ITALY); 尝试的都是女性。

【问题讨论】:

标签: android text-to-speech speech-synthesis google-voice


【解决方案1】:

不,目前没有。需要enhancement request,以便可以将性别包含在Voice Feature Set 中,这样:

语音[名称:en-AU-afi-network,区域设置:en_AU,质量:500,延迟:400,requiresNetwork:true,功能:[networkTimeoutMs, networkRetriesCount, ma​​le]]

我已向 Text to Speech 提供商发送了电子邮件,要求将其包含在内 - 因为等待 Google 的增强功能可能还需要数年时间。

与此同时,您所能做的就是硬编码引擎名称并参考性别。这很耗时,而且无法保证他们不会更改名称.... 对我来说是必须的。

【讨论】:

  • 你知道声音名称中的“afi”是什么意思吗?
  • @brandall 我正在创建一个使用文本到语音的应用程序,我想使用不同的声音而不是默认的女性声音,这听起来像机器人。我对此进行了研发,但找不到任何整合男性声音的方法。我从 tts.getVoices() 获得了所有声音,并且我已经硬编码了引擎的名称,但它在某些设备中不支持
  • 当我使用 Set a=new HashSet(); a.add("男"); //语音 v=new Voice("en-us-x-sfg#female_2-local",new Locale("en","US"),400,200,true,a);语音 v=new Voice("hi-IN-x-sfg#male_2-local",new Locale("hi","IN"),400,200,true,a); tts.setVoice(v); if (status == TextToSpeech.SUCCESS) { int result = tts.setVoice(v); ------------------> hi-IN locale 总是发出女性声音,请帮助我
【解决方案2】:

为了增强@brandall 的回答,可以使用男/女声音并从应用程序 UI 动态更改它。像这样定义 TTS(在构造函数中添加 tts 引擎):

tts = new TextToSpeech(context, this, "com.google.android.tts");

contex = 活动/应用程序

this=TextToSpeech.OnInitListener

tts.getVoices() 列表中,通过它的名称选择你想要的声音,如下所示:

for (Voice tmpVoice : tts.getVoices()) {
            if (tmpVoice.getName().equals(_voiceName)) {
                return tmpVoice;
                break;
            }
}

注意:你需要通过从tts.getVoices() 获取硬编码的voice_name 来设置_voiceName。例如:对于英国男性,它将是:“en-us-x-sfg#male_1-local”

【讨论】:

  • 我已经硬编码了您在上面定义的引擎名称,但它不支持某些设备并以默认语音说话。有什么解决办法?
  • 我想要男性声音作为语言环境你好,---- >它总是给女性声音作为 hi-IN 语言环境——我使用你的代码来获取 tts.getVoices() 并且之前它给出了正确的value like => "hi-in-x-cfn#male_3-local" ,但现在它改变了 tts.getVoices() 改变了值 => Voice[Name: hi-in-x-hia-local, locale: hi_IN ,质量:400,延迟:200,requiresNetwork:false,功能:[networkTimeoutMs,networkRetriesCount]],请指导我在哪里失踪?
【解决方案3】:
// use this code after onInit success assuming you have initilaised text to speech as tts

Set<Voice> voices = tts.getVoices();
for (Voice tmpVoice : tts.getVoices()) {
    if (tmpVoice.getName().contains("#male") && tmpVoice.getName().contains("en-us")) {
        voice = tmpVoice;
        break;
    }
    else {
        voice = null;
    }
}
if (voice != null) {
    tts.setVoice(voice);
}

on_init 成功后使用此代码,进行版本检查,因为getVoices() 已添加到 API 级别 21

【讨论】:

  • 在上述解决方案中 if (tmpVoice.getName().contains("#male") && tmpVoice.getName().contains("en-us")) 永远不会给出真实的结果,因为 tts。 getVoice() 不包含诸如“男性”关键字之类的东西,两天前我得到了男性和女性声音的结果,但现在相同的代码不适用于男性,每次女性声音和 tts.getVoices() 给出 Voice[名称:hi-in-x-hia-local,语言环境:hi_IN,质量:400,延迟:200,requiresNetwork:false,功能:[networkTimeoutMs,networkRetriesCount]] 我听不到男性声音的地方。请指导我为什么会这样。
【解决方案4】:

我在这里发布使用谷歌语音引擎选择男性或女性声音的代码。

    Set<String> a=new HashSet<>();
    a.add("female");//here you can give male if you want to select mail voice.

    Voice v=new Voice("en-us-x-sfg#female_2-local",new Locale("en","US"),400,200,true,a); 
    myTTS.setVoice(v);

这里最关心 Voices 的名称。比如“en-us-x-sfg#female_2-local”

您可以使用以下方法获取所有声音,并可以文件下载。

myTTS.getVoices() // you can get all voices of male female related information which we can set in Voice.whoever voice we want to listen.(male /female.)

【讨论】:

  • 设备对区域设置 es_ES (包括男性或女性)的默认语音支持是什么?或者如果设备不支持,它会先安装然后使用?有什么解决办法?
  • 这取决于语音引擎是否有语音。否则需要安装语音引擎和语音引擎提供的特定语音。
  • 我需要以人声或非机器人语音来语音文本。有什么方法可以实现吗?设备有默认引擎吗?
  • 我想要男声作为语言环境你好,----> 当我使用 Set a=new HashSet(); a.add("男"); //语音 v=new Voice("en-us-x-sfg#female_2-local",new Locale("en","US"),400,200,true,a);语音 v=new Voice("hi-IN-x-sfg#male_2-local",new Locale("hi","IN"),400,200,true,a); tts.setVoice(v); if (status == TextToSpeech.SUCCESS) { int result = tts.setVoice(v); ------------------> 它总是为 hi-IN 语言环境发出女性声音,请帮助我 -
猜你喜欢
  • 2012-02-12
  • 1970-01-01
  • 1970-01-01
  • 2012-04-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多