How to Text-to-Speech plays on Bluetooth in Android?

杀马特。学长 韩版系。学妹 提交于 2021-02-19 05:24:22

问题


I'm a newbie for android. I've created an app that can read Incoming messages using Android Text-To-Speech. Up to now its fine with it. Now user's want It has to play over paired Bluetooth.

I'd read all the forums but i didn't get it. Now how i play my TTS engine on Bluetooth ?

Anyone having any idea ?

Thanks in advance.


回答1:


Use my answer at Using the Android RecognizerIntent with a bluetooth headset

And create a speak method like below

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);
}


来源:https://stackoverflow.com/questions/15392457/how-to-text-to-speech-plays-on-bluetooth-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!