android语音识别API.System始终识别默认语言

时间:2014-08-26 10:01:40

标签: java android speech-recognition

以下是我的代码的外观。

//loc will be either "ru-RU" or "en-US"
speechRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, loc);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, loc); 
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_ONLY_RETURN_LANGUAGE_PREFERENCE, loc);

问题是,当我使用不同手机的程序时效果很好。但是用我的手机它总是选择默认语言。很少有人只是混合识别语言。就像一半的结果是用另一种语言的另一半语言。 我不知道它是系统的原因还是代码本身? 此外,它在我的手机上运行良好。可以是某些设置的原因吗? 我该如何克服并修复它?我需要知道如果他们遇到同样的问题,通知用户如何修复它

How can I use voice recognition with other languages android

SpeechRecognizer with Google Search version 3.6.14.1337016 can't recognize other voice language except default

2 个答案:

答案 0 :(得分:5)

首先,使用 SpeechRecognizer 时存在问题 在这种情况下,唯一的解决方案是删除谷歌搜索,因为它与谷歌搜索更新相关。这样做我们将删除所有更新。这适用于我自己的设备

但在我看来,实际上,小更新不应该改变api行为。我希望有解决这个问题的程序化方法,或者会有新的更新来修复它

这是未记录的程序化解决方案:

  

intent.putExtra(“android.speech.extra.EXTRA_ADDITIONAL_LANGUAGES”,new   串[] {});

artetxem's answer

其他解决方案只是呼叫活动以进行识别。这样就可以看到google的对话框活动,但不会出现语言问题。

我打开的问题issue

artetxem issue

在谷歌搜索中打开了问题

答案 1 :(得分:0)

嗨@VSL我也面临同样的问题设置语言印地语而不是英语,但语音识别器总是采用我的Android操作系统默认语言,这是英语。但是下面的代码解决了我的问题

     Intent recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
     recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "hi");
     recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, InteractionActivity.this.getPackageName());  
     recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
     recognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 3);
     speech.startListening(recognizerIntent);