1

我是Android的新手。我創建了一個應用程序,可以使用Android Text-To-Speech讀取傳入消息。到現在爲止它很好。現在用戶希望它必須通過配對的藍牙進行播放。如何在Android中的藍牙文本到語音播放?

我讀過所有的論壇,但我沒有得到它。現在我如何在藍牙上播放我的TTS引擎?

任何人有任何想法?

在此先感謝。

回答

1

使用我的答案在Using the Android RecognizerIntent with a bluetooth headset

,創造像一個speak方法如下

protected void speak(String text) 
{ 

    HashMap<String, String> myHashRender = new HashMap<String, String>(); 

    if (mBluetoothHelper.isOnHeadsetSco()) 
    { 
     myHashRender.put(TextToSpeech.Engine.KEY_PARAM_STREAM, 
       String.valueOf(AudioManager.STREAM_VOICE_CALL)); 
    } 
    mTts.speak(text, TextToSpeech.QUEUE_FLUSH, myHashRender); 
} 
+0

mBluetoothHelper不能被解析爲一個變量在我的MainActivity – 2013-03-13 19:24:47

+0

你在上面的鏈接複製BluetoothHeadsetUtils到您的項目? – 2013-03-13 19:35:21

+0

是的,我複製了,因爲我錯誤轉換你的兩條線 BluetoothHeadsetUtils mBluetoothHelper = new BluetoothHeadsetUtils(this); – 2013-03-13 19:41:45