我正在使用第三方云服务在Android上进行语音识别,它可以与Android API SpeechRecognizer很好地配合使用。以下是代码:
Intent recognizerIntent =
new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
// accept partial results if they come
recognizerIntent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);
//need to have a calling package for it to work
if (!recognizerIntent.hasExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE)) {
recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, "com.example.speechrecognition");
}
recognizer = SpeechRecognizer.createSpeechRecognizer(context);
recognizer.setRecognitionListener(this);
recognizer.startListening(recognizerIntent);
同时,我希望记录不同音频设置的音频,例如频率、通道、音频格式等。然后我将持续分析这个音频缓冲区。为此,我使用AudioRecord。只有当关闭语音识别时,这才有效。
如果同时录制音频和语音识别,则会发生错误。
E/AudioRecord: start() status -38
如何实现这种功能,我也尝试使用本地音频-SLRecordItf,但是没有成功。