Text To Speech
Text To Speech:文字轉換成語音。
android 提供 TextToSpeech 類別達成此目標,並且要指定initListnere。
例如:
private EditText write;
ttob=new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
}
});
這個Listener需要指定文字轉語音的屬性,如音調、語言等,可以透過setLanguage() 來設定。
例如:
ttob.setLanguage(Locale.UK);
Locale 可以接受的當地語言(不只這些)
US
CANADA_FRENCH
GERMANY
ITALY
JAPAN
CHINA
一旦設定好語言,如果想要說出文字,就需要呼叫speak方法。
例如:
ttob.speak(toSpeak, TextToSpeech.QUEUE_FLUSH, null);
QUEUE_FLUSH:講完所輸入的文字或數字。
QUEUE_FLUSH:講完所輸入的文字或數字。
TextToSpeech 其他方法
addSpeech(String text, String filename):語音和文字描述一同儲存於TextToSpeech 庫中。
getLanguage():取得Locale 的語言。
isSpeaking():判斷TextToSpeech是否在忙碌中。
setPitch(float pitch):設置TextToSpeech文字轉語音的音調。
setSpeechRate(float speechRate):設定語音速率。
shutdown():釋放TextToSpeech的資源。
stop():TextToSpeech 停止說話。
參考文獻
Android - Text To Speech
Android文本到語音教程
透過 Android TTS API 進行 Text To Speech
Android TTS
Android手機開發文字轉語音程式-TTS(Text to spech) 附程式碼
Android 文字轉語音 text to speech
[Android] TextToSpeech (TTS) 簡易教學
Android 文字轉語音 text to speech
android getLanguage, getCountry list(getLanguage)
Android-筆記 取得系統語言(getLanguage)
java獲取系統語言(區分簡體中文和繁體中文)
[Android API] TextToSpeech 好用文字發音(setpitch)
IOS和Android音頻開發總結
Android TTS 自動發聲
Android TextToSpeech 讓Android說話
http://cookiesp.pixnet.net/blog/post/82122159-android-texttospeech-%E8%AE%93android%E8%AA%AA%E8%A9%B1
[Android] 如何使用 TextToSpeech (TTS)
http://shung007.blogspot.tw/2010/12/android-texttospeech-tts.html
[Android] 如何使用 TextToSpeech (TTS)
http://shung007.blogspot.tw/2010/12/android-texttospeech-tts.html
沒有留言:
張貼留言