文本转语音同时接收多个语音请求

发布于 2025-01-07 06:15:57 字数 374 浏览 0 评论 0原文

我正在编写一个应用程序,可以逐个读出字符串。我的问题是,TTS 似乎在第一对夫妇中结结巴巴,正确地说出一个然后就停止了。我不明白为什么。

    public void onInit(int status) {

    Log.d("TTS", "2");
    String text = desc;
    Toast.makeText(ct, "Saying: " + text, Toast.LENGTH_LONG).show();
    tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
}

此 onInit 方法位于广播接收器中,因此每次收到接近警报时,它都会读取关联的字符串。我真的很感激一些帮助。

I am writing an app that reads out strings one after the other. My problem is that TTS seems to stutter through the first couple, say one properly and then stop. I can't understand why.

    public void onInit(int status) {

    Log.d("TTS", "2");
    String text = desc;
    Toast.makeText(ct, "Saying: " + text, Toast.LENGTH_LONG).show();
    tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
}

This onInit method is located in a Broadcast Receiver so every time a proximity alert is received it reads the associated String. I'd really appreciate some help with this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

留蓝 2025-01-14 06:15:57

我不知道它是否可以帮助您解决您的情况,但我面临的问题是它多次收到说话的请求,因此它不断重复新的字符串并且不完成前一个字符串。所以我做了这个技巧。希望它可以帮助你。:P

public void onInit(int status) {

    Log.d("TTS", "2");
    String text = desc;
    Toast.makeText(ct, "Saying: " + text, Toast.LENGTH_LONG).show();

    if(!tts.isSpeaking())               
        tts.speak(text,TextToSpeech.QUEUE_FLUSH,null);       
}

I don't know whether it can help you in your case or not,but I was facing problem like it gets requests to speak many time and hence it keeps on repeating the new strings and doesn't complete the previous one.So I did this trick.Hope it can help you for yours.:P

public void onInit(int status) {

    Log.d("TTS", "2");
    String text = desc;
    Toast.makeText(ct, "Saying: " + text, Toast.LENGTH_LONG).show();

    if(!tts.isSpeaking())               
        tts.speak(text,TextToSpeech.QUEUE_FLUSH,null);       
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文