Android SpeechRecognizer ERROR_NETWORK

时间:2015-01-19 13:49:57

标签: android google-play speech-recognition speech-to-text

我目前正在处理使用SpeechRecognizer的应用,但我一直收到错误2 ERROR_NETWORK。 查看日志时,我可以看到以下内容:

01-19 14:38:00.080   1291-13267/? W/JavaNetConnection﹕ Failed to get connection status.
java.io.FileNotFoundException: https://www.google.com/m/voice-search/down?pair=760f1fd2-4b87-48b8-bf6f-76cfc79d8ae8
        at kxb.getInputStream(PG:228)
        at kxa.getInputStream(PG:210)
        at kxc.getInputStream(PG:25)
        at cla.Gj(PG:256)
        at dzz.Gj(PG:26)
        at cla.Gi(PG:240)
        at cla.disconnect(PG:132)
        at clb.b(PG:110)
        at clb.a(PG:66)
        at dzb.a(PG:197)
        at cqj.HS(PG:529)
        at cqi.run(PG:314)

我使用SpeechRecognizer的方式是

private void setupVoiceRecorder() {
    mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);
    mSpeechRecognizer.setRecognitionListener(new Listener());
}

然后我就这样开始录音:

private void startVoiceRecording(String languageKey) {
    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
                      RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);

    String packageName = getPackageName();
    intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, packageName);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, languageKey);
    intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1);
    mSpeechRecognizer.startListening(intent);
}

事情是它有时会起作用。但在大多数情况下,它失败了...... 关于我做错了什么想法?

0 个答案:

没有答案