Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing the Android RecognizerIntent with a bluetooth headset
    text
    copied!<p>I use the following code to launch speech recognition in Android:</p> <pre><code>PackageManager pm = getPackageManager(); List&lt;ResolveInfo&gt; activities = pm.queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0); if (activities.size() == 0) { displayWarning("This device does not support speech recognition"); return; } Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE); </code></pre> <p>This works fine. However, it doesn't seem to accept voice input from a bluetooth headset that is paired and connected using the "Phone audio" profile.</p> <p>I can use an app called <a href="https://play.google.com/store/apps/details?id=com.woodslink.android.wiredheadphoneroutingfix" rel="noreferrer">SoundAbout</a> to force "Media Audio" to "Bluetooth (mono) (SCO)". With this app set, my voice recognition now works taking my speech input from my headset.</p> <p>How can I use RecognizerIntent and get speech input from a bluetooth headset?</p> <p>I see in API level 16 there is a new intent action <a href="http://developer.android.com/reference/android/speech/RecognizerIntent.html#ACTION_VOICE_SEARCH_HANDS_FREE" rel="noreferrer">ACTION_VOICE_SEARCH_HANDS_FREE</a>. This is too new for me to use, but would this solve my problem?</p> <p>Do I have to muck around in the AudioManager (like I assume SoundAbout is doing) to route the audio input using <a href="http://developer.android.com/reference/android/media/AudioManager.html#setBluetoothScoOn%28boolean%29" rel="noreferrer">setBluetoothScoOn</a>() or <a href="http://developer.android.com/reference/android/media/AudioManager.html#startBluetoothSco%28%29" rel="noreferrer">startBluetoothSco</a>()? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload