Reputation: 1083
I'm developing an app that will play TextToSpeech audio over bluetooth SCO. After connecting to the target bluetooth device (Car stereo), and then instructing the TextToSpeech engine to speak, it takes around 15 seconds for the audio to start playing, even if I wait several seconds between connecting over SCO and playing the TextToSpeech.
Here is the code I'm using to connect over SCO:
AudioManager audioM = (AudioManager) getApplicationContext().getSystemService(getApplicationContext().AUDIO_SERVICE);
audioM.setMode(audioM.MODE_IN_COMMUNICATION);
audioM.setBluetoothScoOn(true);
audioM.startBluetoothSco();
audioM.setSpeakerphoneOn(false);
Here is the code I'm using to play TextToSpeech :
String text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry.";
HashMap<String, String> ttsParams = new HashMap<String, String>();
ttsParams.put(TextToSpeech.Engine.KEY_PARAM_STREAM, String.valueOf(AudioManager.STREAM_VOICE_CALL));
mTts.speak(text, TextToSpeech.QUEUE_FLUSH, ttsParams);
Other android apps (including VOIP and built-in telephony app) do not suffer from this delay. An equivalent iOS app I have created does not have a delay. So I know that the problem is not with the stereo.
Any help would be greatly appreciated, thanks
Upvotes: 5
Views: 850
Reputation: 1083
It turns out the problem was specific to a low-end device I was testing with. All other devices I have tried play immediately.
Upvotes: 2