speechRecognizer -listener在onResults(捆绑结果)多数设备中给予捆绑包[empty_parcel] 11

发布于 2025-01-21 08:33:26 字数 1342 浏览 6 评论 0原文

我正在使用

speech = SpeechRecognizer.createSpeechRecognizer(getReactApplicationContext().getApplicationContext());
            speech.setRecognitionListener(VoiceAppModule.this);
            recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
            recognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS, 100000000);
            recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en");
            recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, "com.languageacademy");
            recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
            recognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 3);
            recognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS, 10000);
            recognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS, 10000);

上述代码进行语音识别。

@Override 公共空白onResults(捆绑结果){

结果结果是给出 bundle [empty_parcel] 结果。

arrayList匹配= results.getStringArrayList(secementRecognizer.Results_Recognition);

我在许多设备中尝试过,它主要在具有Android 11以及一些三星手机的MI手机中给出了问题。

I am Using

speech = SpeechRecognizer.createSpeechRecognizer(getReactApplicationContext().getApplicationContext());
            speech.setRecognitionListener(VoiceAppModule.this);
            recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
            recognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS, 100000000);
            recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en");
            recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, "com.languageacademy");
            recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
            recognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 3);
            recognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS, 10000);
            recognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS, 10000);

The Above code for Speech recognition.

@Override
public void onResults(Bundle results) {

in about On Result the result is giving Bundle[EMPTY_PARCEL] in Result.

ArrayList matches = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);

I tried in many of the Devices it is mainly giving problem in MI phones having android 11 and also some samsung phones.

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

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

发布评论

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

评论(3

弱骨蛰伏 2025-01-28 08:33:26

同样的问题,此错误像几天前一样开始发生。

我认为此错误的原因是“ Google”的新版本
app( https://play.google.com/商店/应用程序/详细信息?

如果您单击Uinstall“ Google”
应用程序,它将返回到较旧的版本,而OnResult回调将正常工作。

解决了我的问题的解决方案正在删除:
extair_speech_input_minimum_length_millis extras

请注意,非常罕见,您想在意图中指定此值。通常,仅当它也被用作Extra_Segented_session的值以启用分段会话模式时,才应指定它。还请注意,某些值可能会导致不希望或意外的结果 - 明智地使用!

https://developer.android.com/reference/android/speech/recognizerintent#extra_segmented_session

Same problem here, this bug started to occur like few days ago.

I think the reason of this bug is the new version of "Google"
app (https://play.google.com/store/apps/details?id=com.google.android.googlequicksearchbox), as SpeechRecognizer uses this app to recognize voice.

If you click uinstall "Google"
app, it will roll back to older version and onResult callback will work fine.

Solution that fixed my problem was removing:
EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS extras

Note that it is extremely rare you'd want to specify this value in an intent. Generally, it should be specified only when it is also used as the value for EXTRA_SEGMENTED_SESSION to enable segmented session mode. Note also that certain values may cause undesired or unexpected results - use judiciously!

https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_SEGMENTED_SESSION

瑾兮 2025-01-28 08:33:26

I confirm the answer gave by Seba, only in my case I have to remove also

RecognizerIntent.EXTRA_MAX_RESULTS RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS RecognizerIntent.EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS

and affected also Huawei and Samsung devices with Android 9, so it seems这些问题每天都在传播。

I confirm the answer gave by Seba, only in my case I have to remove also

RecognizerIntent.EXTRA_MAX_RESULTS RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS RecognizerIntent.EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS

and affected also Huawei and Samsung devices with Android 9, so it seems the issues's propagating day by day.

热情消退 2025-01-28 08:33:26

我也面临同一问题。删除以下意图后,它开始工作。

putextra(ensenizerIntent.extra_speech_input_complete_silence_silence_length_millis,3000)

先前的意图:

 recognizerIntent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH).apply {
      putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en")
      putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, packageName)
      putExtra(
        RecognizerIntent.EXTRA_LANGUAGE_MODEL,
        RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH
      )
      putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS, 3000)
      putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1)
    }

修改意图:

recognizerIntent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH).apply {
  putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en")
  putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, packageName)
  putExtra(
    RecognizerIntent.EXTRA_LANGUAGE_MODEL,
    RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH
  )
  putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1)
}

I was also facing the same issue. After removing the below intent it started working.

putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS, 3000)

Previous intent :

 recognizerIntent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH).apply {
      putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en")
      putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, packageName)
      putExtra(
        RecognizerIntent.EXTRA_LANGUAGE_MODEL,
        RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH
      )
      putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS, 3000)
      putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1)
    }

Modified Intent:

recognizerIntent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH).apply {
  putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en")
  putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, packageName)
  putExtra(
    RecognizerIntent.EXTRA_LANGUAGE_MODEL,
    RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH
  )
  putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1)
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文