2

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 Answers1

3

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);
}
Community
  • 1
  • 1
Hoan Nguyen
  • 18,033
  • 3
  • 50
  • 54
  • mBluetoothHelper cannot be resolved to a variable in my MainActivity – Radhakrishna Rayidi Mar 13 '13 at 19:24
  • Did you copy the BluetoothHeadsetUtils in the above link to your project? – Hoan Nguyen Mar 13 '13 at 19:35
  • Yes i copied, Because of the error i converted your two lines into BluetoothHeadsetUtils mBluetoothHelper = new BluetoothHeadsetUtils(this); – Radhakrishna Rayidi Mar 13 '13 at 19:41
  • I fixed the error there. It should be BluetoothHeadsetUtils mBluetoothHelper; and then the other line is correct. The mBluetoothHelper should be a class member in your class. You declare it as a local variable, that why you got the error. – Hoan Nguyen Mar 13 '13 at 19:46
  • I made a slight modification to the BluetoothHeadsetUtils class about an hour ago. Make sure you get the latest update. If you have mIsStarted in the class then you are up to date. – Hoan Nguyen Mar 13 '13 at 20:01
  • Ok i will follow. If no bluetooth is connected is your code connects to debugger that showing message ? – Radhakrishna Rayidi Mar 13 '13 at 20:04
  • I do not quite understand what do you mean? Do you mean is there a way to find out if there is no connected headset? – Hoan Nguyen Mar 13 '13 at 20:11
  • That's file i will take care of it. Anyway thank you for your time. If i have any questions further i will post here. – Radhakrishna Rayidi Mar 13 '13 at 20:20