如何在 Android 中的蓝牙上播放文本到语音? [英] How to Text-to-Speech plays on Bluetooth in Android?
本文介绍了如何在 Android 中的蓝牙上播放文本到语音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是安卓新手.我创建了一个应用程序,可以使用 Android Text-To-Speech 读取传入消息.到目前为止,它很好.现在用户想要它必须通过配对的蓝牙播放.
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.
我已经阅读了所有论坛,但我没有明白.现在我如何在蓝牙上播放我的 TTS 引擎?
I'd read all the forums but i didn't get it. Now how i play my TTS engine on Bluetooth ?
有人知道吗?
提前致谢.
推荐答案
在 通过蓝牙耳机使用Android RecognizerIntent
并创建一个像下面这样的说话方法
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);
}
这篇关于如何在 Android 中的蓝牙上播放文本到语音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文