我正在使用Android上的第三方 Cloud 服务进行语音识别,并且它适用于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);
同时,我想用不同的音频设置录制音频,如频率, Channels ,音频格式等 . 然后我会不断分析这个音频缓冲区 . 我使用AudioRecord来达到目的 . 这只适用于我关闭语音识别 .
如果我同时录制音频和语音识别,则会发生错误 .
E/AudioRecord: start() status -38
如何实现这种功能,我也试过原生音频 - SLRecordItf,也行不通 .
1 回答
正如评论所述,一次只允许/可能一个麦克风访问 .
对于SpeechRecognizer,附件RecognitionListener的回调为onBufferReceived(byte[] buffer)但不幸的是,谷歌_2516444非常令人沮丧 .
您唯一的选择是使用外部服务,该服务赢得了Cloud Speech API,Cloud Speech API具有Android example .