android关于 text_to_speach的使用(tts)
主要用到两个包
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
其中必须实现OnInitListener里面的方法
OnClickListener mSubmitListener = new OnClickListener() {public void onClick(View v) {//Log the second parameter with the first parameter as the tag.//Note: Window -> Show View... -> Other -> LogCat to view the log in EclipseLog.i("TTS_TEST", "Button clicked - Attempting to speak");//On button click, say whatever is in the textFieldtts.speak(vText.getText().toString(), TextToSpeech.QUEUE_FLUSH, null);}};
?
TextToSpeech.Engine.ACTION_CHECK_TTS_DATA
这里一定要注意TextToSpeech.Engine下的几个常量。
源码来源于网络