读书人

android关于 text_to_speach的施用(t

发布时间: 2012-08-22 09:50:35 作者: rapoo

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下的几个常量。

源码来源于网络

读书人网 >Android

热点推荐