使用setVoice更改语音样式(android.speech.tts.Voice)

时间:2015-04-18 08:55:12

标签: android google-text-to-speech

我需要将用户文本的语音风格更改为语音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());
}

我在API级别21上添加了Android Voice类 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)

1 个答案:

答案 0 :(得分: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);