expo-speech 13.1.3 → 13.1.5

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/android/build.gradle +2 -2
  3. package/build/Speech.d.ts.map +1 -1
  4. package/build/Speech.js +6 -1
  5. package/build/Speech.js.map +1 -1
  6. package/expo-module.config.json +1 -1
  7. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.5/expo.modules.speech-13.1.5.aar +0 -0
  8. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.5/expo.modules.speech-13.1.5.aar.md5 +1 -0
  9. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.5/expo.modules.speech-13.1.5.aar.sha1 +1 -0
  10. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.5/expo.modules.speech-13.1.5.aar.sha256 +1 -0
  11. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.5/expo.modules.speech-13.1.5.aar.sha512 +1 -0
  12. package/local-maven-repo/host/exp/exponent/expo.modules.speech/{13.1.3/expo.modules.speech-13.1.3.module → 13.1.5/expo.modules.speech-13.1.5.module} +17 -17
  13. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.5/expo.modules.speech-13.1.5.module.md5 +1 -0
  14. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.5/expo.modules.speech-13.1.5.module.sha1 +1 -0
  15. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.5/expo.modules.speech-13.1.5.module.sha256 +1 -0
  16. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.5/expo.modules.speech-13.1.5.module.sha512 +1 -0
  17. package/local-maven-repo/host/exp/exponent/expo.modules.speech/{13.1.3/expo.modules.speech-13.1.3.pom → 13.1.5/expo.modules.speech-13.1.5.pom} +1 -1
  18. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.5/expo.modules.speech-13.1.5.pom.md5 +1 -0
  19. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.5/expo.modules.speech-13.1.5.pom.sha1 +1 -0
  20. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.5/expo.modules.speech-13.1.5.pom.sha256 +1 -0
  21. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.5/expo.modules.speech-13.1.5.pom.sha512 +1 -0
  22. package/local-maven-repo/host/exp/exponent/expo.modules.speech/maven-metadata.xml +4 -4
  23. package/local-maven-repo/host/exp/exponent/expo.modules.speech/maven-metadata.xml.md5 +1 -1
  24. package/local-maven-repo/host/exp/exponent/expo.modules.speech/maven-metadata.xml.sha1 +1 -1
  25. package/local-maven-repo/host/exp/exponent/expo.modules.speech/maven-metadata.xml.sha256 +1 -1
  26. package/local-maven-repo/host/exp/exponent/expo.modules.speech/maven-metadata.xml.sha512 +1 -1
  27. package/package.json +3 -3
  28. package/src/Speech/Speech.ts +32 -4
  29. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.3/expo.modules.speech-13.1.3.aar +0 -0
  30. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.3/expo.modules.speech-13.1.3.aar.md5 +0 -1
  31. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.3/expo.modules.speech-13.1.3.aar.sha1 +0 -1
  32. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.3/expo.modules.speech-13.1.3.aar.sha256 +0 -1
  33. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.3/expo.modules.speech-13.1.3.aar.sha512 +0 -1
  34. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.3/expo.modules.speech-13.1.3.module.md5 +0 -1
  35. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.3/expo.modules.speech-13.1.3.module.sha1 +0 -1
  36. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.3/expo.modules.speech-13.1.3.module.sha256 +0 -1
  37. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.3/expo.modules.speech-13.1.3.module.sha512 +0 -1
  38. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.3/expo.modules.speech-13.1.3.pom.md5 +0 -1
  39. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.3/expo.modules.speech-13.1.3.pom.sha1 +0 -1
  40. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.3/expo.modules.speech-13.1.3.pom.sha256 +0 -1
  41. package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.3/expo.modules.speech-13.1.3.pom.sha512 +0 -1
  42. /package/local-maven-repo/host/exp/exponent/expo.modules.speech/{13.1.3/expo.modules.speech-13.1.3-sources.jar → 13.1.5/expo.modules.speech-13.1.5-sources.jar} +0 -0
  43. /package/local-maven-repo/host/exp/exponent/expo.modules.speech/{13.1.3/expo.modules.speech-13.1.3-sources.jar.md5 → 13.1.5/expo.modules.speech-13.1.5-sources.jar.md5} +0 -0
  44. /package/local-maven-repo/host/exp/exponent/expo.modules.speech/{13.1.3/expo.modules.speech-13.1.3-sources.jar.sha1 → 13.1.5/expo.modules.speech-13.1.5-sources.jar.sha1} +0 -0
  45. /package/local-maven-repo/host/exp/exponent/expo.modules.speech/{13.1.3/expo.modules.speech-13.1.3-sources.jar.sha256 → 13.1.5/expo.modules.speech-13.1.5-sources.jar.sha256} +0 -0
  46. /package/local-maven-repo/host/exp/exponent/expo.modules.speech/{13.1.3/expo.modules.speech-13.1.3-sources.jar.sha512 → 13.1.5/expo.modules.speech-13.1.5-sources.jar.sha512} +0 -0
package/CHANGELOG.md CHANGED
@@ -10,6 +10,14 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 13.1.5 — 2025-04-25
14
+
15
+ _This version does not introduce any user-facing changes._
16
+
17
+ ## 13.1.4 — 2025-04-14
18
+
19
+ _This version does not introduce any user-facing changes._
20
+
13
21
  ## 13.1.3 — 2025-04-11
14
22
 
15
23
  _This version does not introduce any user-facing changes._
@@ -4,12 +4,12 @@ plugins {
4
4
  }
5
5
 
6
6
  group = 'host.exp.exponent'
7
- version = '13.1.3'
7
+ version = '13.1.5'
8
8
 
9
9
  android {
10
10
  namespace "expo.modules.speech"
11
11
  defaultConfig {
12
12
  versionCode 18
13
- versionName "13.1.3"
13
+ versionName "13.1.5"
14
14
  }
15
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Speech.d.ts","sourceRoot":"","sources":["../src/Speech/Speech.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEnG,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AA8D7E;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,QAK9D;AAGD;;;GAGG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC,CAKhE;AAGD;;;;GAIG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CAExD;AAGD;;GAEG;AACH,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAE1C;AAGD;;GAEG;AACH,wBAAsB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAK3C;AAGD;;;GAGG;AACH,wBAAsB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAM5C;AAeD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAgE,CAAC"}
1
+ {"version":3,"file":"Speech.d.ts","sourceRoot":"","sources":["../src/Speech/Speech.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEnG,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AAuF7E;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,QAK9D;AAGD;;;GAGG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC,CAKhE;AAGD;;;;GAIG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CAExD;AAGD;;GAEG;AACH,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAE1C;AAGD;;GAEG;AACH,wBAAsB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAK3C;AAGD;;;GAGG;AACH,wBAAsB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAM5C;AAkBD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAgE,CAAC"}
package/build/Speech.js CHANGED
@@ -5,6 +5,9 @@ export { VoiceQuality };
5
5
  const _CALLBACKS = {};
6
6
  let _nextCallbackId = 1;
7
7
  let _didSetListeners = false;
8
+ function _makeCallbackId() {
9
+ return String(_nextCallbackId++);
10
+ }
8
11
  function _unregisterListenersIfNeeded() {
9
12
  if (Object.keys(_CALLBACKS).length === 0) {
10
13
  removeSpeakingListener('Exponent.speakingStarted');
@@ -28,6 +31,7 @@ function _registerListenersIfNeeded() {
28
31
  setSpeakingListener('Exponent.speakingWillSayNextString', ({ id, charIndex, charLength }) => {
29
32
  const options = _CALLBACKS[id];
30
33
  if (options && options.onBoundary) {
34
+ // @ts-expect-error TODO(cedric): type is `SpeechEventCallback` while it should be `NativeBoundaryEventCallback` in this context, resulting in errors around `this` context
31
35
  options.onBoundary({
32
36
  charIndex,
33
37
  charLength,
@@ -50,6 +54,7 @@ function _registerListenersIfNeeded() {
50
54
  delete _CALLBACKS[id];
51
55
  _unregisterListenersIfNeeded();
52
56
  });
57
+ // @ts-expect-error TODO(cedric): Android does not provide the `error` parameter for the `speakingError` event, while iOS never uses this event at all
53
58
  setSpeakingListener('Exponent.speakingError', ({ id, error }) => {
54
59
  const options = _CALLBACKS[id];
55
60
  if (options && options.onError) {
@@ -67,7 +72,7 @@ function _registerListenersIfNeeded() {
67
72
  * @param options A `SpeechOptions` object.
68
73
  */
69
74
  export function speak(text, options = {}) {
70
- const id = _nextCallbackId++;
75
+ const id = _makeCallbackId();
71
76
  _CALLBACKS[id] = options;
72
77
  _registerListenersIfNeeded();
73
78
  ExponentSpeech.speak(String(id), text, options);
@@ -1 +1 @@
1
- {"version":3,"file":"Speech.js","sourceRoot":"","sources":["../src/Speech/Speech.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAsC,YAAY,EAAmB,MAAM,gBAAgB,CAAC;AAEnG,OAAO,EAAsC,YAAY,EAAmB,CAAC;AAE7E,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,IAAI,eAAe,GAAG,CAAC,CAAC;AACxB,IAAI,gBAAgB,GAAG,KAAK,CAAC;AAE7B,SAAS,4BAA4B;IACnC,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzC,sBAAsB,CAAC,0BAA0B,CAAC,CAAC;QACnD,sBAAsB,CAAC,oCAAoC,CAAC,CAAC;QAC7D,sBAAsB,CAAC,uBAAuB,CAAC,CAAC;QAChD,sBAAsB,CAAC,0BAA0B,CAAC,CAAC;QACnD,sBAAsB,CAAC,wBAAwB,CAAC,CAAC;QACjD,gBAAgB,GAAG,KAAK,CAAC;IAC3B,CAAC;AACH,CAAC;AAED,SAAS,0BAA0B;IACjC,IAAI,gBAAgB;QAAE,OAAO;IAC7B,gBAAgB,GAAG,IAAI,CAAC;IACxB,mBAAmB,CAAC,0BAA0B,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;QACzD,MAAM,OAAO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,CAAC,KAAK,EAAE,CAAC;AAChC,CAAC;AAED,cAAc;AACd;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM;IAC1B,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;QAC3B,MAAM,IAAI,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,cAAc,CAAC,MAAM,EAAE,CAAC;AACjC,CAAC;AAED,SAAS,mBAAmB,CAAC,SAAS,EAAE,QAAQ;IAC9C,MAAM,aAAa,GAAG,cAAc,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAC9D,IAAI,aAAa,GAAG,CAAC,EAAE,CAAC;QACtB,cAAc,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC/C,CAAC;IACD,cAAc,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,sBAAsB,CAAC,SAAS;IACvC,cAAc,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;AAC/C,CAAC;AAED,cAAc;AACd;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAW,cAAc,CAAC,oBAAoB,IAAI,MAAM,CAAC,SAAS,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\n\nimport ExponentSpeech from './ExponentSpeech';\nimport { SpeechOptions, SpeechEventCallback, VoiceQuality, Voice, WebVoice } from './Speech.types';\n\nexport { SpeechOptions, SpeechEventCallback, VoiceQuality, Voice, WebVoice };\n\nconst _CALLBACKS = {};\nlet _nextCallbackId = 1;\nlet _didSetListeners = false;\n\nfunction _unregisterListenersIfNeeded() {\n if (Object.keys(_CALLBACKS).length === 0) {\n removeSpeakingListener('Exponent.speakingStarted');\n removeSpeakingListener('Exponent.speakingWillSayNextString');\n removeSpeakingListener('Exponent.speakingDone');\n removeSpeakingListener('Exponent.speakingStopped');\n removeSpeakingListener('Exponent.speakingError');\n _didSetListeners = false;\n }\n}\n\nfunction _registerListenersIfNeeded() {\n if (_didSetListeners) return;\n _didSetListeners = true;\n setSpeakingListener('Exponent.speakingStarted', ({ id }) => {\n const options = _CALLBACKS[id];\n if (options && options.onStart) {\n options.onStart();\n }\n });\n setSpeakingListener('Exponent.speakingWillSayNextString', ({ id, charIndex, charLength }) => {\n const options = _CALLBACKS[id];\n if (options && options.onBoundary) {\n options.onBoundary({\n charIndex,\n charLength,\n });\n }\n });\n setSpeakingListener('Exponent.speakingDone', ({ id }) => {\n const options = _CALLBACKS[id];\n if (options && options.onDone) {\n options.onDone();\n }\n delete _CALLBACKS[id];\n _unregisterListenersIfNeeded();\n });\n setSpeakingListener('Exponent.speakingStopped', ({ id }) => {\n const options = _CALLBACKS[id];\n if (options && options.onStopped) {\n options.onStopped();\n }\n delete _CALLBACKS[id];\n _unregisterListenersIfNeeded();\n });\n setSpeakingListener('Exponent.speakingError', ({ id, error }) => {\n const options = _CALLBACKS[id];\n if (options && options.onError) {\n options.onError(new Error(error));\n }\n delete _CALLBACKS[id];\n _unregisterListenersIfNeeded();\n });\n}\n\n// @needsAudit\n/**\n * Speak out loud the text given options. Calling this when another text is being spoken adds\n * an utterance to queue.\n * @param text The text to be spoken. Cannot be longer than [`Speech.maxSpeechInputLength`](#speechmaxspeechinputlength).\n * @param options A `SpeechOptions` object.\n */\nexport function speak(text: string, options: SpeechOptions = {}) {\n const id = _nextCallbackId++;\n _CALLBACKS[id] = options;\n _registerListenersIfNeeded();\n ExponentSpeech.speak(String(id), text, options);\n}\n\n// @needsAudit\n/**\n * Returns list of all available voices.\n * @return List of `Voice` objects.\n */\nexport async function getAvailableVoicesAsync(): Promise<Voice[]> {\n if (!ExponentSpeech.getVoices) {\n throw new UnavailabilityError('Speech', 'getVoices');\n }\n return ExponentSpeech.getVoices();\n}\n\n//@needsAudit\n/**\n * Determine whether the Text-to-speech utility is currently speaking. Will return `true` if speaker\n * is paused.\n * @return Returns a Promise that fulfils with a boolean, `true` if speaking, `false` if not.\n */\nexport async function isSpeakingAsync(): Promise<boolean> {\n return ExponentSpeech.isSpeaking();\n}\n\n// @needsAudit\n/**\n * Interrupts current speech and deletes all in queue.\n */\nexport async function stop(): Promise<void> {\n return ExponentSpeech.stop();\n}\n\n// @needsAudit\n/**\n * Pauses current speech. This method is not available on Android.\n */\nexport async function pause(): Promise<void> {\n if (!ExponentSpeech.pause) {\n throw new UnavailabilityError('Speech', 'pause');\n }\n return ExponentSpeech.pause();\n}\n\n// @needsAudit\n/**\n * Resumes speaking previously paused speech or does nothing if there's none. This method is not\n * available on Android.\n */\nexport async function resume(): Promise<void> {\n if (!ExponentSpeech.resume) {\n throw new UnavailabilityError('Speech', 'resume');\n }\n\n return ExponentSpeech.resume();\n}\n\nfunction setSpeakingListener(eventName, callback) {\n const listenerCount = ExponentSpeech.listenerCount(eventName);\n if (listenerCount > 0) {\n ExponentSpeech.removeAllListeners(eventName);\n }\n ExponentSpeech.addListener(eventName, callback);\n}\n\nfunction removeSpeakingListener(eventName) {\n ExponentSpeech.removeAllListeners(eventName);\n}\n\n// @needsAudit\n/**\n * Maximum possible text length acceptable by `Speech.speak()` method. It is platform-dependent.\n * On iOS, this returns `Number.MAX_VALUE`.\n */\nexport const maxSpeechInputLength: number = ExponentSpeech.maxSpeechInputLength || Number.MAX_VALUE;\n"]}
1
+ {"version":3,"file":"Speech.js","sourceRoot":"","sources":["../src/Speech/Speech.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAsC,YAAY,EAAmB,MAAM,gBAAgB,CAAC;AAEnG,OAAO,EAAsC,YAAY,EAAmB,CAAC;AAqB7E,MAAM,UAAU,GAA8D,EAAE,CAAC;AACjF,IAAI,eAAe,GAAG,CAAC,CAAC;AACxB,IAAI,gBAAgB,GAAG,KAAK,CAAC;AAE7B,SAAS,eAAe;IACtB,OAAO,MAAM,CAAC,eAAe,E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AC,SAAS,CAAC,CAAC;AAC/C,CAAC;AAED,cAAc;AACd;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAW,cAAc,CAAC,oBAAoB,IAAI,MAAM,CAAC,SAAS,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\n\nimport ExponentSpeech from './ExponentSpeech';\nimport { SpeechOptions, SpeechEventCallback, VoiceQuality, Voice, WebVoice } from './Speech.types';\n\nexport { SpeechOptions, SpeechEventCallback, VoiceQuality, Voice, WebVoice };\n\ntype SpeechEventSharedParams = {\n /** The speech utterance or callback ID */\n id: string;\n};\n\ntype SpeechEvent<EventParams = never> = (\n params: [EventParams] extends [never]\n ? SpeechEventSharedParams\n : SpeechEventSharedParams & EventParams\n) => void;\n\ntype SpeechEventsMap = {\n 'Exponent.speakingStarted': SpeechEvent;\n 'Exponent.speakingWillSayNextString': SpeechEvent<{ charIndex: number; charLength: number }>;\n 'Exponent.speakingDone': SpeechEvent;\n 'Exponent.speakingStopped': SpeechEvent;\n 'Exponent.speakingError': SpeechEvent;\n};\n\nconst _CALLBACKS: Record<ReturnType<typeof _makeCallbackId>, SpeechOptions> = {};\nlet _nextCallbackId = 1;\nlet _didSetListeners = false;\n\nfunction _makeCallbackId(): SpeechEventSharedParams['id'] {\n return String(_nextCallbackId++);\n}\n\nfunction _unregisterListenersIfNeeded() {\n if (Object.keys(_CALLBACKS).length === 0) {\n removeSpeakingListener('Exponent.speakingStarted');\n removeSpeakingListener('Exponent.speakingWillSayNextString');\n removeSpeakingListener('Exponent.speakingDone');\n removeSpeakingListener('Exponent.speakingStopped');\n removeSpeakingListener('Exponent.speakingError');\n _didSetListeners = false;\n }\n}\n\nfunction _registerListenersIfNeeded() {\n if (_didSetListeners) return;\n _didSetListeners = true;\n setSpeakingListener('Exponent.speakingStarted', ({ id }) => {\n const options = _CALLBACKS[id];\n if (options && options.onStart) {\n options.onStart();\n }\n });\n setSpeakingListener('Exponent.speakingWillSayNextString', ({ id, charIndex, charLength }) => {\n const options = _CALLBACKS[id];\n if (options && options.onBoundary) {\n // @ts-expect-error TODO(cedric): type is `SpeechEventCallback` while it should be `NativeBoundaryEventCallback` in this context, resulting in errors around `this` context\n options.onBoundary({\n charIndex,\n charLength,\n });\n }\n });\n setSpeakingListener('Exponent.speakingDone', ({ id }) => {\n const options = _CALLBACKS[id];\n if (options && options.onDone) {\n options.onDone();\n }\n delete _CALLBACKS[id];\n _unregisterListenersIfNeeded();\n });\n setSpeakingListener('Exponent.speakingStopped', ({ id }) => {\n const options = _CALLBACKS[id];\n if (options && options.onStopped) {\n options.onStopped();\n }\n delete _CALLBACKS[id];\n _unregisterListenersIfNeeded();\n });\n // @ts-expect-error TODO(cedric): Android does not provide the `error` parameter for the `speakingError` event, while iOS never uses this event at all\n setSpeakingListener('Exponent.speakingError', ({ id, error }) => {\n const options = _CALLBACKS[id];\n if (options && options.onError) {\n options.onError(new Error(error));\n }\n delete _CALLBACKS[id];\n _unregisterListenersIfNeeded();\n });\n}\n\n// @needsAudit\n/**\n * Speak out loud the text given options. Calling this when another text is being spoken adds\n * an utterance to queue.\n * @param text The text to be spoken. Cannot be longer than [`Speech.maxSpeechInputLength`](#speechmaxspeechinputlength).\n * @param options A `SpeechOptions` object.\n */\nexport function speak(text: string, options: SpeechOptions = {}) {\n const id = _makeCallbackId();\n _CALLBACKS[id] = options;\n _registerListenersIfNeeded();\n ExponentSpeech.speak(String(id), text, options);\n}\n\n// @needsAudit\n/**\n * Returns list of all available voices.\n * @return List of `Voice` objects.\n */\nexport async function getAvailableVoicesAsync(): Promise<Voice[]> {\n if (!ExponentSpeech.getVoices) {\n throw new UnavailabilityError('Speech', 'getVoices');\n }\n return ExponentSpeech.getVoices();\n}\n\n//@needsAudit\n/**\n * Determine whether the Text-to-speech utility is currently speaking. Will return `true` if speaker\n * is paused.\n * @return Returns a Promise that fulfils with a boolean, `true` if speaking, `false` if not.\n */\nexport async function isSpeakingAsync(): Promise<boolean> {\n return ExponentSpeech.isSpeaking();\n}\n\n// @needsAudit\n/**\n * Interrupts current speech and deletes all in queue.\n */\nexport async function stop(): Promise<void> {\n return ExponentSpeech.stop();\n}\n\n// @needsAudit\n/**\n * Pauses current speech. This method is not available on Android.\n */\nexport async function pause(): Promise<void> {\n if (!ExponentSpeech.pause) {\n throw new UnavailabilityError('Speech', 'pause');\n }\n return ExponentSpeech.pause();\n}\n\n// @needsAudit\n/**\n * Resumes speaking previously paused speech or does nothing if there's none. This method is not\n * available on Android.\n */\nexport async function resume(): Promise<void> {\n if (!ExponentSpeech.resume) {\n throw new UnavailabilityError('Speech', 'resume');\n }\n\n return ExponentSpeech.resume();\n}\n\nfunction setSpeakingListener<T extends keyof SpeechEventsMap>(\n eventName: T,\n callback: SpeechEventsMap[T]\n) {\n const listenerCount = ExponentSpeech.listenerCount(eventName);\n if (listenerCount > 0) {\n ExponentSpeech.removeAllListeners(eventName);\n }\n ExponentSpeech.addListener(eventName, callback);\n}\n\nfunction removeSpeakingListener<T extends keyof SpeechEventsMap>(eventName: T) {\n ExponentSpeech.removeAllListeners(eventName);\n}\n\n// @needsAudit\n/**\n * Maximum possible text length acceptable by `Speech.speak()` method. It is platform-dependent.\n * On iOS, this returns `Number.MAX_VALUE`.\n */\nexport const maxSpeechInputLength: number = ExponentSpeech.maxSpeechInputLength || Number.MAX_VALUE;\n"]}
@@ -8,7 +8,7 @@
8
8
  "publication": {
9
9
  "groupId": "host.exp.exponent",
10
10
  "artifactId": "expo.modules.speech",
11
- "version": "13.1.3",
11
+ "version": "13.1.5",
12
12
  "repository": "local-maven-repo"
13
13
  }
14
14
  }
@@ -0,0 +1 @@
1
+ 4c5a6403f69771511d9d3b815f9dafae4f0fd9d1602e37ba126a881ce0163375
@@ -0,0 +1 @@
1
+ d897f4fec68ad2c718d8d5914e909f6c6f3b5bc8d4058f11d16cbf203e99c49e35f898838718663bb856a93d9b7977e234509ec8c331c41d15f4a7f3accbe147
@@ -3,7 +3,7 @@
3
3
  "component": {
4
4
  "group": "host.exp.exponent",
5
5
  "module": "expo.modules.speech",
6
- "version": "13.1.3",
6
+ "version": "13.1.5",
7
7
  "attributes": {
8
8
  "org.gradle.status": "release"
9
9
  }
@@ -24,13 +24,13 @@
24
24
  },
25
25
  "files": [
26
26
  {
27
- "name": "expo.modules.speech-13.1.3.aar",
28
- "url": "expo.modules.speech-13.1.3.aar",
29
- "size": 30104,
30
- "sha512": "031d8c3f613ba6be2d4b6909cb263e394de17577dedf9a95eee47dafbaeee9463519e512df381d4c3ef0fb59201285a1c6d6943f7625de598b671d9273f02f7d",
31
- "sha256": "91dc8a4689b3da6c077ed485fea90daae9372e5bdfd589e1ec3562ff3fe76cb6",
32
- "sha1": "f0da3db013e2c09867a2b1e23c4993827d615522",
33
- "md5": "df28a3cf6f7254d13dfac884cd408990"
27
+ "name": "expo.modules.speech-13.1.5.aar",
28
+ "url": "expo.modules.speech-13.1.5.aar",
29
+ "size": 30168,
30
+ "sha512": "d897f4fec68ad2c718d8d5914e909f6c6f3b5bc8d4058f11d16cbf203e99c49e35f898838718663bb856a93d9b7977e234509ec8c331c41d15f4a7f3accbe147",
31
+ "sha256": "4c5a6403f69771511d9d3b815f9dafae4f0fd9d1602e37ba126a881ce0163375",
32
+ "sha1": "7fe449fd84dfaaa18df2d16b037286fc7b53305a",
33
+ "md5": "823ad87fa43963c2085884e981fa0436"
34
34
  }
35
35
  ]
36
36
  },
@@ -53,13 +53,13 @@
53
53
  ],
54
54
  "files": [
55
55
  {
56
- "name": "expo.modules.speech-13.1.3.aar",
57
- "url": "expo.modules.speech-13.1.3.aar",
58
- "size": 30104,
59
- "sha512": "031d8c3f613ba6be2d4b6909cb263e394de17577dedf9a95eee47dafbaeee9463519e512df381d4c3ef0fb59201285a1c6d6943f7625de598b671d9273f02f7d",
60
- "sha256": "91dc8a4689b3da6c077ed485fea90daae9372e5bdfd589e1ec3562ff3fe76cb6",
61
- "sha1": "f0da3db013e2c09867a2b1e23c4993827d615522",
62
- "md5": "df28a3cf6f7254d13dfac884cd408990"
56
+ "name": "expo.modules.speech-13.1.5.aar",
57
+ "url": "expo.modules.speech-13.1.5.aar",
58
+ "size": 30168,
59
+ "sha512": "d897f4fec68ad2c718d8d5914e909f6c6f3b5bc8d4058f11d16cbf203e99c49e35f898838718663bb856a93d9b7977e234509ec8c331c41d15f4a7f3accbe147",
60
+ "sha256": "4c5a6403f69771511d9d3b815f9dafae4f0fd9d1602e37ba126a881ce0163375",
61
+ "sha1": "7fe449fd84dfaaa18df2d16b037286fc7b53305a",
62
+ "md5": "823ad87fa43963c2085884e981fa0436"
63
63
  }
64
64
  ]
65
65
  },
@@ -73,8 +73,8 @@
73
73
  },
74
74
  "files": [
75
75
  {
76
- "name": "expo.modules.speech-13.1.3-sources.jar",
77
- "url": "expo.modules.speech-13.1.3-sources.jar",
76
+ "name": "expo.modules.speech-13.1.5-sources.jar",
77
+ "url": "expo.modules.speech-13.1.5-sources.jar",
78
78
  "size": 4300,
79
79
  "sha512": "da96e3592bc8eadeee376508feca7da36b54f37d55eda3839bff8a57980635601764dee698324c698581cc01f707596e83a96f8f84b706f60446ca2f0922c3a3",
80
80
  "sha256": "3a9e571372d42a0a09f3f55e574aa7af6409aea92e4e69de91fc12ae256348f3",
@@ -0,0 +1 @@
1
+ fb44fa4aea4b643f4371c441704c4ae9d9b320bbf8c3bcb1a474ea6d2f8e5a8f
@@ -0,0 +1 @@
1
+ 5a15c537394ecda4dc925b18989bdd7f5ce9d5c6993bc66686ff7ae9471c1ff184f365086f32ae2d190dc48bf9caed638303e6fc34bbae8855b97f681ac7ce69
@@ -9,7 +9,7 @@
9
9
  <modelVersion>4.0.0</modelVersion>
10
10
  <groupId>host.exp.exponent</groupId>
11
11
  <artifactId>expo.modules.speech</artifactId>
12
- <version>13.1.3</version>
12
+ <version>13.1.5</version>
13
13
  <packaging>aar</packaging>
14
14
  <name>expo.modules.speech</name>
15
15
  <url>https://github.com/expo/expo</url>
@@ -0,0 +1 @@
1
+ 89d7f827b5776e371687c3cac3b1465285a93857a5d7d77bb3c25a1f1741abe1
@@ -0,0 +1 @@
1
+ 20f45119ada5830fa598045bfb64724968ade6e380f936f1a201c8053c9c6dd47664f5a3bcf5962e0df359881ce6c38d6000a9e571aa5a165452f2ad549a650e
@@ -3,11 +3,11 @@
3
3
  <groupId>host.exp.exponent</groupId>
4
4
  <artifactId>expo.modules.speech</artifactId>
5
5
  <versioning>
6
- <latest>13.1.3</latest>
7
- <release>13.1.3</release>
6
+ <latest>13.1.5</latest>
7
+ <release>13.1.5</release>
8
8
  <versions>
9
- <version>13.1.3</version>
9
+ <version>13.1.5</version>
10
10
  </versions>
11
- <lastUpdated>20250411190920</lastUpdated>
11
+ <lastUpdated>20250425210748</lastUpdated>
12
12
  </versioning>
13
13
  </metadata>
@@ -1 +1 @@
1
- f26f85da0ccd6f22c925b78c47a69b85
1
+ ddabc81c252a24e912be58119d62679b
@@ -1 +1 @@
1
- 21b892b48d76bc039af030ab58acae3a0a492d08
1
+ fc310b81f4606de091ff06a89c55f70c8394f59a
@@ -1 +1 @@
1
- 255bf3434501f1a7d0d18a65b472b8c29556a984d0d74f8cfdda2ef2a5569e5e
1
+ ff2f98e9120ad342ac3677b4d533c846ea3bd2f4fd86d14d47ba906f8c115f7e
@@ -1 +1 @@
1
- bb75aac4870ba3e421996042a8d92a79c3d38fd6558a90a8e8fd136cfed4edb6b597c8f72bd305c02d63030373a93bc2b9c047b8b733c7668b8c3730e8bf56cd
1
+ 88b8abd637ae496c6ebc4727e189092d209f2dc5d54d6790e37fc4afac8b11491b68610a4b52ecd95fe52d2d12d7dc640f6811f8a29f63c54f338f79d5adce43
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-speech",
3
- "version": "13.1.3",
3
+ "version": "13.1.5",
4
4
  "description": "Provides text-to-speech functionality.",
5
5
  "main": "build/Speech.js",
6
6
  "types": "build/Speech.d.ts",
@@ -37,10 +37,10 @@
37
37
  },
38
38
  "dependencies": {},
39
39
  "devDependencies": {
40
- "expo-module-scripts": "^4.1.1"
40
+ "expo-module-scripts": "^4.1.5"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "expo": "*"
44
44
  },
45
- "gitHead": "dd2c7150fd75c56505aa6d3f805c14e255649c5d"
45
+ "gitHead": "3cd208465df78e385ca9380531bbbfe33ca68e81"
46
46
  }
@@ -5,10 +5,33 @@ import { SpeechOptions, SpeechEventCallback, VoiceQuality, Voice, WebVoice } fro
5
5
 
6
6
  export { SpeechOptions, SpeechEventCallback, VoiceQuality, Voice, WebVoice };
7
7
 
8
- const _CALLBACKS = {};
8
+ type SpeechEventSharedParams = {
9
+ /** The speech utterance or callback ID */
10
+ id: string;
11
+ };
12
+
13
+ type SpeechEvent<EventParams = never> = (
14
+ params: [EventParams] extends [never]
15
+ ? SpeechEventSharedParams
16
+ : SpeechEventSharedParams & EventParams
17
+ ) => void;
18
+
19
+ type SpeechEventsMap = {
20
+ 'Exponent.speakingStarted': SpeechEvent;
21
+ 'Exponent.speakingWillSayNextString': SpeechEvent<{ charIndex: number; charLength: number }>;
22
+ 'Exponent.speakingDone': SpeechEvent;
23
+ 'Exponent.speakingStopped': SpeechEvent;
24
+ 'Exponent.speakingError': SpeechEvent;
25
+ };
26
+
27
+ const _CALLBACKS: Record<ReturnType<typeof _makeCallbackId>, SpeechOptions> = {};
9
28
  let _nextCallbackId = 1;
10
29
  let _didSetListeners = false;
11
30
 
31
+ function _makeCallbackId(): SpeechEventSharedParams['id'] {
32
+ return String(_nextCallbackId++);
33
+ }
34
+
12
35
  function _unregisterListenersIfNeeded() {
13
36
  if (Object.keys(_CALLBACKS).length === 0) {
14
37
  removeSpeakingListener('Exponent.speakingStarted');
@@ -32,6 +55,7 @@ function _registerListenersIfNeeded() {
32
55
  setSpeakingListener('Exponent.speakingWillSayNextString', ({ id, charIndex, charLength }) => {
33
56
  const options = _CALLBACKS[id];
34
57
  if (options && options.onBoundary) {
58
+ // @ts-expect-error TODO(cedric): type is `SpeechEventCallback` while it should be `NativeBoundaryEventCallback` in this context, resulting in errors around `this` context
35
59
  options.onBoundary({
36
60
  charIndex,
37
61
  charLength,
@@ -54,6 +78,7 @@ function _registerListenersIfNeeded() {
54
78
  delete _CALLBACKS[id];
55
79
  _unregisterListenersIfNeeded();
56
80
  });
81
+ // @ts-expect-error TODO(cedric): Android does not provide the `error` parameter for the `speakingError` event, while iOS never uses this event at all
57
82
  setSpeakingListener('Exponent.speakingError', ({ id, error }) => {
58
83
  const options = _CALLBACKS[id];
59
84
  if (options && options.onError) {
@@ -72,7 +97,7 @@ function _registerListenersIfNeeded() {
72
97
  * @param options A `SpeechOptions` object.
73
98
  */
74
99
  export function speak(text: string, options: SpeechOptions = {}) {
75
- const id = _nextCallbackId++;
100
+ const id = _makeCallbackId();
76
101
  _CALLBACKS[id] = options;
77
102
  _registerListenersIfNeeded();
78
103
  ExponentSpeech.speak(String(id), text, options);
@@ -132,7 +157,10 @@ export async function resume(): Promise<void> {
132
157
  return ExponentSpeech.resume();
133
158
  }
134
159
 
135
- function setSpeakingListener(eventName, callback) {
160
+ function setSpeakingListener<T extends keyof SpeechEventsMap>(
161
+ eventName: T,
162
+ callback: SpeechEventsMap[T]
163
+ ) {
136
164
  const listenerCount = ExponentSpeech.listenerCount(eventName);
137
165
  if (listenerCount > 0) {
138
166
  ExponentSpeech.removeAllListeners(eventName);
@@ -140,7 +168,7 @@ function setSpeakingListener(eventName, callback) {
140
168
  ExponentSpeech.addListener(eventName, callback);
141
169
  }
142
170
 
143
- function removeSpeakingListener(eventName) {
171
+ function removeSpeakingListener<T extends keyof SpeechEventsMap>(eventName: T) {
144
172
  ExponentSpeech.removeAllListeners(eventName);
145
173
  }
146
174
 
@@ -1 +0,0 @@
1
- f0da3db013e2c09867a2b1e23c4993827d615522
@@ -1 +0,0 @@
1
- 91dc8a4689b3da6c077ed485fea90daae9372e5bdfd589e1ec3562ff3fe76cb6
@@ -1 +0,0 @@
1
- 031d8c3f613ba6be2d4b6909cb263e394de17577dedf9a95eee47dafbaeee9463519e512df381d4c3ef0fb59201285a1c6d6943f7625de598b671d9273f02f7d
@@ -1 +0,0 @@
1
- c02dd1fae717a62eaa262c59ae02fb0e7809767c0b77133f391a4b77f5911ea2
@@ -1 +0,0 @@
1
- e3a82da64415a2d6e43a283e4426eae256e8e29954fdca0ebc21e321fce3cd2cf95c301401c0fe766c801046452c62a84be12cc63e5c7d23da54a8ada62777f2
@@ -1 +0,0 @@
1
- bd600e8ede975b75b5b479cd15e7399cad041b40
@@ -1 +0,0 @@
1
- 92c211f201e37ab47d796d8e00f1e9300307ac783a7008ae954a46b805e84576
@@ -1 +0,0 @@
1
- 5e9968105f4066b70dc896af57ad6143bd361ac158d498cead54331fb494c447bf074c33933d9952b214d33af35d55a5f78309c2dba47aaecf8790e3f0ce0449