0
我在android studio中將文本轉換爲語音時出錯。我已經初始化了代碼,但它仍然沒有返回語音輸出。代碼如下。android text to speech toast message
else if((match.contains("yes") || match.contains("yeah")) && defsele) {
//Toast toast = Toast.makeText(getApplicationContext(), "Default selection is done and program is starting", Toast.LENGTH_SHORT);
//toast.show();
defsele=false;
switch (progno) {
case 1:
//Toast toast1 = Toast.makeText(getApplicationContext(),"The default settings for cotton cycle is done",Toast.LENGTH_SHORT);
//toast1.show();
String cotton = "The cotton program is starting with the default values";
tts.speak(cotton, TextToSpeech.QUEUE_FLUSH, null);
soak=true;
soakdef();
break;
tts.speak被取消並且不起作用。我如何使這項工作。初始化代碼如下
tts = new TextToSpeech(this,this);
@Override
public void onInit(int status) {
Log.d("Speech", "OnInit - Status ["+status+"]");
if(status == TextToSpeech.SUCCESS){
Log.d("Speech","Success");
tts.setLanguage(Locale.ENGLISH);
我是非常新的android編程,並將不勝感激任何幫助。
感謝高級!!!
不,代碼自動評論本身。無論如何,我可以只使用「tts.speak()」函數初始化api並轉換多個句子。 –