5

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)

dipdipdip
  • 2,326
  • 1
  • 21
  • 31
  • 3
    Note that all of the Speech Services and related API implementations were [removed in Android 13](https://developer.android.com/about/versions/13/behavior-changes-all#speech-service). – ianhanniballake Nov 02 '22 at 20:47
  • Thanks for the hint! I've also tried to query the `SpeechRecognizer` directly and edited my question. But this also doesn't give me any results. – dipdipdip Nov 03 '22 at 09:21

0 Answers0