1

我需要将用户文本的语音样式更改为语音 tts 引擎下面是我的代码

private TextToSpeech tts;
tts = new TextToSpeech(context, new TextToSpeech.OnInitListener() {
Voice voiceobj = new Voice("This is kirti for welcome you", Locale.getDefault(), 1, 1, false,
                     "This is");
            tts.setVoice(tts.getVoice());
}

我正在使用 android Voice 类作为它添加到 API 级别 21 http://developer.android.com/reference/android/speech/tts/Voice.html

对于 Setvoice () http://developer.android.com/reference/android/speech/tts/TextToSpeech.html#setVoice(android.speech.tts.Voice)

4

1 回答 1

2

这是设置方法的方式,名称,包含声音的名称。

 Voice voiceobj = new Voice("it-it-x-kda#male_2-local", 
     Locale.getDefault(), 1, 1, false, null);

 tts.setVoice(voiceobj);
 String text = "Ciao Daniel, come stai?";
 tts.speak(text, TextToSpeech.QUEUE_FLUSH, null,null);
于 2018-02-13T17:12:41.777 回答