private void startAuto(String data) {
// 設定音調,值越大聲音越尖(女生),值越小則變成男聲,1.0是常規
textToSpeech.setPitch(1.0f);
// 設定語速
textToSpeech.setSpeechRate(1.0f);
textToSpeech.speak(data,//輸入中文,若不支持的設備則不會讀出來
TextToSpeech.QUEUE_FLUSH, null);
}
private void initTTS() {
//實體化自帶語音物件
textToSpeech = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if (status == textToSpeech.SUCCESS) {
textToSpeech.setPitch(1.0f);//方法用來控制音調
textToSpeech.setSpeechRate(1.0f);//用來控制語速
//判斷是否支持下面兩種語言
int result1 = textToSpeech.setLanguage(Locale.US);
int result2 = textToSpeech.setLanguage(Locale.
SIMPLIFIED_CHINESE);
boolean a = (result1
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/76441.html
標籤:其他
