AndroidPocketSphinx:系统怎么知道是调用了哪些识别? [英] AndroidPocketSphinx: How does the system know which recognizer is invoked?

查看:213
本文介绍了AndroidPocketSphinx:系统怎么知道是调用了哪些识别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我学习的源泉code <一个href=\"https://github.com/mistrykajal16/AndroidPocketSphinx/blob/master/src/ca/ilanguage/labs/pocketsphinx/ui/TestPocketSphinxAndAndroidASR.java\"相对=nofollow> TestPocketSphinxAndAndroidASR.java ,这是不那么清楚,我的第一件事就是系统是如何知道的其中识别(即谷歌或CMUSphinx)来调用。

I am studying the source code of TestPocketSphinxAndAndroidASR.java and the first thing that is not so clear to me is how the system knows which recognizer (i.e. Google or CMUSphinx) to invoke.

我可以看到,表彰活动是由启动:

I can see that the recognition activity is started by:

  Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
  intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
  startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);

但据我知道这code是不特定要么GVR(谷歌语音搜索)或CMUSphinx。

but as far as I know this code isn't specific to either GVR (Google Voice Search) or CMUSphinx.

那么,如何知道Android版的的识别开始?

So how does Android know which recognizer to start?

在的onCreate()早些时候,有一个AndroidPocketSphinx设置的引用:

Earlier in onCreate(), there is a reference to an AndroidPocketSphinx setting:

mUsePocektSphinxASR = prefs.getBoolean(PreferenceConstants.PREFERENCE_USE_POCKETSPHINX_ASR, false);

但搜索上的全部的项目收益率只有它使用这个布尔显示不同的吐司下面的语句:

but searching on the entire project yields only the next statement which uses this boolean to display a different Toast:

if (mUsePocektSphinxASR){
  Toast.makeText(TestPocketSphinxAndAndroidASR.this, "Would be working offline, using PocketSphinx Speech recognizer...", Toast.LENGTH_LONG).show();
}
else{
  Toast.makeText(TestPocketSphinxAndAndroidASR.this, "Working online, Using system speech recognizer (Google speech recognition server)... ", Toast.LENGTH_LONG).show();
}

所以我不知道系统是如何知道(基于preference)来启动该识别器。

So I don't understand how the system knows (based on that preference) which recognizer to start.

如何知道Android版的识别开始?

How does Android know which recognizer to start?

推荐答案

您的问题不是特定于Android上的语音识别。这只是一个关于如何解决意图在Android上发生问题。

Your question is not specific to speech recognition on Android. It's just a question about how intent resolution happens on Android.

您code构建一个意图,并将其传递到 startActivityForResult 这将启动相应的活动。如果有几个相应的活动,然后Android的弹出一个对话框选择,或者选择自动根据用户设置的默认值。如果如谷歌语音搜索会自动选择,那么你可以尝试明确默认适用于它在应用程序管理器。说明三星Galaxy S II运行Android 4.1:

Your code constructs an Intent and passes it to startActivityForResult which starts the corresponding activity. If there are several corresponding activities then Android pops up a choice dialog, or chooses automatically based on a user-set default. If e.g. Google Voice Search is automatically chosen then you can try to apply "clear defaults" to it in the Application Manager. Instructions for Samsung Galaxy S II running Android 4.1:

Settings -> Application manager -> All -> Google Search (v2.7.9...)
    -> Launch by default -> Clear defaults

在谷歌搜索默认启动设置现在应显示无默认设置。现在,如果你推出一个支持活动 ACTION_RECOGNIZE_SPEECH ,如果除了谷歌搜索你安装了一个或多个应用程序,支持此意图,那么你会看到对话框。如果测试你需要支持的应用程序 ACTION_RECOGNIZE_SPEECH 然后再安装Kõnele 。 (我不知道,你实际引用基于CMU狮身人面像code实现此目的的类型,但我没仔细检查。)

The Google Search "Launch by default" setting should now show "No defaults set". Now, if you launch an activity that supports ACTION_RECOGNIZE_SPEECH and if in addition to Google Search you have one or more apps installed that support this intent, then you'll see the dialog. If for testing you need an app that supports ACTION_RECOGNIZE_SPEECH then install Kõnele. (I'm not sure that the CMU Sphinx based code that you reference actually implements this intent type, but I didn't check carefully.)

这篇关于AndroidPocketSphinx:系统怎么知道是调用了哪些识别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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