I query the supported languages for the speech service with the RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS
action:
val intent = Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS)
packageManager.queryBroadcastReceivers(intent, 0).map { resolveInfo ->
sendOrderedBroadcast(
intent.apply {
component = ComponentName(resolveInfo.activityInfo.applicationInfo.packageName, resolveInfo.activityInfo.name)
},
null,
object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
val extras = getResultExtras(true)
val supportedLanguages = extras.getStringArrayList(RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES)
// supportedLanguages is empty on Android 13 for all services
}
},
null, Activity.RESULT_OK, null, null
)
}
This works well on Android 12 and below. However the list is empty on Android 13. I'm using the Google Speech Services/Google App.
After some digging it seems the broadcast receiver which returned the languages before is simply disabled. From the decompiled sources of the Google App:
values/bools.xml
<bool name="speech_services_enabled">true</bool>
values-v33/bools.xml
<bool name="speech_services_enabled">false</bool>
Is there any other way to get the list of supported languages?
Edit: I've also tried to query the SpeechRecognizer
directly:
val speechRecognizer = SpeechRecognizer.createSpeechRecognizer(context)
speechRecognizer.checkRecognitionSupport(
Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH),
...
)
But this always returns error 14 (ERROR_CANNOT_CHECK_SUPPORT
)