在Android上共享音频输入 [英] sharing audio input on Android

查看:64
本文介绍了在Android上共享音频输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Android手机应用程序做一些准备研究,该应用程序涉及在用户同时打个电话的同时进行语音搜索或语音识别.我发现当我在通话过程中并尝试调用语音搜索或类似的操作(需要从麦克风输入)时,会收到音频错误"消息.电话应用是否可以独占控制电话的麦克风输入,以使其他应用无法访问音频输入?

I am doing some preparation research for an Android phone app that would involve voice search or speech recognition while the user is simultaneously engaged 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!

这篇关于在Android上共享音频输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆