You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -334,7 +335,7 @@ Events are largely based on the [Web Speech API](https://developer.mozilla.org/e
334
335
|`speechend`| Fired when speech recognized by the speech recognition service has stopped being detected. | Not supported yet on iOS |
335
336
|`start`| Speech recognition has started | Use this event to indicate to the user when to speak. |
336
337
|`volumechange`| Fired when the input volume changes. | Returns a value between -2 and 10 indicating the volume of the input audio. Consider anything below 0 to be inaudible. |
337
-
|`languagedetection`| Called when the language detection (and switching) results are available. | Android 14+ only. Enabled with `EXTRA_ENABLE_LANGUAGE_DETECTION` in the `androidIntent` option when starting. Also can be called multiple times by enabling `EXTRA_ENABLE_LANGUAGE_SWITCH`.|
338
+
|`languagedetection`| Called when the language detection (and switching) results are available. | Android 14+ only with `com.google.android.as`. Enabled with `EXTRA_ENABLE_LANGUAGE_DETECTION` in the `androidIntent` option when starting. Also can be called multiple times by enabling `EXTRA_ENABLE_LANGUAGE_SWITCH`. |
338
339
339
340
## Handling Errors
340
341
@@ -697,6 +698,39 @@ You may notice that after saying short syllables, words, letters, or numbers (e.
697
698
- For both platforms, you also may want to consider using on-device recognition. On Android this seems to work well for single-word prompts.
698
699
- Alternatively, you may want to consider recording the recognized audio and sending it to an external service for further processing. See [Persisting Audio Recordings](#persisting-audio-recordings) for more information. Note that some services (such as the Google Speech API) may require an audio file with a duration of at least 3 seconds.
699
700
701
+
## Language Detection
702
+
703
+
> [!NOTE]
704
+
> This feature is currently only available on Android 14+ using the `com.google.android.as` service package.
705
+
706
+
You can use the `languagedetection` event to get the detected language and confidence level. This feature has a few requirements:
707
+
708
+
- Android 14+ only.
709
+
- The `com.google.android.as` (on-device recognition) service package must be selected. This seems to be the only service that supports language detection as of writing this.
710
+
- You must enable `EXTRA_ENABLE_LANGUAGE_DETECTION` in the `androidIntentOptions` when starting the recognition.
711
+
- Optional: You can enable `EXTRA_ENABLE_LANGUAGE_SWITCH` to allow the user to switch languages, however **keep in mind that you need the language model to be downloaded for this to work**. Refer to [androidTriggerOfflineModelDownload()](#androidtriggerofflinemodeldownload) to download a model, and [getSupportedLocales()](#getsupportedlocales) to get the list of downloaded on-device locales.
Users on Android devices will first need to download the offline model for the locale they want to use in order to use on-device speech recognition (i.e. the `requiresOnDeviceRecognition` setting in the `start` options).
0 commit comments