TTS - CHECK_VOICE_DATA_FAIL - 检查发动机availlable [英] TTS - CHECK_VOICE_DATA_FAIL - Check engine availlable

查看:217
本文介绍了TTS - CHECK_VOICE_DATA_FAIL - 检查发动机availlable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

林具有TTS引擎一个奇怪的问题,我无法弄清楚,为什么/哪里是我的错误。搜索了几个小时一个解决方案,但没有任何mentionable结果。

当我使用这个<一href="http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/TextToSpeechActivity.html"相对=nofollow> API演示code 一切运作良好,我可以听到所有已安装的语言的声音。

但是当我通过这种方法我得到CHECK_VOICE_DATA_FAIL作为返回code定制TTS引擎(这是我需要的所有necessay语言,谷歌的标准是不够的)。

我在想什么吗?我如何检查TTS引擎的availabillity? 我知道,这并不一定是code问题,但是,对于其他Programms这似乎是工作。

我从 SVOX网站安装其他应用程序和这些似乎工作我所有的设备,而code以下失败。

作为一个例子, TalkToMeClassic 的正在检查的availlability发动机和其工作正常。

做了什么不同吗?

下面是我的excact code(这是文章的复印件):

  @覆盖
公共无效的onCreate(包savedInstanceState){
    super.onCreate(savedInstanceState);
    意图checkIntent =新意图();
    checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
    startActivityForResult(checkIntent,0x99);
}

@覆盖
保护无效onActivityResult(INT申请code,INT结果code,意图数据){
    如果(要求code == 0x99){
        如果(结果code == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS){
            //成功,创造了TTS实例
            MTTS =新TextToSpeech(这一点,这一点);
        } 其他 {
            Log.e(TTS,缺少数据:+结果code);
            //丢失的数据,安装
            意图installIntent =新意图();
            installIntent.setAction(
                TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
            startActivity(installIntent);
        }
    }
}
 

解决方案

不幸的是,初始化TextToSpeech 可靠是复杂的,异步的,和混乱。

为什么你的code检查0x99 ???

您其实并不需要使用 ACTION_CHECK_TTS_DATA意图来检查可用的语言,使用 TextToSpeech.isLanguageAvailable 代替。

所以,<一个href="https://github.com/gast-lib/gast-lib/blob/master/library/src/root/gast/speech/tts/TextToSpeechInitializer.java"相对=nofollow>这里是一个辅助类该做的。在code在该库将帮助您开始。它可以是那么容易,因为只是延长<一href="https://github.com/gast-lib/gast-lib/blob/master/library/src/root/gast/speech/SpeechRecognizingAndSpeakingActivity.java"相对=nofollow>这个类。

或者您可以阅读有关href="http://rads.stackoverflow.com/amzn/click/1118183487" rel="nofollow">这本书

Im having a odd Problem with the TTS engine and I cant figure out why / where is my mistake. Is searched for hours for a solution but without any mentionable result.

When I am using this API Demo code everything is working well and I can hear for all installed languages the voice.

But when I am checking by this method I am getting CHECK_VOICE_DATA_FAIL as a return code for custom TTS engines (which I need for all necessay languages, Standard google is not enough).

What am I missing here? How can I check the availabillity of the TTS engines? I know that this is not necessarily a code problem but, for other Programms this seems to be working.

I installed some other apps from the SVox Website and these seem to work on all my devices, while the code below fails.

As an example, TalkToMeClassic is checking the availlability of the Engine and it is working.

What is done different here?

Here is my excact code (which is a copy of the article):

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent checkIntent = new Intent();
    checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
    startActivityForResult(checkIntent, 0x99);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 0x99) {
        if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
            // success, create the TTS instance
            mTts = new TextToSpeech(this, this);
        } else {
            Log.e("TTS","Missing Data:" + resultCode );
            // missing data, install it
            Intent installIntent = new Intent();
            installIntent.setAction(
                TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
            startActivity(installIntent);
        }
    }
}

解决方案

Unfortunately, initializing TextToSpeech reliably is complicated, asynchronous, and confusing.

Why is your code checking 0x99???

You actually don't need to use the ACTION_CHECK_TTS_DATA Intent to check for language availability, use TextToSpeech.isLanguageAvailable instead.

So here is a helper class that does it. The code in that library will help you get started. It can be as easy as just extending this class.

Or you can read about the details in this book.

这篇关于TTS - CHECK_VOICE_DATA_FAIL - 检查发动机availlable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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