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?