expo-speech-recognition 0.2.24 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +93 -65
- package/android/src/main/java/expo/modules/speechrecognition/ExpoSpeechRecognitionModule.kt +2 -0
- package/android/src/main/java/expo/modules/speechrecognition/ExpoSpeechService.kt +37 -3
- package/build/ExpoSpeechRecognitionModule.d.ts +0 -2
- package/build/ExpoSpeechRecognitionModule.d.ts.map +1 -1
- package/build/ExpoSpeechRecognitionModule.js +6 -18
- package/build/ExpoSpeechRecognitionModule.js.map +1 -1
- package/build/ExpoSpeechRecognitionModule.types.d.ts +34 -3
- package/build/ExpoSpeechRecognitionModule.types.d.ts.map +1 -1
- package/build/ExpoSpeechRecognitionModule.types.js.map +1 -1
- package/build/ExpoSpeechRecognitionModule.web.d.ts +43 -10
- package/build/ExpoSpeechRecognitionModule.web.d.ts.map +1 -1
- package/build/ExpoSpeechRecognitionModule.web.js +109 -105
- package/build/ExpoSpeechRecognitionModule.web.js.map +1 -1
- package/build/ExpoWebSpeechRecognition.d.ts.map +1 -1
- package/build/ExpoWebSpeechRecognition.js +4 -4
- package/build/ExpoWebSpeechRecognition.js.map +1 -1
- package/build/index.d.ts +3 -4
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -3
- package/build/index.js.map +1 -1
- package/build/useSpeechRecognitionEvent.d.ts +2 -2
- package/build/useSpeechRecognitionEvent.d.ts.map +1 -1
- package/build/useSpeechRecognitionEvent.js +5 -9
- package/build/useSpeechRecognitionEvent.js.map +1 -1
- package/ios/ExpoSpeechRecognitionModule.swift +2 -0
- package/package.json +9 -4
- package/src/ExpoSpeechRecognitionModule.ts +6 -32
- package/src/ExpoSpeechRecognitionModule.types.ts +38 -3
- package/src/ExpoSpeechRecognitionModule.web.ts +172 -145
- package/src/ExpoWebSpeechRecognition.ts +5 -8
- package/src/index.ts +22 -33
- package/src/useSpeechRecognition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ACvD,kGAAkG;IACzF,OAAO,CAAU;IAC1B,iGAAiG;IACjG,MAAM,CAAS;IACf,+FAA+F;IAC/F,IAAI,CAAC,KAAa;QAChB,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,CAAC,MAAM,CAAC,QAAQ,CAAC;QACf,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC/C,CAAC;IAED,YACE,OAAgB,EAChB,YAAgD;QAEhD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7C,IAAI,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;CACF;AAED,MAAM,gCAAgC;IACpC,UAAU,CAAS;IACnB,UAAU,CAAS;IAEnB,YAAY,UAAkB,EAAE,UAAkB;QAChD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF","sourcesContent":["import type { Subscription } from \"expo-modules-core\";\n\n// Import the native module. On web, it will be resolved to ExpoSpeechRecognition.web.ts\n// and on native platforms to ExpoSpeechRecognition.ts\nimport {\n ExpoSpeechRecognitionModule,\n ExpoSpeechRecognitionModuleEmitter,\n} from \"./ExpoSpeechRecognitionModule\";\nimport type {\n ExpoSpeechRecognitionNativeEventMap,\n ExpoSpeechRecognitionOptions,\n} from \"./ExpoSpeechRecognitionModule.types\";\n\nconst noop = () => {};\n\nconst createEventData = (target: EventTarget) => ({\n AT_TARGET: 2 as const,\n bubbles: false,\n BUBBLING_PHASE: 3 as const,\n cancelable: false,\n CAPTURING_PHASE: 1 as const,\n composed: false,\n composedPath: () => [],\n currentTarget: target,\n defaultPrevented: false,\n eventPhase: 0,\n isTrusted: true,\n NONE: 0 as const,\n preventDefault: noop,\n resultIndex: 0,\n stopImmediatePropagation: noop,\n stopPropagation: noop,\n target,\n timeStamp: 0,\n type: \"\",\n cancelBubble: false,\n returnValue: false,\n srcElement: null,\n initEvent: noop,\n});\n\ntype NativeEventAndListener<\n TEventName extends keyof ExpoSpeechRecognitionNativeEventMap,\n> = {\n /** Event name to listen for on native side */\n eventName: TEventName;\n nativeListener: (\n nativeEvent: ExpoSpeechRecognitionNativeEventMap[TEventName],\n ) => void;\n};\n\nfunction stubEvent<K extends keyof SpeechRecognitionEventMap>(\n eventName: K,\n instance: ExpoWebSpeechRecognition,\n listener: (this: SpeechRecognition, ev: Event) => unknown,\n): NativeEventAndListener<K> {\n return {\n eventName,\n nativeListener: (nativeEvent) =>\n listener.call(instance, createEventData(instance)),\n };\n}\n\n/**\n * Transforms the native listener payloads to web-compatible shapes\n */\nconst WebListenerTransformers: {\n [K in keyof SpeechRecognitionEventMap]?: (\n instance: ExpoWebSpeechRecognition,\n listener: (\n this: SpeechRecognition,\n ev: SpeechRecognitionEventMap[K],\n ) => unknown,\n ) => NativeEventAndListener<K>;\n} = {\n audiostart: (instance, listener) => {\n return {\n eventName: \"audiostart\",\n nativeListener(nativeEvent) {\n listener.call(instance, {\n ...createEventData(instance),\n uri: nativeEvent.uri,\n });\n },\n };\n },\n audioend: (instance, listener) => {\n return {\n eventName: \"audioend\",\n nativeListener(nativeEvent) {\n listener.call(instance, {\n ...createEventData(instance),\n uri: nativeEvent.uri,\n });\n },\n };\n },\n nomatch: (instance, listener) => {\n // @ts-ignore\n return stubEvent(\"nomatch\", instance, listener);\n },\n end: (instance, listener) => {\n return stubEvent(\"end\", instance, listener);\n },\n start: (instance, listener) => {\n return {\n eventName: \"start\",\n nativeListener() {\n listener.call(instance, createEventData(instance));\n },\n };\n },\n error: (instance, listener) => {\n return {\n eventName: \"error\",\n nativeListener: (\n nativeEvent: ExpoSpeechRecognitionNativeEventMap[\"error\"],\n ) => {\n const clientEvent: SpeechRecognitionEventMap[\"error\"] = {\n ...createEventData(instance),\n // TODO: handle custom ios error codes\n error: nativeEvent.error as SpeechRecognitionErrorCode,\n message: nativeEvent.message,\n };\n listener.call(instance, clientEvent);\n },\n };\n },\n result: (instance, listener) => {\n return {\n eventName: \"result\",\n nativeListener: (\n nativeEvent: ExpoSpeechRecognitionNativeEventMap[\"result\"],\n ) => {\n if (!instance.interimResults && !nativeEvent.isFinal) {\n return;\n }\n const alternatives = nativeEvent.results.map(\n (result) =>\n new ExpoSpeechRecognitionAlternative(\n result.confidence,\n result.transcript,\n ),\n );\n const clientEvent: SpeechRecognitionEventMap[\"result\"] = {\n ...createEventData(instance),\n results: new ExpoSpeechRecognitionResultList([\n new ExpoSpeechRecognitionResult(nativeEvent.isFinal, alternatives),\n ]),\n };\n listener.call(instance, clientEvent);\n },\n };\n },\n};\n\ntype SpeechListener<K extends keyof SpeechRecognitionEventMap> = (\n this: SpeechRecognition,\n ev: SpeechRecognitionEventMap[K],\n) => any;\n\n/** A compatibility wrapper that implements the web SpeechRecognition API for React Native. */\nexport class ExpoWebSpeechRecognition implements SpeechRecognition {\n lang = \"en-US\";\n grammars: SpeechGrammarList = new ExpoWebSpeechGrammarList();\n maxAlternatives = 1;\n continuous = false;\n\n #interimResults = false;\n\n get interimResults(): boolean {\n return this.#interimResults;\n }\n\n set interimResults(interimResults: boolean) {\n this.#interimResults = interimResults;\n // Subscribe to native\n }\n\n // Extended properties\n\n /** [EXTENDED, default: undefined] An array of strings that will be used to provide context to the speech recognition engine. */\n contextualStrings?: string[] = undefined;\n /** [EXTENDED, default: false] Whether the speech recognition engine should require the device to be on when the recognition starts. */\n requiresOnDeviceRecognition = false;\n /** [EXTENDED, default: false] Whether the speech recognition engine should add punctuation to the transcription. */\n addsPunctuation = false;\n /** [EXTENDED, default: undefined] Android-specific options to pass to the recognizer. */\n androidIntentOptions: ExpoSpeechRecognitionOptions[\"androidIntentOptions\"];\n /** [EXTENDED, default: undefined] Audio source options to pass to the recognizer. */\n audioSource?: ExpoSpeechRecognitionOptions[\"audioSource\"];\n /** [EXTENDED, default: undefined] Audio recording options to pass to the recognizer. */\n recordingOptions?: ExpoSpeechRecognitionOptions[\"recordingOptions\"];\n /** [EXTENDED, default: \"android.speech.action.RECOGNIZE_SPEECH\"] The kind of intent action */\n androidIntent?: ExpoSpeechRecognitionOptions[\"androidIntent\"] = undefined;\n /** [EXTENDED, default: undefined] The hint for the speech recognition task. */\n iosTaskHint?: ExpoSpeechRecognitionOptions[\"iosTaskHint\"] = undefined;\n /** [EXTENDED, default: undefined] The audio session category and options to use. */\n iosCategory?: ExpoSpeechRecognitionOptions[\"iosCategory\"] = undefined;\n /**\n * [EXTENDED, default: undefined]\n *\n * The package name of the speech recognition service to use.\n * If not provided, the default service will be used.\n *\n * Obtain the supported packages by running `ExpoSpeechRecognitionModule.getSpeechRecognitionServices()`\n *\n * e.g. com.samsung.android.bixby.agent\"\n */\n androidRecognitionServicePackage: ExpoSpeechRecognitionOptions[\"androidRecognitionServicePackage\"];\n\n // keyed by listener function\n #subscriptionMap: Map<SpeechListener<any>, Subscription[]> = new Map();\n\n start() {\n ExpoSpeechRecognitionModule.requestPermissionsAsync().then(() => {\n // A result doesn't matter,\n // the module will emit an error if permissions are not granted\n ExpoSpeechRecognitionModule.start({\n lang: this.lang,\n interimResults: this.interimResults,\n maxAlternatives: this.maxAlternatives,\n contextualStrings: this.contextualStrings,\n requiresOnDeviceRecognition: this.requiresOnDeviceRecognition,\n addsPunctuation: this.addsPunctuation,\n continuous: this.continuous,\n recordingOptions: this.recordingOptions,\n androidIntentOptions: this.androidIntentOptions,\n androidRecognitionServicePackage: this.androidRecognitionServicePackage,\n audioSource: this.audioSource,\n androidIntent: this.androidIntent,\n iosTaskHint: this.iosTaskHint,\n iosCategory: this.iosCategory,\n });\n });\n }\n stop = ExpoSpeechRecognitionModule.stop;\n abort = ExpoSpeechRecognitionModule.abort;\n\n #onstart: SpeechListener<\"start\"> | null = null;\n set onstart(listener: SpeechListener<\"start\"> | null) {\n this._setListeners(\"start\", listener, this.#onstart);\n this.#onstart = listener;\n }\n /** Fired when the speech recognition starts. */\n get onstart() {\n return this.#onstart;\n }\n\n #onend: SpeechListener<\"end\"> | null = null;\n set onend(listener: SpeechListener<\"end\"> | null) {\n this._setListeners(\n \"end\",\n (ev) => {\n listener?.call(this, ev);\n },\n this.#onend,\n );\n this.#onend = listener;\n }\n /** Fired when the speech recognition service has disconnected. */\n get onend() {\n return this.#onend;\n }\n\n #onerror: SpeechListener<\"error\"> | null = null;\n set onerror(listener: SpeechListener<\"error\"> | null) {\n this._setListeners(\"error\", listener, this.#onerror);\n this.#onerror = listener;\n }\n /** Fired when the speech recognition service encounters an error. */\n get onerror() {\n return this.#onerror;\n }\n\n _setListeners<K extends keyof SpeechRecognitionEventMap>(\n key: K,\n listenerFn: SpeechListener<K> | null,\n existingListener: SpeechListener<K> | null,\n ) {\n if (existingListener) {\n this.removeEventListener(key, existingListener);\n }\n if (listenerFn) {\n this.addEventListener(key, listenerFn);\n }\n }\n\n #onresult: SpeechListener<\"result\"> | null = null;\n set onresult(listener: SpeechListener<\"result\"> | null) {\n this._setListeners(\"result\", listener, this.#onresult);\n this.#onresult = listener;\n }\n /** Fired when the speech recognition service returns a result —\n * a word or phrase has been positively recognized and this has been communicated back to the app. */\n get onresult() {\n return this.#onresult;\n }\n\n #onnomatch: SpeechListener<\"nomatch\"> | null = null;\n set onnomatch(listener: SpeechListener<\"nomatch\"> | null) {\n this._setListeners(\"nomatch\", listener, this.#onnomatch);\n this.#onnomatch = listener;\n }\n /** Fired when the speech recognition service returns a final result with no significant recognition. */\n get onnomatch() {\n return this.#onnomatch;\n }\n\n #onspeechstart: SpeechListener<\"speechstart\"> | null = null;\n set onspeechstart(listener: SpeechListener<\"speechstart\"> | null) {\n this._setListeners(\"speechstart\", listener, this.#onspeechstart);\n this.#onspeechstart = listener;\n }\n /** Fired when the speech recognition service returns a final result with no significant recognition. */\n get onspeechstart() {\n return this.#onspeechstart;\n }\n\n #onspeechend: SpeechListener<\"speechend\"> | null = null;\n set onspeechend(listener: SpeechListener<\"speechend\"> | null) {\n this._setListeners(\"speechend\", listener, this.#onspeechend);\n this.#onspeechend = listener;\n }\n /** Fired when the speech recognition service returns a final result with no significant recognition. */\n get onspeechend() {\n return this.#onspeechend;\n }\n\n #onaudiostart: SpeechListener<\"audiostart\"> | null = null;\n set onaudiostart(listener: SpeechListener<\"audiostart\"> | null) {\n this._setListeners(\"audiostart\", listener, this.#onaudiostart);\n this.#onaudiostart = listener;\n }\n /** Fired when the user agent has started to capture audio. */\n get onaudiostart() {\n return this.#onaudiostart;\n }\n\n #onaudioend: SpeechListener<\"audioend\"> | null = null;\n set onaudioend(listener: SpeechListener<\"audioend\"> | null) {\n this._setListeners(\"audioend\", listener, this.#onaudioend);\n this.#onaudioend = listener;\n }\n /** Fired when the user agent has finished capturing audio. */\n get onaudioend() {\n return this.#onaudioend;\n }\n\n /** [TODO] */\n onsoundend: ((this: SpeechRecognition, ev: Event) => any) | null = null;\n /** [TODO] */\n onsoundstart: ((this: SpeechRecognition, ev: Event) => any) | null = null;\n\n addEventListener<K extends keyof SpeechRecognitionEventMap>(\n type: K,\n listener: SpeechListener<K>,\n options?: boolean | AddEventListenerOptions,\n ): void {\n const once = typeof options === \"object\" && options.once;\n\n // If the user opts in to only listening once,\n // wrap the listener in a function that removes the listener\n const wrappedListener = once\n ? (((ev) => {\n listener.call(this, ev);\n // remove the listeners from the map\n for (const sub of this.#subscriptionMap.get(listener) ?? []) {\n sub.remove();\n }\n this.#subscriptionMap.delete(listener);\n }) as SpeechListener<K>)\n : listener;\n\n // Enhance the native listener with any necessary polyfills\n const enhancedEvent: NativeEventAndListener<K> =\n WebListenerTransformers[type]?.(this, wrappedListener) ??\n stubEvent(\n type,\n this,\n wrappedListener as (this: SpeechRecognition, ev: Event) => unknown,\n );\n\n const subscription = ExpoSpeechRecognitionModuleEmitter.addListener(\n enhancedEvent.eventName,\n enhancedEvent.nativeListener,\n );\n\n // Store the subscriptions so we can remove them later\n // This is keyed by the listener function so we can remove all subscriptions for a given listener\n this.#subscriptionMap.set(listener, [subscription]);\n }\n\n removeEventListener<K extends keyof SpeechRecognitionEventMap>(\n type: K,\n listener: (\n this: SpeechRecognition,\n ev: SpeechRecognitionEventMap[K],\n ) => any,\n options?: boolean | EventListenerOptions | undefined,\n ): void {\n const subscriptions = this.#subscriptionMap.get(listener);\n if (subscriptions) {\n for (const subscription of subscriptions) {\n subscription.remove();\n }\n this.#subscriptionMap.delete(listener);\n }\n }\n\n dispatchEvent(event: Event): boolean {\n throw new Error(\"Method not implemented.\");\n }\n}\n\n/**\n * This class is just a polyfill and does nothing on Android/iOS\n */\nexport class ExpoWebSpeechGrammarList implements SpeechGrammarList {\n get length() {\n return this.#grammars.length;\n }\n #grammars: ExpoWebSpeechGrammar[] = [];\n [index: number]: SpeechGrammar; // Indexer property\n\n addFromURI(src: string, weight?: number | undefined): void {\n // todo\n }\n\n item(index: number): ExpoWebSpeechGrammar {\n return this.#grammars[index];\n }\n\n addFromString = (grammar: string, weight?: number) => {\n // TODO: parse grammar to html entities (data:application/xml,....)\n this.#grammars.push(new ExpoWebSpeechGrammar(grammar, weight));\n // Set key on this object for compatibility with web SpeechGrammarList API\n this[this.length - 1] = this.#grammars[this.length - 1];\n };\n}\n\nexport class ExpoWebSpeechGrammar implements SpeechGrammar {\n src = \"\";\n weight = 1;\n\n constructor(src: string, weight?: number) {\n this.src = src;\n this.weight = weight ?? 1;\n }\n}\n\nclass ExpoSpeechRecognitionResultList implements SpeechRecognitionResultList {\n #results: ExpoSpeechRecognitionResult[] = [];\n\n [Symbol.iterator](): IterableIterator<ExpoSpeechRecognitionResult> {\n return this.#results[Symbol.iterator]();\n }\n length: number;\n item(index: number): SpeechRecognitionResult {\n return this.#results[index];\n }\n [index: number]: SpeechRecognitionResult;\n\n constructor(results: ExpoSpeechRecognitionResult[]) {\n this.#results = results;\n this.length = results.length;\n for (let i = 0; i < this.#results.length; i++) {\n this[i] = this.#results[i];\n }\n }\n}\n\nclass ExpoSpeechRecognitionResult implements SpeechRecognitionResult {\n #alternatives: ExpoSpeechRecognitionAlternative[] = [];\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SpeechRecognitionResult/isFinal) */\n readonly isFinal: boolean;\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SpeechRecognitionResult/length) */\n length: number;\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SpeechRecognitionResult/item) */\n item(index: number): SpeechRecognitionAlternative {\n return this.#alternatives[index];\n }\n [index: number]: SpeechRecognitionAlternative;\n [Symbol.iterator](): IterableIterator<SpeechRecognitionAlternative> {\n return this.#alternatives[Symbol.iterator]();\n }\n\n constructor(\n isFinal: boolean,\n alternatives: ExpoSpeechRecognitionAlternative[],\n ) {\n this.isFinal = isFinal;\n this.length = alternatives.length;\n this.#alternatives = alternatives;\n for (let i = 0; i < alternatives.length; i++) {\n this[i] = alternatives[i];\n }\n }\n}\n\nclass ExpoSpeechRecognitionAlternative implements SpeechRecognitionAlternative {\n confidence: number;\n transcript: string;\n\n constructor(confidence: number, transcript: string) {\n this.confidence = confidence;\n this.transcript = transcript;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ExpoWebSpeechRecognition.js","sourceRoot":"","sources":["../src/ExpoWebSpeechRecognition.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAM5E,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAEtB,MAAM,eAAe,GAAG,CAAC,MAAmB,EAAE,EAAE,CAAC,CAAC;IAChD,SAAS,EAAE,CAAU;IACrB,OAAO,EAAE,KAAK;IACd,cAAc,EAAE,CAAU;IAC1B,UAAU,EAAE,KAAK;IACjB,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C,aAAa,GAAG,YAAY,CAAC;QAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7C,IAAI,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;CACF;AAED,MAAM,gCAAgC;IACpC,UAAU,CAAS;IACnB,UAAU,CAAS;IAEnB,YAAY,UAAkB,EAAE,UAAkB;QAChD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF","sourcesContent":["// Import the native module. On web, it will be resolved to ExpoSpeechRecognition.web.ts\n// and on native platforms to ExpoSpeechRecognition.ts\nimport type { EventSubscription } from \"expo-modules-core\";\nimport { ExpoSpeechRecognitionModule } from \"./ExpoSpeechRecognitionModule\";\nimport type {\n ExpoSpeechRecognitionNativeEventMap,\n ExpoSpeechRecognitionOptions,\n} from \"./ExpoSpeechRecognitionModule.types\";\n\nconst noop = () => {};\n\nconst createEventData = (target: EventTarget) => ({\n AT_TARGET: 2 as const,\n bubbles: false,\n BUBBLING_PHASE: 3 as const,\n cancelable: false,\n CAPTURING_PHASE: 1 as const,\n composed: false,\n composedPath: () => [],\n currentTarget: target,\n defaultPrevented: false,\n eventPhase: 0,\n isTrusted: true,\n NONE: 0 as const,\n preventDefault: noop,\n resultIndex: 0,\n stopImmediatePropagation: noop,\n stopPropagation: noop,\n target,\n timeStamp: 0,\n type: \"\",\n cancelBubble: false,\n returnValue: false,\n srcElement: null,\n initEvent: noop,\n});\n\ntype NativeEventAndListener<\n TEventName extends keyof ExpoSpeechRecognitionNativeEventMap,\n> = {\n /** Event name to listen for on native side */\n eventName: TEventName;\n nativeListener: (\n nativeEvent: ExpoSpeechRecognitionNativeEventMap[TEventName],\n ) => void;\n};\n\nfunction stubEvent<K extends keyof SpeechRecognitionEventMap>(\n eventName: K,\n instance: ExpoWebSpeechRecognition,\n listener: (this: SpeechRecognition, ev: Event) => unknown,\n): NativeEventAndListener<K> {\n return {\n eventName,\n nativeListener: (nativeEvent) =>\n listener.call(instance, createEventData(instance)),\n };\n}\n\n/**\n * Transforms the native listener payloads to web-compatible shapes\n */\nconst WebListenerTransformers: {\n [K in keyof SpeechRecognitionEventMap]?: (\n instance: ExpoWebSpeechRecognition,\n listener: (\n this: SpeechRecognition,\n ev: SpeechRecognitionEventMap[K],\n ) => unknown,\n ) => NativeEventAndListener<K>;\n} = {\n audiostart: (instance, listener) => {\n return {\n eventName: \"audiostart\",\n nativeListener(nativeEvent) {\n listener.call(instance, {\n ...createEventData(instance),\n uri: nativeEvent.uri,\n });\n },\n };\n },\n audioend: (instance, listener) => {\n return {\n eventName: \"audioend\",\n nativeListener(nativeEvent) {\n listener.call(instance, {\n ...createEventData(instance),\n uri: nativeEvent.uri,\n });\n },\n };\n },\n nomatch: (instance, listener) => {\n // @ts-ignore\n return stubEvent(\"nomatch\", instance, listener);\n },\n end: (instance, listener) => {\n return stubEvent(\"end\", instance, listener);\n },\n start: (instance, listener) => {\n return {\n eventName: \"start\",\n nativeListener() {\n listener.call(instance, createEventData(instance));\n },\n };\n },\n error: (instance, listener) => {\n return {\n eventName: \"error\",\n nativeListener: (\n nativeEvent: ExpoSpeechRecognitionNativeEventMap[\"error\"],\n ) => {\n const clientEvent: SpeechRecognitionEventMap[\"error\"] = {\n ...createEventData(instance),\n // TODO: handle custom ios error codes\n error: nativeEvent.error as SpeechRecognitionErrorCode,\n message: nativeEvent.message,\n };\n listener.call(instance, clientEvent);\n },\n };\n },\n result: (instance, listener) => {\n return {\n eventName: \"result\",\n nativeListener: (\n nativeEvent: ExpoSpeechRecognitionNativeEventMap[\"result\"],\n ) => {\n if (!instance.interimResults && !nativeEvent.isFinal) {\n return;\n }\n const alternatives = nativeEvent.results.map(\n (result) =>\n new ExpoSpeechRecognitionAlternative(\n result.confidence,\n result.transcript,\n ),\n );\n const clientEvent: SpeechRecognitionEventMap[\"result\"] = {\n ...createEventData(instance),\n results: new ExpoSpeechRecognitionResultList([\n new ExpoSpeechRecognitionResult(nativeEvent.isFinal, alternatives),\n ]),\n };\n listener.call(instance, clientEvent);\n },\n };\n },\n};\n\ntype SpeechListener<K extends keyof SpeechRecognitionEventMap> = (\n this: SpeechRecognition,\n ev: SpeechRecognitionEventMap[K],\n) => any;\n\n/** A compatibility wrapper that implements the web SpeechRecognition API for React Native. */\nexport class ExpoWebSpeechRecognition implements SpeechRecognition {\n lang = \"en-US\";\n grammars: SpeechGrammarList = new ExpoWebSpeechGrammarList();\n maxAlternatives = 1;\n continuous = false;\n\n #interimResults = false;\n\n get interimResults(): boolean {\n return this.#interimResults;\n }\n\n set interimResults(interimResults: boolean) {\n this.#interimResults = interimResults;\n // Subscribe to native\n }\n\n // Extended properties\n\n /** [EXTENDED, default: undefined] An array of strings that will be used to provide context to the speech recognition engine. */\n contextualStrings?: string[] = undefined;\n /** [EXTENDED, default: false] Whether the speech recognition engine should require the device to be on when the recognition starts. */\n requiresOnDeviceRecognition = false;\n /** [EXTENDED, default: false] Whether the speech recognition engine should add punctuation to the transcription. */\n addsPunctuation = false;\n /** [EXTENDED, default: undefined] Android-specific options to pass to the recognizer. */\n androidIntentOptions: ExpoSpeechRecognitionOptions[\"androidIntentOptions\"];\n /** [EXTENDED, default: undefined] Audio source options to pass to the recognizer. */\n audioSource?: ExpoSpeechRecognitionOptions[\"audioSource\"];\n /** [EXTENDED, default: undefined] Audio recording options to pass to the recognizer. */\n recordingOptions?: ExpoSpeechRecognitionOptions[\"recordingOptions\"];\n /** [EXTENDED, default: \"android.speech.action.RECOGNIZE_SPEECH\"] The kind of intent action */\n androidIntent?: ExpoSpeechRecognitionOptions[\"androidIntent\"] = undefined;\n /** [EXTENDED, default: undefined] The hint for the speech recognition task. */\n iosTaskHint?: ExpoSpeechRecognitionOptions[\"iosTaskHint\"] = undefined;\n /** [EXTENDED, default: undefined] The audio session category and options to use. */\n iosCategory?: ExpoSpeechRecognitionOptions[\"iosCategory\"] = undefined;\n /**\n * [EXTENDED, default: undefined]\n *\n * The package name of the speech recognition service to use.\n * If not provided, the default service will be used.\n *\n * Obtain the supported packages by running `ExpoSpeechRecognitionModule.getSpeechRecognitionServices()`\n *\n * e.g. com.samsung.android.bixby.agent\"\n */\n androidRecognitionServicePackage: ExpoSpeechRecognitionOptions[\"androidRecognitionServicePackage\"];\n\n // keyed by listener function\n #subscriptionMap: Map<SpeechListener<any>, EventSubscription[]> = new Map();\n\n start() {\n ExpoSpeechRecognitionModule.requestPermissionsAsync().then(() => {\n // A result doesn't matter,\n // the module will emit an error if permissions are not granted\n ExpoSpeechRecognitionModule.start({\n lang: this.lang,\n interimResults: this.interimResults,\n maxAlternatives: this.maxAlternatives,\n contextualStrings: this.contextualStrings,\n requiresOnDeviceRecognition: this.requiresOnDeviceRecognition,\n addsPunctuation: this.addsPunctuation,\n continuous: this.continuous,\n recordingOptions: this.recordingOptions,\n androidIntentOptions: this.androidIntentOptions,\n androidRecognitionServicePackage: this.androidRecognitionServicePackage,\n audioSource: this.audioSource,\n androidIntent: this.androidIntent,\n iosTaskHint: this.iosTaskHint,\n iosCategory: this.iosCategory,\n });\n });\n }\n stop = ExpoSpeechRecognitionModule.stop;\n abort = ExpoSpeechRecognitionModule.abort;\n\n #onstart: SpeechListener<\"start\"> | null = null;\n set onstart(listener: SpeechListener<\"start\"> | null) {\n this._setListeners(\"start\", listener, this.#onstart);\n this.#onstart = listener;\n }\n /** Fired when the speech recognition starts. */\n get onstart() {\n return this.#onstart;\n }\n\n #onend: SpeechListener<\"end\"> | null = null;\n set onend(listener: SpeechListener<\"end\"> | null) {\n this._setListeners(\n \"end\",\n (ev) => {\n listener?.call(this, ev);\n },\n this.#onend,\n );\n this.#onend = listener;\n }\n /** Fired when the speech recognition service has disconnected. */\n get onend() {\n return this.#onend;\n }\n\n #onerror: SpeechListener<\"error\"> | null = null;\n set onerror(listener: SpeechListener<\"error\"> | null) {\n this._setListeners(\"error\", listener, this.#onerror);\n this.#onerror = listener;\n }\n /** Fired when the speech recognition service encounters an error. */\n get onerror() {\n return this.#onerror;\n }\n\n _setListeners<K extends keyof SpeechRecognitionEventMap>(\n key: K,\n listenerFn: SpeechListener<K> | null,\n existingListener: SpeechListener<K> | null,\n ) {\n if (existingListener) {\n this.removeEventListener(key, existingListener);\n }\n if (listenerFn) {\n this.addEventListener(key, listenerFn);\n }\n }\n\n #onresult: SpeechListener<\"result\"> | null = null;\n set onresult(listener: SpeechListener<\"result\"> | null) {\n this._setListeners(\"result\", listener, this.#onresult);\n this.#onresult = listener;\n }\n /** Fired when the speech recognition service returns a result —\n * a word or phrase has been positively recognized and this has been communicated back to the app. */\n get onresult() {\n return this.#onresult;\n }\n\n #onnomatch: SpeechListener<\"nomatch\"> | null = null;\n set onnomatch(listener: SpeechListener<\"nomatch\"> | null) {\n this._setListeners(\"nomatch\", listener, this.#onnomatch);\n this.#onnomatch = listener;\n }\n /** Fired when the speech recognition service returns a final result with no significant recognition. */\n get onnomatch() {\n return this.#onnomatch;\n }\n\n #onspeechstart: SpeechListener<\"speechstart\"> | null = null;\n set onspeechstart(listener: SpeechListener<\"speechstart\"> | null) {\n this._setListeners(\"speechstart\", listener, this.#onspeechstart);\n this.#onspeechstart = listener;\n }\n /** Fired when the speech recognition service returns a final result with no significant recognition. */\n get onspeechstart() {\n return this.#onspeechstart;\n }\n\n #onspeechend: SpeechListener<\"speechend\"> | null = null;\n set onspeechend(listener: SpeechListener<\"speechend\"> | null) {\n this._setListeners(\"speechend\", listener, this.#onspeechend);\n this.#onspeechend = listener;\n }\n /** Fired when the speech recognition service returns a final result with no significant recognition. */\n get onspeechend() {\n return this.#onspeechend;\n }\n\n #onaudiostart: SpeechListener<\"audiostart\"> | null = null;\n set onaudiostart(listener: SpeechListener<\"audiostart\"> | null) {\n this._setListeners(\"audiostart\", listener, this.#onaudiostart);\n this.#onaudiostart = listener;\n }\n /** Fired when the user agent has started to capture audio. */\n get onaudiostart() {\n return this.#onaudiostart;\n }\n\n #onaudioend: SpeechListener<\"audioend\"> | null = null;\n set onaudioend(listener: SpeechListener<\"audioend\"> | null) {\n this._setListeners(\"audioend\", listener, this.#onaudioend);\n this.#onaudioend = listener;\n }\n /** Fired when the user agent has finished capturing audio. */\n get onaudioend() {\n return this.#onaudioend;\n }\n\n /** [TODO] */\n onsoundend: ((this: SpeechRecognition, ev: Event) => any) | null = null;\n /** [TODO] */\n onsoundstart: ((this: SpeechRecognition, ev: Event) => any) | null = null;\n\n addEventListener<K extends keyof SpeechRecognitionEventMap>(\n type: K,\n listener: SpeechListener<K>,\n options?: boolean | AddEventListenerOptions,\n ): void {\n const once = typeof options === \"object\" && options.once;\n\n // If the user opts in to only listening once,\n // wrap the listener in a function that removes the listener\n const wrappedListener = once\n ? (((ev) => {\n listener.call(this, ev);\n // remove the listeners from the map\n for (const sub of this.#subscriptionMap.get(listener) ?? []) {\n sub.remove();\n }\n this.#subscriptionMap.delete(listener);\n }) as SpeechListener<K>)\n : listener;\n\n // Enhance the native listener with any necessary polyfills\n const enhancedEvent: NativeEventAndListener<K> =\n WebListenerTransformers[type]?.(this, wrappedListener) ??\n stubEvent(\n type,\n this,\n wrappedListener as (this: SpeechRecognition, ev: Event) => unknown,\n );\n\n const subscription = ExpoSpeechRecognitionModule.addListener(\n enhancedEvent.eventName,\n // @ts-expect-error\n enhancedEvent.nativeListener,\n );\n\n // Store the subscriptions so we can remove them later\n // This is keyed by the listener function so we can remove all subscriptions for a given listener\n this.#subscriptionMap.set(listener, [subscription]);\n }\n\n removeEventListener<K extends keyof SpeechRecognitionEventMap>(\n type: K,\n listener: (\n this: SpeechRecognition,\n ev: SpeechRecognitionEventMap[K],\n ) => any,\n options?: boolean | EventListenerOptions | undefined,\n ): void {\n const subscriptions = this.#subscriptionMap.get(listener);\n if (subscriptions) {\n for (const subscription of subscriptions) {\n subscription.remove();\n }\n this.#subscriptionMap.delete(listener);\n }\n }\n\n dispatchEvent(event: Event): boolean {\n throw new Error(\"Method not implemented.\");\n }\n}\n\n/**\n * This class is just a polyfill and does nothing on Android/iOS\n */\nexport class ExpoWebSpeechGrammarList implements SpeechGrammarList {\n get length() {\n return this.#grammars.length;\n }\n #grammars: ExpoWebSpeechGrammar[] = [];\n [index: number]: SpeechGrammar; // Indexer property\n\n addFromURI(src: string, weight?: number | undefined): void {\n // todo\n }\n\n item(index: number): ExpoWebSpeechGrammar {\n return this.#grammars[index];\n }\n\n addFromString = (grammar: string, weight?: number) => {\n // TODO: parse grammar to html entities (data:application/xml,....)\n this.#grammars.push(new ExpoWebSpeechGrammar(grammar, weight));\n // Set key on this object for compatibility with web SpeechGrammarList API\n this[this.length - 1] = this.#grammars[this.length - 1];\n };\n}\n\nexport class ExpoWebSpeechGrammar implements SpeechGrammar {\n src = \"\";\n weight = 1;\n\n constructor(src: string, weight?: number) {\n this.src = src;\n this.weight = weight ?? 1;\n }\n}\n\nclass ExpoSpeechRecognitionResultList implements SpeechRecognitionResultList {\n #results: ExpoSpeechRecognitionResult[] = [];\n\n [Symbol.iterator](): IterableIterator<ExpoSpeechRecognitionResult> {\n return this.#results[Symbol.iterator]();\n }\n length: number;\n item(index: number): SpeechRecognitionResult {\n return this.#results[index];\n }\n [index: number]: SpeechRecognitionResult;\n\n constructor(results: ExpoSpeechRecognitionResult[]) {\n this.#results = results;\n this.length = results.length;\n for (let i = 0; i < this.#results.length; i++) {\n this[i] = this.#results[i];\n }\n }\n}\n\nclass ExpoSpeechRecognitionResult implements SpeechRecognitionResult {\n #alternatives: ExpoSpeechRecognitionAlternative[] = [];\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SpeechRecognitionResult/isFinal) */\n readonly isFinal: boolean;\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SpeechRecognitionResult/length) */\n length: number;\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SpeechRecognitionResult/item) */\n item(index: number): SpeechRecognitionAlternative {\n return this.#alternatives[index];\n }\n [index: number]: SpeechRecognitionAlternative;\n [Symbol.iterator](): IterableIterator<SpeechRecognitionAlternative> {\n return this.#alternatives[Symbol.iterator]();\n }\n\n constructor(\n isFinal: boolean,\n alternatives: ExpoSpeechRecognitionAlternative[],\n ) {\n this.isFinal = isFinal;\n this.length = alternatives.length;\n this.#alternatives = alternatives;\n for (let i = 0; i < alternatives.length; i++) {\n this[i] = alternatives[i];\n }\n }\n}\n\nclass ExpoSpeechRecognitionAlternative implements SpeechRecognitionAlternative {\n confidence: number;\n transcript: string;\n\n constructor(confidence: number, transcript: string) {\n this.confidence = confidence;\n this.transcript = transcript;\n }\n}\n"]}
|
package/build/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { ExpoSpeechRecognitionNativeEventMap } from "./ExpoSpeechRecognitionModule.types";
|
|
2
1
|
export { ExpoWebSpeechRecognition, ExpoWebSpeechGrammar, ExpoWebSpeechGrammarList, } from "./ExpoWebSpeechRecognition";
|
|
3
|
-
export { ExpoSpeechRecognitionModule
|
|
2
|
+
export { ExpoSpeechRecognitionModule } from "./ExpoSpeechRecognitionModule";
|
|
4
3
|
export { useSpeechRecognitionEvent } from "./useSpeechRecognitionEvent";
|
|
5
4
|
export { AVAudioSessionCategory, AVAudioSessionCategoryOptions, AVAudioSessionMode, RecognizerIntentExtraLanguageModel, RecognizerIntentEnableLanguageSwitch, AudioEncodingAndroid, TaskHintIOS, } from "./constants";
|
|
6
5
|
export declare const getSupportedLocales: (options?: {
|
|
@@ -34,6 +33,6 @@ export declare const getDefaultRecognitionService: () => {
|
|
|
34
33
|
export declare const getAssistantService: () => {
|
|
35
34
|
packageName: string;
|
|
36
35
|
};
|
|
37
|
-
export declare const addSpeechRecognitionListener: <
|
|
38
|
-
export {
|
|
36
|
+
export declare const addSpeechRecognitionListener: <EventName extends keyof import("./ExpoSpeechRecognitionModule.types").ExpoSpeechRecognitionNativeEventMap>(eventName: EventName, listener: import("./ExpoSpeechRecognitionModule.types").ExpoSpeechRecognitionNativeEvents[EventName]) => import("expo-modules-core").EventSubscription;
|
|
37
|
+
export type { ExpoSpeechRecognitionOptions, AndroidIntentOptions, ExpoSpeechRecognitionNativeEventMap, AVAudioSessionCategoryOptionsValue, AVAudioSessionModeValue, AVAudioSessionCategoryValue, AudioEncodingAndroidValue, AudioSourceOptions, RecordingOptions, IOSTaskHintValue, SetCategoryOptions, ExpoSpeechRecognitionErrorCode, ExpoSpeechRecognitionErrorEvent, ExpoSpeechRecognitionResultEvent, ExpoSpeechRecognitionResult, ExpoSpeechRecognitionResultSegment, } from "./ExpoSpeechRecognitionModule.types";
|
|
39
38
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAG5E,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAGxE,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,kBAAkB,EAClB,kCAAkC,EAClC,oCAAoC,EACpC,oBAAoB,EACpB,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,eAAO,MAAM,mBAAmB,aAAc;IAC5C,gCAAgC,CAAC,EAAE,MAAM,CAAC;CAC3C;;;EAAmE,CAAC;AAErE,eAAO,MAAM,4BAA4B,gBACiB,CAAC;AAE3D,eAAO,MAAM,2BAA2B,eACiB,CAAC;AAE1D,eAAO,MAAM,iBAAiB,eAAgD,CAAC;AAE/E,eAAO,MAAM,cAAc,qFAA6C,CAAC;AAEzE,eAAO,MAAM,oCAAoC;;;;CACiB,CAAC;AAEnE,eAAO,MAAM,wBAAwB;;UACiB,CAAC;AAEvD,eAAO,MAAM,kCAAkC;;;;;EACiB,CAAC;AAEjE,eAAO,MAAM,sBAAsB,eACiB,CAAC;AAErD,eAAO,MAAM,4BAA4B;;CACiB,CAAC;AAE3D,eAAO,MAAM,mBAAmB;;CACiB,CAAC;AAElD,eAAO,MAAM,4BAA4B,0RACA,CAAC;AAE1C,YAAY,EACV,4BAA4B,EAC5B,oBAAoB,EACpB,mCAAmC,EACnC,kCAAkC,EAClC,uBAAuB,EACvB,2BAA2B,EAC3B,yBAAyB,EACzB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,8BAA8B,EAC9B,+BAA+B,EAC/B,gCAAgC,EAChC,2BAA2B,EAC3B,kCAAkC,GACnC,MAAM,qCAAqC,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ExpoSpeechRecognitionModule
|
|
1
|
+
import { ExpoSpeechRecognitionModule } from "./ExpoSpeechRecognitionModule";
|
|
2
2
|
// Export the SpeechRecognition APIs
|
|
3
3
|
export { ExpoWebSpeechRecognition, ExpoWebSpeechGrammar, ExpoWebSpeechGrammarList, } from "./ExpoWebSpeechRecognition";
|
|
4
4
|
// Native module
|
|
5
|
-
export { ExpoSpeechRecognitionModule
|
|
5
|
+
export { ExpoSpeechRecognitionModule } from "./ExpoSpeechRecognitionModule";
|
|
6
6
|
// Hooks
|
|
7
7
|
export { useSpeechRecognitionEvent } from "./useSpeechRecognitionEvent";
|
|
8
8
|
// Constants
|
|
@@ -18,5 +18,5 @@ export const androidTriggerOfflineModelDownload = ExpoSpeechRecognitionModule.an
|
|
|
18
18
|
export const isRecognitionAvailable = ExpoSpeechRecognitionModule.isRecognitionAvailable;
|
|
19
19
|
export const getDefaultRecognitionService = ExpoSpeechRecognitionModule.getDefaultRecognitionService;
|
|
20
20
|
export const getAssistantService = ExpoSpeechRecognitionModule.getAssistantService;
|
|
21
|
-
export const addSpeechRecognitionListener =
|
|
21
|
+
export const addSpeechRecognitionListener = ExpoSpeechRecognitionModule.addListener;
|
|
22
22
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAE5E,oCAAoC;AACpC,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AAEpC,gBAAgB;AAChB,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAE5E,QAAQ;AACR,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,YAAY;AACZ,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,kBAAkB,EAClB,kCAAkC,EAClC,oCAAoC,EACpC,oBAAoB,EACpB,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAEnC,EAAE,EAAE,CAAC,2BAA2B,CAAC,mBAAmB,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;AAErE,MAAM,CAAC,MAAM,4BAA4B,GACvC,2BAA2B,CAAC,4BAA4B,CAAC;AAE3D,MAAM,CAAC,MAAM,2BAA2B,GACtC,2BAA2B,CAAC,2BAA2B,CAAC;AAE1D,MAAM,CAAC,MAAM,iBAAiB,GAAG,2BAA2B,CAAC,iBAAiB,CAAC;AAE/E,MAAM,CAAC,MAAM,cAAc,GAAG,2BAA2B,CAAC,cAAc,CAAC;AAEzE,MAAM,CAAC,MAAM,oCAAoC,GAC/C,2BAA2B,CAAC,oCAAoC,CAAC;AAEnE,MAAM,CAAC,MAAM,wBAAwB,GACnC,2BAA2B,CAAC,wBAAwB,CAAC;AAEvD,MAAM,CAAC,MAAM,kCAAkC,GAC7C,2BAA2B,CAAC,kCAAkC,CAAC;AAEjE,MAAM,CAAC,MAAM,sBAAsB,GACjC,2BAA2B,CAAC,sBAAsB,CAAC;AAErD,MAAM,CAAC,MAAM,4BAA4B,GACvC,2BAA2B,CAAC,4BAA4B,CAAC;AAE3D,MAAM,CAAC,MAAM,mBAAmB,GAC9B,2BAA2B,CAAC,mBAAmB,CAAC;AAElD,MAAM,CAAC,MAAM,4BAA4B,GACvC,2BAA2B,CAAC,WAAW,CAAC","sourcesContent":["import { ExpoSpeechRecognitionModule } from \"./ExpoSpeechRecognitionModule\";\n\n// Export the SpeechRecognition APIs\nexport {\n ExpoWebSpeechRecognition,\n ExpoWebSpeechGrammar,\n ExpoWebSpeechGrammarList,\n} from \"./ExpoWebSpeechRecognition\";\n\n// Native module\nexport { ExpoSpeechRecognitionModule } from \"./ExpoSpeechRecognitionModule\";\n\n// Hooks\nexport { useSpeechRecognitionEvent } from \"./useSpeechRecognitionEvent\";\n\n// Constants\nexport {\n AVAudioSessionCategory,\n AVAudioSessionCategoryOptions,\n AVAudioSessionMode,\n RecognizerIntentExtraLanguageModel,\n RecognizerIntentEnableLanguageSwitch,\n AudioEncodingAndroid,\n TaskHintIOS,\n} from \"./constants\";\n\nexport const getSupportedLocales = (options?: {\n androidRecognitionServicePackage?: string;\n}) => ExpoSpeechRecognitionModule.getSupportedLocales(options ?? {});\n\nexport const getSpeechRecognitionServices =\n ExpoSpeechRecognitionModule.getSpeechRecognitionServices;\n\nexport const supportsOnDeviceRecognition =\n ExpoSpeechRecognitionModule.supportsOnDeviceRecognition;\n\nexport const supportsRecording = ExpoSpeechRecognitionModule.supportsRecording;\n\nexport const setCategoryIOS = ExpoSpeechRecognitionModule.setCategoryIOS;\n\nexport const getAudioSessionCategoryAndOptionsIOS =\n ExpoSpeechRecognitionModule.getAudioSessionCategoryAndOptionsIOS;\n\nexport const setAudioSessionActiveIOS =\n ExpoSpeechRecognitionModule.setAudioSessionActiveIOS;\n\nexport const androidTriggerOfflineModelDownload =\n ExpoSpeechRecognitionModule.androidTriggerOfflineModelDownload;\n\nexport const isRecognitionAvailable =\n ExpoSpeechRecognitionModule.isRecognitionAvailable;\n\nexport const getDefaultRecognitionService =\n ExpoSpeechRecognitionModule.getDefaultRecognitionService;\n\nexport const getAssistantService =\n ExpoSpeechRecognitionModule.getAssistantService;\n\nexport const addSpeechRecognitionListener =\n ExpoSpeechRecognitionModule.addListener;\n\nexport type {\n ExpoSpeechRecognitionOptions,\n AndroidIntentOptions,\n ExpoSpeechRecognitionNativeEventMap,\n AVAudioSessionCategoryOptionsValue,\n AVAudioSessionModeValue,\n AVAudioSessionCategoryValue,\n AudioEncodingAndroidValue,\n AudioSourceOptions,\n RecordingOptions,\n IOSTaskHintValue,\n SetCategoryOptions,\n ExpoSpeechRecognitionErrorCode,\n ExpoSpeechRecognitionErrorEvent,\n ExpoSpeechRecognitionResultEvent,\n ExpoSpeechRecognitionResult,\n ExpoSpeechRecognitionResultSegment,\n} from \"./ExpoSpeechRecognitionModule.types\";\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ExpoSpeechRecognitionNativeEvents } from "./ExpoSpeechRecognitionModule.types";
|
|
2
2
|
/**
|
|
3
3
|
* This hook allows you to listen to native events emitted by the `ExpoSpeechRecognitionModule`.
|
|
4
4
|
*
|
|
@@ -7,5 +7,5 @@ import type { ExpoSpeechRecognitionNativeEventMap } from "./ExpoSpeechRecognitio
|
|
|
7
7
|
* @param eventName The name of the event to listen to
|
|
8
8
|
* @param listener The listener function to call when the event is emitted
|
|
9
9
|
*/
|
|
10
|
-
export declare function useSpeechRecognitionEvent<K extends keyof
|
|
10
|
+
export declare function useSpeechRecognitionEvent<K extends keyof ExpoSpeechRecognitionNativeEvents>(eventName: K, listener: ExpoSpeechRecognitionNativeEvents[K]): void;
|
|
11
11
|
//# sourceMappingURL=useSpeechRecognitionEvent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSpeechRecognitionEvent.d.ts","sourceRoot":"","sources":["../src/useSpeechRecognitionEvent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSpeechRecognitionEvent.d.ts","sourceRoot":"","sources":["../src/useSpeechRecognitionEvent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAG7F;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,CAAC,SAAS,MAAM,iCAAiC,EACjD,SAAS,EAAE,CAAC,EAAE,QAAQ,EAAE,iCAAiC,CAAC,CAAC,CAAC,QAO7D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ExpoSpeechRecognitionModule } from "./ExpoSpeechRecognitionModule";
|
|
2
|
+
import { useEventListener } from "expo";
|
|
3
3
|
/**
|
|
4
4
|
* This hook allows you to listen to native events emitted by the `ExpoSpeechRecognitionModule`.
|
|
5
5
|
*
|
|
@@ -9,12 +9,8 @@ import { ExpoSpeechRecognitionModuleEmitter } from "./ExpoSpeechRecognitionModul
|
|
|
9
9
|
* @param listener The listener function to call when the event is emitted
|
|
10
10
|
*/
|
|
11
11
|
export function useSpeechRecognitionEvent(eventName, listener) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const handler = listenerRef.current;
|
|
16
|
-
const subscription = ExpoSpeechRecognitionModuleEmitter.addListener(eventName, handler);
|
|
17
|
-
return subscription.remove;
|
|
18
|
-
}, [eventName]);
|
|
12
|
+
return useEventListener(ExpoSpeechRecognitionModule, eventName,
|
|
13
|
+
// @ts-expect-error
|
|
14
|
+
listener);
|
|
19
15
|
}
|
|
20
16
|
//# sourceMappingURL=useSpeechRecognitionEvent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSpeechRecognitionEvent.js","sourceRoot":"","sources":["../src/useSpeechRecognitionEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useSpeechRecognitionEvent.js","sourceRoot":"","sources":["../src/useSpeechRecognitionEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAE5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAExC;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CAEvC,SAAY,EAAE,QAA8C;IAC5D,OAAO,gBAAgB,CACrB,2BAA2B,EAC3B,SAAS;IACT,mBAAmB;IACnB,QAAQ,CACT,CAAC;AACJ,CAAC","sourcesContent":["import { ExpoSpeechRecognitionModule } from \"./ExpoSpeechRecognitionModule\";\nimport type { ExpoSpeechRecognitionNativeEvents } from \"./ExpoSpeechRecognitionModule.types\";\nimport { useEventListener } from \"expo\";\n\n/**\n * This hook allows you to listen to native events emitted by the `ExpoSpeechRecognitionModule`.\n *\n * Note: this is not the same as the `SpeechRecognition` event listener on the web speech API.\n *\n * @param eventName The name of the event to listen to\n * @param listener The listener function to call when the event is emitted\n */\nexport function useSpeechRecognitionEvent<\n K extends keyof ExpoSpeechRecognitionNativeEvents,\n>(eventName: K, listener: ExpoSpeechRecognitionNativeEvents[K]) {\n return useEventListener(\n ExpoSpeechRecognitionModule,\n eventName,\n // @ts-expect-error\n listener,\n );\n}\n"]}
|
|
@@ -94,6 +94,8 @@ public class ExpoSpeechRecognitionModule: Module {
|
|
|
94
94
|
"start",
|
|
95
95
|
// Called when there's results (as a string array, not API compliant)
|
|
96
96
|
"result",
|
|
97
|
+
// Called when the language detection (and switching) results are available.
|
|
98
|
+
"languagedetection",
|
|
97
99
|
// Fired when the input volume changes
|
|
98
100
|
"volumechange"
|
|
99
101
|
)
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-speech-recognition",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Speech Recognition for React Native Expo projects",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
7
10
|
"scripts": {
|
|
8
11
|
"build": "expo-module build",
|
|
9
12
|
"clean": "expo-module clean",
|
|
@@ -14,6 +17,7 @@
|
|
|
14
17
|
"expo-module": "expo-module",
|
|
15
18
|
"open:ios": "open -a \"Xcode\" example/ios",
|
|
16
19
|
"open:android": "open -a \"Android Studio\" example/android",
|
|
20
|
+
"release": "npm run prepare && changeset publish",
|
|
17
21
|
"ts:check": "tsc -p . --noEmit"
|
|
18
22
|
},
|
|
19
23
|
"keywords": [
|
|
@@ -32,10 +36,11 @@
|
|
|
32
36
|
"license": "MIT",
|
|
33
37
|
"homepage": "https://github.com/jamsch/expo-speech-recognition#readme",
|
|
34
38
|
"devDependencies": {
|
|
39
|
+
"@changesets/cli": "^2.27.9",
|
|
35
40
|
"@types/dom-speech-recognition": "^0.0.4",
|
|
36
|
-
"@types/react": "^18.3.
|
|
37
|
-
"expo
|
|
38
|
-
"expo-
|
|
41
|
+
"@types/react": "^18.3.12",
|
|
42
|
+
"expo": "~52.0.0",
|
|
43
|
+
"expo-module-scripts": "^4.0.2"
|
|
39
44
|
},
|
|
40
45
|
"prettier": {
|
|
41
46
|
"trailingComma": "all"
|
|
@@ -1,40 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EventEmitter,
|
|
3
|
-
NativeModulesProxy,
|
|
4
|
-
requireNativeModule,
|
|
5
|
-
} from "expo-modules-core";
|
|
1
|
+
import { requireNativeModule } from "expo";
|
|
6
2
|
|
|
7
3
|
import type { ExpoSpeechRecognitionModuleType } from "./ExpoSpeechRecognitionModule.types";
|
|
8
4
|
|
|
9
5
|
// It loads the native module object from the JSI or falls back to
|
|
10
6
|
// the bridge module (from NativeModulesProxy) if the remote debugger is on.
|
|
11
|
-
const
|
|
7
|
+
export const ExpoSpeechRecognitionModule =
|
|
12
8
|
requireNativeModule<ExpoSpeechRecognitionModuleType>("ExpoSpeechRecognition");
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// Avoid any function bindings when calling the native module
|
|
17
|
-
stop: () => ExpoSpeechRecognitionNativeModule.stop(),
|
|
18
|
-
abort: () => ExpoSpeechRecognitionNativeModule.abort(),
|
|
19
|
-
requestPermissionsAsync: () =>
|
|
20
|
-
ExpoSpeechRecognitionNativeModule.requestPermissionsAsync(),
|
|
21
|
-
getPermissionsAsync: () =>
|
|
22
|
-
ExpoSpeechRecognitionNativeModule.getPermissionsAsync(),
|
|
23
|
-
getStateAsync: () => ExpoSpeechRecognitionNativeModule.getStateAsync(),
|
|
24
|
-
getAssistantService: () =>
|
|
25
|
-
ExpoSpeechRecognitionNativeModule.getAssistantService(),
|
|
26
|
-
getDefaultRecognitionService: () =>
|
|
27
|
-
ExpoSpeechRecognitionNativeModule.getDefaultRecognitionService(),
|
|
28
|
-
getSpeechRecognitionServices: () =>
|
|
29
|
-
ExpoSpeechRecognitionNativeModule.getSpeechRecognitionServices(),
|
|
30
|
-
supportsOnDeviceRecognition: () =>
|
|
31
|
-
ExpoSpeechRecognitionNativeModule.supportsOnDeviceRecognition(),
|
|
32
|
-
supportsRecording: () =>
|
|
33
|
-
ExpoSpeechRecognitionNativeModule.supportsRecording(),
|
|
34
|
-
isRecognitionAvailable: () =>
|
|
35
|
-
ExpoSpeechRecognitionNativeModule.isRecognitionAvailable(),
|
|
36
|
-
};
|
|
10
|
+
const stop = ExpoSpeechRecognitionModule.stop;
|
|
11
|
+
const abort = ExpoSpeechRecognitionModule.abort;
|
|
37
12
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
);
|
|
13
|
+
ExpoSpeechRecognitionModule.abort = () => abort();
|
|
14
|
+
ExpoSpeechRecognitionModule.stop = () => stop();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PermissionResponse } from "expo-modules-core";
|
|
2
|
-
import type { NativeModule } from "
|
|
2
|
+
import type { NativeModule } from "expo";
|
|
3
3
|
|
|
4
4
|
import type {
|
|
5
5
|
AudioEncodingAndroid,
|
|
@@ -88,6 +88,23 @@ export type ExpoSpeechRecognitionErrorEvent = {
|
|
|
88
88
|
message: string;
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
+
export type LanguageDetectionEvent = {
|
|
92
|
+
/** The language that was detected, in BCP-47 format. e.g. "en-US", "de-DE" */
|
|
93
|
+
detectedLanguage: string;
|
|
94
|
+
/** The confidence of the detected language. A value ranging between 0.0 and 1.0.
|
|
95
|
+
*
|
|
96
|
+
* Values range from:
|
|
97
|
+
*
|
|
98
|
+
* - 1.0 (highly confident)
|
|
99
|
+
* - 0.8 (confident)
|
|
100
|
+
* - 0.5 (not confident)
|
|
101
|
+
* - 0.0 (unknown)
|
|
102
|
+
*/
|
|
103
|
+
confidence: number;
|
|
104
|
+
/** The alternative locales for the same language, in BCP-47 format. e.g. ["en-US", "en-GB"] */
|
|
105
|
+
topLocaleAlternatives: string[];
|
|
106
|
+
};
|
|
107
|
+
|
|
91
108
|
/**
|
|
92
109
|
* Events that are dispatched from the native side
|
|
93
110
|
*/
|
|
@@ -127,6 +144,7 @@ export type ExpoSpeechRecognitionNativeEventMap = {
|
|
|
127
144
|
end: null;
|
|
128
145
|
soundstart: null;
|
|
129
146
|
soundend: null;
|
|
147
|
+
languagedetection: LanguageDetectionEvent;
|
|
130
148
|
volumechange: {
|
|
131
149
|
/**
|
|
132
150
|
* A float value between -2 and 10 indicating the volume of the input audio
|
|
@@ -171,7 +189,9 @@ export type ExpoSpeechRecognitionOptions = {
|
|
|
171
189
|
/**
|
|
172
190
|
* [Default: false] Include punctuation in the recognition results. This applies to full stops and commas.
|
|
173
191
|
*
|
|
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+).
|
|
192
|
+
* 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+).
|
|
193
|
+
*
|
|
194
|
+
* 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)
|
|
175
195
|
*
|
|
176
196
|
* On iOS, this configures [`SFSpeechRecognitionRequest.addsPunctuation`](https://developer.apple.com/documentation/speech/sfspeechrecognitionrequest/3930023-addspunctuation).
|
|
177
197
|
*/
|
|
@@ -372,6 +392,15 @@ export type AndroidIntentOptions = {
|
|
|
372
392
|
* Depending on the recognizer implementation, this value may have no effect.
|
|
373
393
|
*/
|
|
374
394
|
EXTRA_ENABLE_LANGUAGE_SWITCH: (typeof RecognizerIntentEnableLanguageSwitch)[keyof typeof RecognizerIntentEnableLanguageSwitch];
|
|
395
|
+
/**
|
|
396
|
+
* https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_ENABLE_FORMATTING
|
|
397
|
+
*
|
|
398
|
+
* NOTE: This is also configurable through `addsPunctuation` (which sets `EXTRA_ENABLE_FORMATTING` to "quality")
|
|
399
|
+
*
|
|
400
|
+
* [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.
|
|
401
|
+
*
|
|
402
|
+
*/
|
|
403
|
+
EXTRA_ENABLE_FORMATTING: "latency" | "quality";
|
|
375
404
|
/**
|
|
376
405
|
* https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_HIDE_PARTIAL_TRAILING_PUNCTUATION
|
|
377
406
|
*
|
|
@@ -512,7 +541,13 @@ export type AndroidIntentOptions = {
|
|
|
512
541
|
EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS: number;
|
|
513
542
|
};
|
|
514
543
|
|
|
515
|
-
export
|
|
544
|
+
export type ExpoSpeechRecognitionNativeEvents = {
|
|
545
|
+
[K in keyof ExpoSpeechRecognitionNativeEventMap]: (
|
|
546
|
+
event: ExpoSpeechRecognitionNativeEventMap[K],
|
|
547
|
+
) => void;
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
export declare class ExpoSpeechRecognitionModuleType extends NativeModule<ExpoSpeechRecognitionNativeEvents> {
|
|
516
551
|
/**
|
|
517
552
|
* Starts speech recognition.
|
|
518
553
|
*/
|