Skip to content

Commit 131d0ce

Browse files
committed
docs: expose EXTRA_ENABLE_FORMATTING & add note about android support
1 parent 07ed46c commit 131d0ce

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ ExpoSpeechRecognitionModule.start({
247247
// [Default: false] Prevent device from sending audio over the network. Only enabled if the device supports it.
248248
requiresOnDeviceRecognition: false,
249249
// [Default: false] Include punctuation in the recognition results. This applies to full stops and commas.
250+
// Not supported on Android 12 and below. On Android 13+, only supported when on-device recognition is enabled.
250251
addsPunctuation: false,
251252
// [Default: undefined] Short custom phrases that are unique to your app.
252253
contextualStrings: ["Carlsen", "Nepomniachtchi", "Praggnanandhaa"],

example/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"react": "18.2.0",
2424
"react-dom": "18.2.0",
2525
"react-native": "0.74.5",
26-
"react-native-web": "~0.19.10",
27-
"react-native-reanimated": "~3.10.1"
26+
"react-native-reanimated": "~3.10.1",
27+
"react-native-web": "~0.19.10"
2828
},
2929
"devDependencies": {
3030
"@babel/core": "^7.24.0",

src/ExpoSpeechRecognitionModule.types.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ export type ExpoSpeechRecognitionOptions = {
171171
/**
172172
* [Default: false] Include punctuation in the recognition results. This applies to full stops and commas.
173173
*
174-
* On Android, this configures [`EXTRA_ENABLE_FORMATTING`](https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_ENABLE_FORMATTING) in the recognizer intent (API level 33+).
174+
* On Android, this configures [`EXTRA_ENABLE_FORMATTING`](https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_ENABLE_FORMATTING) in the recognizer intent (Android 13+, API level 33+).
175+
*
176+
* Note for Android: This feature is only verified to work on Android 13+ with on-device speech recognition enabled (i.e. enabling `requiresOnDeviceRecognition` or using the `com.google.android.as` service package)
175177
*
176178
* On iOS, this configures [`SFSpeechRecognitionRequest.addsPunctuation`](https://developer.apple.com/documentation/speech/sfspeechrecognitionrequest/3930023-addspunctuation).
177179
*/
@@ -372,6 +374,15 @@ export type AndroidIntentOptions = {
372374
* Depending on the recognizer implementation, this value may have no effect.
373375
*/
374376
EXTRA_ENABLE_LANGUAGE_SWITCH: (typeof RecognizerIntentEnableLanguageSwitch)[keyof typeof RecognizerIntentEnableLanguageSwitch];
377+
/**
378+
* https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_ENABLE_FORMATTING
379+
*
380+
* NOTE: This is also configurable through `addsPunctuation` (which sets `EXTRA_ENABLE_FORMATTING` to "quality")
381+
*
382+
* [API level 33] Optional string to enable text formatting (e.g. unspoken punctuation (examples: question mark, comma, period, etc.), capitalization, etc.) and specify the optimization strategy. If set, the partial and final result texts will be formatted. Each result list will contain two hypotheses in the order of 1) formatted text 2) raw text.
383+
*
384+
*/
385+
EXTRA_ENABLE_FORMATTING: "latency" | "quality";
375386
/**
376387
* https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_HIDE_PARTIAL_TRAILING_PUNCTUATION
377388
*

0 commit comments

Comments
 (0)