final android.speech.tts.TextToSpeech t1 = new android.speech.tts.TextToSpeech(getApplicationContext(), new android.speech.tts.TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if(status == android.speech.tts.TextToSpeech.ERROR) { Toast.makeText(getApplicationContext(), "Error",Toast.LENGTH_SHORT).show();
}
}
});
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View _v) {
String sentence = edittext1.getText().toString(); Toast.makeText(getApplicationContext(), sentence,Toast.LENGTH_SHORT).show(); t1.speak(sentence,android.speech.tts.TextToSpeech.QUEUE_FLUSH, null); } } );
Komentar