安卓的文本到语音的两个实例的工作非常缓慢 [英] Android: two instances of Text-to-Speech work very slowly

查看:211
本文介绍了安卓的文本到语音的两个实例的工作非常缓慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要实现我的Andorind应用程序,它允许电流活性的研究使两种不同的合成语言的特点 - 具有两个按钮,例如说英语和法语说。

I need to implement feature in my Andorind app which allows to play two different synthesized languages in current Acitivity - for instance having two buttons Say English and Say French

我试图做到这一点在以下两种方式但他们两人的工作不力,因为有较长时间的延迟之前播放声音:

I've tried to do it in two following ways but both of them works ineffectively because there is long delay before sound plays:


  1. 第一种方法:通过取决于什么语言要演奏的setLocale方法来创建TTS的实例,并改变语言。使用setlocale语言之间切换不幸的是按钮被点击后,这对反应的影响时间消耗

  2. 第二种方法:创建各自的语言中每个TTS的两个实例。不幸发生延迟此处以及并有第一溶液之间没有差异。

能否请您帮忙解决这个恼人的问题?

Can you please help to solve this annoying problem?

推荐答案

看起来是文字转​​语音是如何设计的。猜猜它可以加载只是一个语言数据同一时间,当你要求另一个就必须卸载当前语言数据并加载新的。
我在这里补充问题:
的https://$c$c.google.com/p /安卓/问题/细节?ID = 200974

Looks like it is how TextToSpeech is designed. Guess it could load just one language data same time and when you request another one it have to unload current language data and load new one. I have added the issue here: https://code.google.com/p/android/issues/detail?id=200974

<击>也许谷歌将在未来的解决它。他们做到了!

至于解决方法,现在你可以pre-合成音频文件,然后简单地播放它。 F.G.可以在开始活动时启动一些AsyncTask的和生成的背景声。而当它准备揭示UI按钮允许用户播放。
此外,我发现,文字转语音的东西更好地采用了android投入自己的服务流程:流程属性的服务,以避免在某些设备上的UI冻结时setLanguage加载的语言数据

As workaround for now you can pre-synthesize the audio-file and then simply play back it. F.g. you can start some AsyncTask when starting the Activity and generate the sound on the background. And when it is ready reveal the button on UI to allow user to play it. Also I found that TextToSpeech stuff better to put into own service process using android:process attribute for the Service to avoid freeze of UI on some devices when setLanguage is loading the language data.

更新2016年2月17日:我刚刚从二月15并且没有更多的延误更新文字转语音到3.8.14版本!我使用2种语言阅读不同语言文本一招一式之间再也没有延迟!
由于谷歌和文字转语音团队!你是最棒的!

UPDATE 2016-02-17: I just have updated TextToSpeech to the version 3.8.14 from Feb 15. And no more delays! I'm using 2 languages reading the different language texts one by one and no delay between anymore! Thanks Google and TextToSpeech team! You are the best!

更新2016年2月18日:我已经测试更多的设备,发现问题依然存在,其中的Andr​​oid 4.x版仍然使用旧设备。测试在XOOM采用Android 4.1.2,并搭载Android 4.1.1一些NONAME设备7100。两者仍然有同样的延迟。
不知道这是否与但我注意到,这两个与Android 4.x的Andr​​oid设备都与UtteranceProgressListener的问题。为了使这些设备上,我不得不在utteranceId参数传递到说话()函数工作。
不过,若这个bug已经一去不复返了,而不该参数行之有效的设备。
它是现在工作正常的设备是LG D405采用Android 5.0.2
和它有相同的延迟问题,我最近安装的更新文字转语音之前。

UPDATE 2016-02-18: I have tested more devices and found the problem still exists for older devices where Android 4.x is still used. Tested on XOOM with Android 4.1.2 and some noname device 7100 with Android 4.1.1. Both still have the same delays. Not sure is it related but I noticed that both Android device with Android 4.x have the problem with the UtteranceProgressListener. To make it work on such devices I had to pass the utteranceId parameter into the speak() function. However the device where this bug is gone worked well without this parameter. The device where it is working fine for now is LG d405 with Android 5.0.2 And it had the same delay issue before I install recent TextToSpeech update.

这篇关于安卓的文本到语音的两个实例的工作非常缓慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆