1

I want use wired headset as audio source for SpeechRecognizer. I read questions like Android - Getting audio to play through earpiece and Android - Play audio from earpiece. Finally i come to:

public void holdAudioStream(){
    audioManager.setMode(AudioManager.STREAM_VOICE_CALL);
    audioManager.setSpeakerphoneOn(false);
}

public void releaseAudioStream(){
    audioManager.setMode(AudioManager.MODE_NORMAL);
    audioManager.setSpeakerphoneOn(true);
}

but this don't work. Problem solved for Bluetooth headset by using

audioManager.setMode(AudioManager.STREAM_VOICE_CALL);
audioManager.startBluetoothSco();
audioManager.setBluetoothScoOn(true);

I'm not found alternative audioManager.startBluetoothSco(); for wired headset. Is there a possibility combination SpeechRecognizer and wired headset?

Community
  • 1
  • 1

1 Answers1

0

I am also having the same requirement. In my application as well I am using Google Speech recognition but want to take input from headset mic. But SpeechRecognizer does not have any api for it but MediaRecoder in android do have that api. So solution is that record voice using MediaRecorder and send that file to Google Speech to text server and get the response. You can refer to below links :

Android app - https://github.com/katchsvartanian/voiceRecognition

Documentation - https://github.com/gillesdemey/google-speech-v2

I tried to run android app but its giving me some runtime exception.

Please also let me know if you could find solution for it.

Harry
  • 422
  • 3
  • 11