Is it possible to share audio input (Microphone) stream in Android? - android

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

Related

Android Bluetooth Delay

I am developing an app which requires that I play a song in two phones via Bluetooth. At the time I am able to do so, but with a delay in playing sounds.
The way I am doing this is by sending a string over bluetooth which when sent tells the app to play a song and when received do the same.
Of course there will be a delay because of the bluetooth connection but the main problem is that this delay is not constant at all so I am having trouble in synchronize both well..
Any suggestions will be really appreciated :)

VLC on Android streaming

I am using Wowza stream content to an Android device using VLC.
When the connection between the Android device running VLC is lost, the screen freezes as expected, and the video is restored with the connection is restored. However, the second time the connection is lost, VLC stops the stream, and I would need to select the stream path for it to begin playing again.
I set the cache to 25 seconds, but see nothing on number of attempts, or time to wait before giving up on the stream. The ideal behaviour is to always wait until the connection is resorted without intervention, even if the time between attempts grows the longer the network connection is lost.
Where can I set VLC on android to always wait for a stream, and never give up?
This is a known issue .you experience a deadlock in libvlc. that happens when you try to play and stop nearly simultaneously or something like that. the problem is that the input thread does not finish.this is due to race
conditions after calls to vlc_object_alive().
this patch can help you :
https://github.com/rom1v/vlc-udp-deadlock/

Chrome web audio api - how to play sound in a phone call

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!).

Phone-to-phone communication on Android

I am building an app that converts text messages to speech and sends them to the destination. At the other end, the speech is converted back to text messages.
I imagine it may be easy with Twilio but I don't want to use internet connection. A simple call should be enough to transmit the data.
Any idea on how I should proceed with this?
I don't think this is really possible to do, your tasks would be pretty heavy ...
TTS- that's no problem android has a library for that TTS and recording it
Make a phone call and monitor state Make phone call monitor state
Send your synthesized message - can't quite find a way to do this, seems problematic sending recorded messages over phone network it has been suggested that you could play the recording over the speaker and the microphone might pick that up, seems like a good way to introduce even more errors into the system though
On the other end something must answer - Answering a phone call
Record incoming call - this seems to be highly problematic on a non-rooted phone Recording incoming calls? or Recording incoming calls
Take the recording and do reliable STT without the benefit of a server back end, also highly problematic since the translation errors even on high end server apps are sometimes quite comical
So without a rooted phone with a custom rom I don't think all of this is possible even if you could overcome the poor quality of a double translation TTS -> STT
Twillo seems to be about making calls over the net vs. the phones digital network not about sending text (in essence) over a phone connection
Seems like a whole lot of extra work just to avoid an internet connection charge (of about 2 seconds and few bytes!)

sharing audio input on 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!

Categories

Resources