Я использую следующий код для запуска распознавания речи в Android:
PackageManager pm = getPackageManager();
List<ResolveInfo> 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);
Это прекрасно работает. Однако, похоже, он не принимает голосовые данные от гарнитуры bluetooth, которая сопряжена и подключена с использованием профиля "Телефонный звук".
Я могу использовать приложение под названием SoundAbout, чтобы принудительно включить "Media Audio" в "Bluetooth (моно) (SCO)". С этим набором приложений мое распознавание голоса теперь работает с моим речевым входом с моей гарнитуры.
Как я могу использовать RecognizerIntent и получать речевой ввод от гарнитуры bluetooth?
Я вижу, что на уровне API 16 появляется новое действие ACTION_VOICE_SEARCH_HANDS_FREE. Это слишком ново для меня, но это решит мою проблему?
Нужно ли мне гасить в AudioManager (например, я предполагаю, что SoundAbout делает) для маршрутизации аудиовхода с помощью setBluetoothScoOn() или startBluetoothSco()?