开发者

sharing audio input on Android

开发者 https://www.devze.com 2023-01-31 07:43 出处:网络
I am doing some preparation research for an Android phone app that would involve voice search or speech recognition while the user is simultaneously en开发者_JAVA百科gaged in a phone call. I\'m findin

I am doing some preparation research for an Android phone app that would involve voice search or speech recognition while the user is simultaneously en开发者_JAVA百科gaged in a phone call. I'm finding that when I am in the middle of a call and attempt to invoke voice search or a similar action that would take input from the microphone I get an "audio error" message. Does the phone app take exclusive control over the microphone input of the phone such that other apps cannot get access to audio input?


In answer to the direct question, Yes. The phone app takes full exclusive control over the microphone input. This is the same with all apps that use the microphone. Only one app can have access to the microphone at a time. HOWEVER, in hope for your app, you can access the voice uplink stream, which is the same thing (it is what is spoken into the mic and uploaded to the service towers), plus it won't interfere with the call at all. You can do it like this:

MediaRecorder mRecorder = new MediaRecorder(); mRecorder.setAudioSource(MediaRecorder.AudioSource.VOICE_UPLINK);

You will have to add the permissions to record to the Manifest and such, but that's about it for that. Luckily the speech recognition stuff is all built in, so you should be able to find out how to do that fairly easily by just poking around a bit on here or Googleing it. Unfortunately, I myself don't have anything to offer you in that field however. Hope this helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号