【发布时间】:2017-02-07 11:13:20
【问题描述】:
我正在使用 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,也不行。
【问题讨论】:
-
由于android策略,同时只有一个应用程序可以访问麦克风api。
-
有没有机会做到这一点?
-
也许你应该找到一些可以处理声音字节而不是麦克风的语音识别器。
-
这可能是由于同时使用了手机的音频输入硬件。语音识别器和录音机都使用相同的硬件进行收听。如果一个当前正在使用硬件,另一个可能无法使用它。
标签: android speech-recognition audio-recording