Android 中带有录音的 SpeechRecognizer

SpeechRecognizer with Audio recording in Android

我想制作一个转录用户语音的语音识别器应用程序。 我不想在执行此操作时出现任何对话框,因此 startActivityForResult with recognizerIntent 不在选项之列。 (我知道如果我使用这种方法我可以获得音频)

我正在使用 SpeechRecognizer for that and call startListening to listen user's audio. I am getting results with very good accuracy in onResults

现在,我还需要将用户的音频存储在我设备的 sdcard 中。为此,我都尝试了 MediaRecorder as well as AudioRecord, but not getting any success. I am always getting Network Error in onError of RecognitionListener. I can't find anyway on how to overcome this issue. I have also tried to get data from onBufferReceived,但没有成功。

如果有人能对此有所了解,那就太好了。

[编辑]

伙计们,这不是 record/save audio from voice recognition intent 的副本,它略有不同。您给出的答案是 Google 保留。 Keep 使用对话框获取数据。我不需要一个对话框挂在屏幕上。

我在 CLOUD SPEECH API 的帮助下成功完成了这项工作。 您可以通过 google speech.

找到它的演示

The API recognizes over 80 languages and variants, to support your global user base. You can transcribe the text of users dictating to an application’s microphone, enable command-and-control through voice, or transcribe audio files, among many other use cases. Recognize audio uploaded in the request, and integrate with your audio storage on Google Cloud Storage, by using the same technology Google uses to power its own products.

它使用音频缓冲区在 Google 语音 API 的帮助下转录数据。在 AudioRecorder 的帮助下,我已经使用这个缓冲区来存储录音。

所以通过这个演示,我们可以在录音的同时转录用户的语音。