【发布时间】:2015-03-15 11:02:05
【问题描述】:
我在下面使用的代码已经使用了一年多,没有任何问题。谷歌发布了谷歌应用程序的更新,现在当语音识别器被调用时,它几乎立即停止并返回“网络错误”。我从 15 年 1 月 12 日卸载了更新,一切都再次完美。还有人经历过这个吗??我还没有看到任何cmets,所以我可能是唯一受影响的人。请看一下代码并告诉我我可能做错了什么。
sr = SpeechRecognizer.createSpeechRecognizer(this.getApplicationContext());
sr.setRecognitionListener(new listener());
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getClass().getPackage().getName());
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, prefCommandKey.toString());
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, prefLanguage);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 5);
sr.startListening(intent);
奇怪的部分偶尔会出现,它会让我录制一些东西,然后当我进入下一步时,它会在再次启动语音识别器时退出。有什么帮助吗?谢谢。
【问题讨论】:
-
在执行此操作时,您是在代码中的其他任何位置请求音频焦点还是躲避音频?
标签: android speech-recognition text-to-speech voice