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!
Related
I want to make a speech recognizer app which transcribes the user's speech. I do not want any dialog while doing that, so startActivityForResult with recognizerIntent is out of the option. (I know I can get audio if I use this approach)
I am using SpeechRecognizer for that and call startListening to listen user's audio. I am getting results with very good accuracy in onResults.
Now, I also need the audio of user stored in sdcard in my device. For that I have tried both 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, but in vain.
If anyone can throw some light on this, then that would be great.
[Edit]
Guys, this is not a duplicate of record/save audio from voice recognition intent, it's slightly different. The answer you gave is for Google Keep. Keep uses the dialog to get data. I do not need a dialog hanging on the screen.
I have successfully accomplished this with the help of CLOUD SPEECH API.
You can find it's demo by 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.
It uses audio buffer to transcribe data with help of Google Speech API. I have used this buffer to store Audio recording with help of AudioRecorder.
So with this demo we can transcribe user's speech parallely with Audio Recording.
I cant find anything online but how can i use a chrome tab web audio api in an android app so i can play sound during a phone call.
i went to this site but when i play the sound during a phone call the far end doens't here anything. I thought one feature of web audio was that it can play change the sound of someones voice in a phone call, so i thought it had access to the audio phone call stream.
even here the tech says its ready for android but i cant even get hte audio recorder demo to work on android.
While you do (with the user permission) have access to the input of the device you only have access to the main output of the device (internal speakers or headphones). This is represented as the AudioContext.destination. The buffers in a call is (probably) a different output that you simply don't have access to in Web Audio (and that's probably a good thing. Imagine the security issues we'd have if apps were allowed to hijack calls!).
I would like to access my voice (during a phone call) so that I can filter the unwanted noise. I've encountered apps that can record both sides of the call during a live session (no VOIP)
https://www.google.com/url?q=http://www.androidpit.com/en/android/market/apps/app/com.soundmobilesystems.android.recorder/Personal-Call-Voice-Recorder&sa=U&ei=p1bIUYmuFKboiAKx34CoAQ&ved=0CBYQFjAF&client=internal-uds-cse&usg=AFQjCNE9HZmEc9hNokPMGIFl0VWJMQv3nw
using Voice_Call, Voice_Uplink or Voice_Downlink, they were able to access the in call audio stream, my problem is now, how can i send my (noise filtered) voice back into the call audio stream.
This has been asked several times before (e.g. here, here and here).
Nothing has changed in respect to this, so it's still not possible for Android apps to write into the uplink (or downlink) of a voice call, and probably won't be in the future.
When it comes to noise suppression for voice calls, most (if not all) OEMs have both uplink and downlink noise suppression on their phones which has been carefully tuned for each product in a controlled environment to meet all necessary acoustic requirements. Sometimes you can toggle or tweak these settings in the Settings menu or through the Phone application's UI.
I am writing an application that runs as a background service recording and analyzing audio recorded from the microphone. When my app is running I can't use other apps that use the microphone (e.g. phone, voice recording, etc...).
My question is - Is there a way to share the microphone stream in Android? Maybe by using the NDK? If not, is it possible to receive an indication (e.g. a BroadcastIntent) that another app is requiring the microphone?
Simple Answer would be "NO" , This is just because Audio Recording Method is synchronized. So Two or more resources can not attempt it simantenously. Doing so might sometime force close the applicatio.
I know this is old, but you may be able to kill/reactivate the microphone connection every few minutes to simulate a shared microphone resource. This is an untested hack...
Essentially:
Set a timer to disconnect from the mic every few minutes
Hopefully, if another app is trying to collect mic data, it can
while blocking other apps from collecting at the same time
Attempt to reconnect and test for data
if the other app has the mic and is blocking data then you can
try to reconnect at some time in the future.
I haven't tested this but I need a solution too so I'll post code if it works.
Recording audio/video, while other applications are running , is possible. I've done it in Sony Xperia Z1, continuously recorded videos and calls with a downloaded screen recorder. However, I do believe that this was a glitch of some sort, as it stopped being able to record after some time (about 2 months)and started showing an error which says that the microphone is being used by another application...
Yes, with Android 10 you can.
Before Android 10 the input audio stream could only be captured by one app at a time
I am new to android. I am trying to lock the device using voice . I recorded the voice with media recorder but now How I lock the phone with this voice ? plz any idea.
Interesting, but u need to probably do more work that mere speculation here. A quick brainstorm:
your app must be a device admin to be able to lock the device
to lock the device, this device admin could be "told" via a broadcast event routed to it
the "lock device" event can be raised by another / same app if it can capture from the mic,
probably forward this to a server that can do speech-to-text (Google has something), then yo app tries to recognize whether the response text matches the "lock" criteria. If it does, then broadcast the "lock" event.
This heavily depends on how good the speech-to-text part is done, otherwise, explore along those lines.