How to switch microphone between Bluetooth earpiece and mobile phone? - java

I try to write a Speech2speech translation app and the translation service is from Microsoft speech service api.
There are two function I want:
One of them is that earpiece receives my voice(English), and then, the speaker of mobile phone plays the translated result(Japanese).
The other one is that built-in microphone of mobile phone receives someone's voice(Japanese), and then, the earpiece plays the translated result(English).
I try some combinations of these settings, but I still find the correct combination to achieve my goal.
AudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION)
AudioManager.stopBluetoothSco()
AudioManager.setBluetoothScoOn();
AudioManager.setSpeakerphoneOn();
And all of "AudioManager.setMode"
For function 1:
mAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
mAudioManager.stopBluetoothSco();
mAudioManager.setBluetoothScoOn(false);
mAudioManager.setSpeakerphoneOn(true);
For function 2:
mAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
mAudioManager.setMicrophoneMute(false);
mAudioManager.startBluetoothSco();
mAudioManager.setBluetoothScoOn(true);
mAudioManager.setSpeakerphoneOn(false);
Above code is what I use right now.
But both of them receive the voice from built-in microphone of mobile phone and play the translated result on earpiece.
Is there any simple or clear way to select the input or output of audio?

Related

remote media stream not available, webrtc and kurento media stream

I have started with https://doc-kurento.readthedocs.io/en/6.13.2/tutorials/java/tutorial-groupcall.html
Currently, in UI i give user option to decide whether they want only audio or audio+video call. Based on the selection, the constraints for getUserMedia() are passed and this works fine if all the user select same kind of call type.
But, say user 1 select only audio and user 2 selects audio+video, then user 1 receives audio from user 2 while on user 2 end, the html video element keeps loading.
Findings:
I believe this is SDP offer issue, since offer from user 1 and respective SDP answer from user2 does not contain m=video since user 1 has opted only for audio call (this works fine)
But, offer from user 2 and respective SDP answer from user 1 does contain m=video.
So, what i want is, user 2 receive audio from 1, even though user 2 selected video call.
Your stream has both Audio and Video tracks. for some reason, html video element doesn't play audio in this case because it's not getting video and just audio (because the other guy disabled the video). There's two ways you fix it.
Fixing by manipulating mediaStream.
You can create a mediaStream that has only audio tracks when the user has disabled the video.
const audioStream = new MediaStream();
mediaStream.addTrack(originalStream.getAudioTracks()[0]);
/* display audioStream in video element*/
Fixing by generating sdp to right mediaConstraints
You can generate the sdp by passing mediaConstraints as {audio:true,video:false} when creating WebRtcPeer using kurentoUtils. That'll just get you the audio track.

Android detect speech recognition language

I am working in an application that recognizes user voice and convert it to decimal , it should detect two languages Arabic , and English.
This my Intent to detect user input:
Intent voicerecogize = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
voicerecogize.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "ar-eg");
startActivityForResult(voicerecogize, RESULT_SPEECH);
I need a method to detect which language user speaks either Arabic or English.
You can not listen for 2 languages at the same time with the current Android Speech Recognition API.
You can only listen for one language at a time.
What you could do is record the user input and then push the recorded input to one speech recognizer for English and one for Arabic, but there is no out-of-the-box API to do this.

convert serial port sounds into microphone input

Assume that there are two computers, two headsets with microphone.One PC (A) is having a user and one PC (B) does not have a user, but it is having a software which makes automated calls. Now B making a call to A and Playing something like "Please say 'DONE' if you already in your seat." Then A response for it by saying "DONE". Now here what I want to do is, When that person response it comes to the speaker as incoming audio.I want to make that same incoming voice as the input for microphone. because my voice recognition software only convert microphone inputs to words.
If someone understand my problem please reply/advice me. Upto now I used a windows function in my sound card (Listen to the device), but as the solution its not worthy since that voice is not clear and voice volume not enough for voice recognition.
Thank you.

Device Tokens are different from one device to another device

Hi i am little bit confusion about Device Token so can any one guide me. I am using following code for getting DeviceToken.
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)dt
{
}
The above code is working fine and it is showing DeviceToken data ,that is 64 length data.
My doubt is Device Token is different from one device to another device.
If once we got DeviceToken using one device that same DeviceToken can use for another Device.
Of course the device token is different for each device. It identifies a unique device. It's like a phone number (actually it's even more unique than a phone number, since multiple phones can have the same phone number). If it was the same, how would the Apple Push Notifications server know to which device to send your notification?

Detect input from another phone?

I am creating an app and would like to add a feature. What I want to do is be able to detect some sort of input code from another phone. For example, if phone A has my app and is talking to someone on phone B, if the person on phone B inputs a predetermined code, the app on phone A will do something.
Phone B ---> input code ---> app on phone A takes action
The app on phone A will be running in the background when it receives the input.
If this is not possible, then I have already found ways to do this with a text message using a BroadcastReceiver.
Here is a DTMF recognizer: http://code.google.com/p/dtmf-decoder/
No idea how ripe the project is. But it may be a source of inspiration for you :).

Categories

Resources