我正在开发一个应用程序来转录通话过程中的对话,它在三星盖乐世S5和S6 (能够在麦克风和免提电话上转录语音)工作良好。然而,当在S7 (两者都使用Android7)上测试时,它无法工作(只能从麦克风中转录语音)。下面是我用来启动语音转文本的代码
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上的硬件统计数据,但我搞不清楚
发布于 2019-09-17 21:19:47
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, "voice.recognition.test")https://stackoverflow.com/questions/57597140
复制相似问题