我正在开发一个应用程序来转录通话过程中的电话,它在三星galaxy s5和s6(能够转录麦克风和免提电话的语音)工作良好。然而,当在s7上进行测试(都使用android 7)时,它不起作用(只能从mic转录语音)。下面是我用来开始语音到文本的代码

    speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this.getApplicationContext());
    speechRecognizer.setRecognitionListener(this);

    recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en-US");
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS, 20000);
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS, 20000);
    speechRecognizer.startListening(recognizerIntent);

这是硬件问题还是我的代码中遗漏了任何配置选项?我确实比较了s5 s6和s7的硬件统计数据,但我想不通

最佳答案

intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, "voice.recognition.test")

10-08 03:11