4

我正在开发一个应用程序,它将通过蓝牙 SCO 播放 TextToSpeech 音频。连接到目标蓝牙设备(汽车音响),然后指示 TextToSpeech 引擎说话后,音频开始播放大约需要 15 秒,即使我在通过 SCO 连接和播放 TextToSpeech 之间等待几秒钟。

这是我用来通过 SCO 连接的代码:

AudioManager audioM = (AudioManager) getApplicationContext().getSystemService(getApplicationContext().AUDIO_SERVICE);
audioM.setMode(audioM.MODE_IN_COMMUNICATION);
audioM.setBluetoothScoOn(true);
audioM.startBluetoothSco();
audioM.setSpeakerphoneOn(false);

这是我用来播放 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);

其他 android 应用程序(包括 VOIP 和内置电话应用程序)不会受到这种延迟的影响。我创建的等效 iOS 应用程序没有延迟。所以我知道问题不在于立体声。

任何帮助将不胜感激,谢谢

4

1 回答 1

1

事实证明,这个问题特定于我正在测试的低端设备。我尝试过的所有其他设备都会立即播放。

于 2017-03-14T17:02:18.427 回答