Android: How to detect when a user stops talking into the microphone

杀马特。学长 韩版系。学妹 提交于 2019-12-09 11:22:33

问题


I have an Android application that begins recording from the microphone when the application starts. In my current version, the user must press a STOP button to stop recording.

How do I detect that the user has stopped talking and use that to trigger the recorder to stop?

Similar to what is implemented in the Speech Recognition functionality in Android. The user stops talking and then the speech is translated. I have seen other apps that do it, like Talking Tom type apps.

As a side note I would also love to show some type of visual indicating that the microphone is receiving sound. Something to show the sound level coming in.

Any help appreciated.


回答1:


An approach is to use threads on recording and the speech power analyzing process on the recorded bytes, there's a sample code for your reference: http://musicg.googlecode.com/files/musicg_android_demo.zip




回答2:


What are you using to record audio? This may provide some clues:

android.media.MediaRecorder:

  • the constant MEDIA_RECORDER_INFO_MAX_DURATION_REACHED can be used with an onInfoListener.

android.speech.SpeechRecognizer:

  • attach a RecognitionListener and call onEndofSpeech().


来源:https://stackoverflow.com/questions/5247789/android-how-to-detect-when-a-user-stops-talking-into-the-microphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!