expo-speech 13.1.2 → 13.1.4
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 +8 -0
- package/android/build.gradle +2 -2
- package/build/ExponentSpeech.web.d.ts.map +1 -1
- package/build/ExponentSpeech.web.js +1 -1
- package/build/ExponentSpeech.web.js.map +1 -1
- package/build/Speech.d.ts.map +1 -1
- package/build/Speech.js +6 -1
- package/build/Speech.js.map +1 -1
- package/expo-module.config.json +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.speech/{13.1.2/expo.modules.speech-13.1.2.module → 13.1.4/expo.modules.speech-13.1.4.module} +7 -7
- package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.4/expo.modules.speech-13.1.4.module.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.4/expo.modules.speech-13.1.4.module.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.4/expo.modules.speech-13.1.4.module.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.4/expo.modules.speech-13.1.4.module.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.speech/{13.1.2/expo.modules.speech-13.1.2.pom → 13.1.4/expo.modules.speech-13.1.4.pom} +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.4/expo.modules.speech-13.1.4.pom.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.4/expo.modules.speech-13.1.4.pom.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.4/expo.modules.speech-13.1.4.pom.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.4/expo.modules.speech-13.1.4.pom.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.speech/maven-metadata.xml +4 -4
- package/local-maven-repo/host/exp/exponent/expo.modules.speech/maven-metadata.xml.md5 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.speech/maven-metadata.xml.sha1 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.speech/maven-metadata.xml.sha256 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.speech/maven-metadata.xml.sha512 +1 -1
- package/package.json +3 -3
- package/src/Speech/ExponentSpeech.web.ts +1 -1
- package/src/Speech/Speech.ts +32 -4
- package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.2/expo.modules.speech-13.1.2.module.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.2/expo.modules.speech-13.1.2.module.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.2/expo.modules.speech-13.1.2.module.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.2/expo.modules.speech-13.1.2.module.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.2/expo.modules.speech-13.1.2.pom.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.2/expo.modules.speech-13.1.2.pom.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.2/expo.modules.speech-13.1.2.pom.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.speech/13.1.2/expo.modules.speech-13.1.2.pom.sha512 +0 -1
- /package/local-maven-repo/host/exp/exponent/expo.modules.speech/{13.1.2/expo.modules.speech-13.1.2-sources.jar → 13.1.4/expo.modules.speech-13.1.4-sources.jar} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.speech/{13.1.2/expo.modules.speech-13.1.2-sources.jar.md5 → 13.1.4/expo.modules.speech-13.1.4-sources.jar.md5} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.speech/{13.1.2/expo.modules.speech-13.1.2-sources.jar.sha1 → 13.1.4/expo.modules.speech-13.1.4-sources.jar.sha1} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.speech/{13.1.2/expo.modules.speech-13.1.2-sources.jar.sha256 → 13.1.4/expo.modules.speech-13.1.4-sources.jar.sha256} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.speech/{13.1.2/expo.modules.speech-13.1.2-sources.jar.sha512 → 13.1.4/expo.modules.speech-13.1.4-sources.jar.sha512} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.speech/{13.1.2/expo.modules.speech-13.1.2.aar → 13.1.4/expo.modules.speech-13.1.4.aar} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.speech/{13.1.2/expo.modules.speech-13.1.2.aar.md5 → 13.1.4/expo.modules.speech-13.1.4.aar.md5} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.speech/{13.1.2/expo.modules.speech-13.1.2.aar.sha1 → 13.1.4/expo.modules.speech-13.1.4.aar.sha1} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.speech/{13.1.2/expo.modules.speech-13.1.2.aar.sha256 → 13.1.4/expo.modules.speech-13.1.4.aar.sha256} +0 -0
- /package/local-maven-repo/host/exp/exponent/expo.modules.speech/{13.1.2/expo.modules.speech-13.1.2.aar.sha512 → 13.1.4/expo.modules.speech-13.1.4.aar.sha512} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,14 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 13.1.4 — 2025-04-14
|
|
14
|
+
|
|
15
|
+
_This version does not introduce any user-facing changes._
|
|
16
|
+
|
|
17
|
+
## 13.1.3 — 2025-04-11
|
|
18
|
+
|
|
19
|
+
_This version does not introduce any user-facing changes._
|
|
20
|
+
|
|
13
21
|
## 13.1.2 — 2025-04-09
|
|
14
22
|
|
|
15
23
|
_This version does not introduce any user-facing changes._
|
package/android/build.gradle
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExponentSpeech.web.d.ts","sourceRoot":"","sources":["../src/Speech/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K,CAAC,UAAU;QACd,OAAO,MAAM,CAAC,eAAe,CAAC,QAAQ,CAAC;IACzC,CAAC;IACD,KAAK,CAAC,IAAI;QACR,OAAO,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC;IACzC,CAAC;IACD,KAAK,CAAC,KAAK;QACT,OAAO,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IACxC,CAAC;IACD,KAAK,CAAC,MAAM;QACV,OAAO,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC;IACzC,CAAC;IACD,oBAAoB,GAAG,uBAAuB,CAAC;CAChD;AAED,eAAe,iBAAiB,CAAC,UAAU,CAAC,CAAC","sourcesContent":["import { CodedError, NativeModule, registerWebModule } from 'expo-modules-core';\n\nimport { SpeechOptions, WebVoice, VoiceQuality } from './Speech.types';\n\n//https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisUtterance/text\nconst MAX_SPEECH_INPUT_LENGTH = 32767;\n\nasync function getVoices(): Promise<SpeechSynthesisVoice[]> {\n return new Promise<SpeechSynthesisVoice[]>((resolve) => {\n const voices = window.speechSynthesis.getVoices();\n\n if (voices.length > 0) {\n resolve(voices);\n return;\n }\n\n // when a page loads it takes some amount of time to populate the voices list\n // see https://stackoverflow.com/a/52005323/4337317\n window.speechSynthesis.onvoiceschanged = function () {\n const voices = window.speechSynthesis.getVoices();\n resolve(voices);\n };\n });\n}\n\ntype ExpoSpeechEvents = {\n 'Exponent.speakingStarted': (params: { id: string; nativeEvent: SpeechSynthesisEvent }) => void;\n 'Exponent.speakingDone': (params: { id: string; nativeEvent: SpeechSynthesisEvent }) => void;\n 'Exponent.speakingStopped': (params: { id: string; nativeEvent: SpeechSynthesisEvent }) => void;\n 'Exponent.speakingError': (params: { id: string; nativeEvent: SpeechSynthesisEvent }) => void;\n};\n\nclass ExpoSpeech extends NativeModule<ExpoSpeechEvents> {\n async speak(id: string, text: string, options: SpeechOptions): Promise<SpeechSynthesisUtterance> {\n if (text.length > MAX_SPEECH_INPUT_LENGTH) {\n throw new CodedError(\n 'ERR_SPEECH_INPUT_LENGTH',\n 'Speech input text is too long! Limit of input length is: ' + MAX_SPEECH_INPUT_LENGTH\n );\n }\n\n const message = new SpeechSynthesisUtterance();\n\n if (typeof options.rate === 'number') {\n message.rate = options.rate;\n }\n if (typeof options.pitch === 'number') {\n message.pitch = options.pitch;\n }\n if (typeof options.language === 'string') {\n message.lang = options.language;\n }\n if (typeof options.volume === 'number') {\n message.volume = options.volume;\n }\n if ('_voiceIndex' in options && options._voiceIndex != null) {\n const voices = await getVoices();\n message.voice = voices[Math.min(voices.length - 1, Math.max(0, options._voiceIndex))];\n }\n if (typeof options.voice === 'string') {\n const voices = await getVoices();\n message.voice =\n voices[\n Math.max(\n 0,\n voices.findIndex((voice) => voice.voiceURI === options.voice)\n )\n ];\n }\n if (typeof options.onResume === 'function') {\n message.onresume = options.onResume;\n }\n if (typeof options.onMark === 'function') {\n message.onmark = options.onMark;\n }\n if (typeof options.onBoundary === 'function') {\n message.onboundary = options.onBoundary;\n }\n\n message.onstart = (nativeEvent: SpeechSynthesisEvent) => {\n this.emit('Exponent.speakingStarted', { id, nativeEvent });\n };\n message.onend = (nativeEvent: SpeechSynthesisEvent) => {\n this.emit('Exponent.speakingDone', { id, nativeEvent });\n };\n message.onpause = (nativeEvent: SpeechSynthesisEvent) => {\n this.emit('Exponent.speakingStopped', { id, nativeEvent });\n };\n message.onerror = (nativeEvent: SpeechSynthesisErrorEvent) => {\n this.emit('Exponent.speakingError', { id, nativeEvent });\n };\n\n message.text = text;\n\n window.speechSynthesis.speak(message);\n\n return message;\n }\n async getVoices(): Promise<WebVoice[]> {\n const voices = await getVoices();\n return voices.map((voice) => ({\n identifier: voice.voiceURI,\n quality: VoiceQuality.Default,\n isDefault: voice.default,\n language: voice.lang,\n localService: voice.localService,\n name: voice.name,\n voiceURI: voice.voiceURI,\n }));\n }\n async isSpeaking(): Promise<boolean> {\n return window.speechSynthesis.speaking;\n }\n async stop(): Promise<void> {\n return window.speechSynthesis.cancel();\n }\n async pause(): Promise<void> {\n return window.speechSynthesis.pause();\n }\n async resume(): Promise<void> {\n return window.speechSynthesis.resume();\n }\n maxSpeechInputLength = MAX_SPEECH_INPUT_LENGTH;\n}\n\nexport default registerWebModule(ExpoSpeech);\n"]}
|
|
1
|
+
{"version":3,"file":"ExponentSpeech.web.js","sourceRoot":"","sources":["../src/Speech/ExponentSpeech.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEhF,OAAO,EAA2B,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEvE,gFAAgF;AAChF,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAEtC,KAAK,UAAU,SAAS;IACtB,OAAO,IAAI,OAAO,CAAyB,CAAC,OAAO,EAAE,EAAE;QACrD,MAAM,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC,SAAS,EAAE,CAAC;QAElD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,OAAO,CAAC,MAAM,CAAC,CAAC;YAChB,OAAO;QACT,CAAC;QAED,6EAA6E;QAC7E,mDAAmD;QACnD,MAAM,CAAC,eAAe,CAAC,eAAe,GAAG;YACvC,MAAM,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC,SAAS,EAAE,CAAC;YAClD,OAAO,CAAC,MAAM,CAAC,CAAC;QAClB,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AASD,MAAM,UAAW,SAAQ,YAA8B;IACrD,KAAK,CAAC,KAAK,CAAC,EAAU,EAAE,IAAY,EAAE,OAAsB;QAC1D,IAAI,IAAI,CAAC,MAAM,GAAG,uBAAuB,EAAE,CAAC;YAC1C,MAAM,IAAI,UAAU,CAClB,yBAAyB,EACzB,2DAA2D,GAAG,uBAAuB,CACtF,CAAC;QACJ,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,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AC,CAAC;YAC5B,UAAU,EAAE,KAAK,CAAC,QAAQ;YAC1B,OAAO,EAAE,YAAY,CAAC,OAAO;YAC7B,SAAS,EAAE,KAAK,CAAC,OAAO;YACxB,QAAQ,EAAE,KAAK,CAAC,IAAI;YACpB,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;SACzB,CAAC,CAAC,CAAC;IACN,CAAC;IACD,KAAK,CAAC,UAAU;QACd,OAAO,MAAM,CAAC,eAAe,CAAC,QAAQ,CAAC;IACzC,CAAC;IACD,KAAK,CAAC,IAAI;QACR,OAAO,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC;IACzC,CAAC;IACD,KAAK,CAAC,KAAK;QACT,OAAO,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IACxC,CAAC;IACD,KAAK,CAAC,MAAM;QACV,OAAO,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC;IACzC,CAAC;IACD,oBAAoB,GAAG,uBAAuB,CAAC;CAChD;AAED,eAAe,iBAAiB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import { CodedError, NativeModule, registerWebModule } from 'expo-modules-core';\n\nimport { SpeechOptions, WebVoice, VoiceQuality } from './Speech.types';\n\n//https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisUtterance/text\nconst MAX_SPEECH_INPUT_LENGTH = 32767;\n\nasync function getVoices(): Promise<SpeechSynthesisVoice[]> {\n return new Promise<SpeechSynthesisVoice[]>((resolve) => {\n const voices = window.speechSynthesis.getVoices();\n\n if (voices.length > 0) {\n resolve(voices);\n return;\n }\n\n // when a page loads it takes some amount of time to populate the voices list\n // see https://stackoverflow.com/a/52005323/4337317\n window.speechSynthesis.onvoiceschanged = function () {\n const voices = window.speechSynthesis.getVoices();\n resolve(voices);\n };\n });\n}\n\ntype ExpoSpeechEvents = {\n 'Exponent.speakingStarted': (params: { id: string; nativeEvent: SpeechSynthesisEvent }) => void;\n 'Exponent.speakingDone': (params: { id: string; nativeEvent: SpeechSynthesisEvent }) => void;\n 'Exponent.speakingStopped': (params: { id: string; nativeEvent: SpeechSynthesisEvent }) => void;\n 'Exponent.speakingError': (params: { id: string; nativeEvent: SpeechSynthesisEvent }) => void;\n};\n\nclass ExpoSpeech extends NativeModule<ExpoSpeechEvents> {\n async speak(id: string, text: string, options: SpeechOptions): Promise<SpeechSynthesisUtterance> {\n if (text.length > MAX_SPEECH_INPUT_LENGTH) {\n throw new CodedError(\n 'ERR_SPEECH_INPUT_LENGTH',\n 'Speech input text is too long! Limit of input length is: ' + MAX_SPEECH_INPUT_LENGTH\n );\n }\n\n const message = new SpeechSynthesisUtterance();\n\n if (typeof options.rate === 'number') {\n message.rate = options.rate;\n }\n if (typeof options.pitch === 'number') {\n message.pitch = options.pitch;\n }\n if (typeof options.language === 'string') {\n message.lang = options.language;\n }\n if (typeof options.volume === 'number') {\n message.volume = options.volume;\n }\n if ('_voiceIndex' in options && options._voiceIndex != null) {\n const voices = await getVoices();\n message.voice = voices[Math.min(voices.length - 1, Math.max(0, options._voiceIndex))];\n }\n if (typeof options.voice === 'string') {\n const voices = await getVoices();\n message.voice =\n voices[\n Math.max(\n 0,\n voices.findIndex((voice) => voice.voiceURI === options.voice)\n )\n ];\n }\n if (typeof options.onResume === 'function') {\n message.onresume = options.onResume;\n }\n if (typeof options.onMark === 'function') {\n message.onmark = options.onMark;\n }\n if (typeof options.onBoundary === 'function') {\n message.onboundary = options.onBoundary;\n }\n\n message.onstart = (nativeEvent: SpeechSynthesisEvent) => {\n this.emit('Exponent.speakingStarted', { id, nativeEvent });\n };\n message.onend = (nativeEvent: SpeechSynthesisEvent) => {\n this.emit('Exponent.speakingDone', { id, nativeEvent });\n };\n message.onpause = (nativeEvent: SpeechSynthesisEvent) => {\n this.emit('Exponent.speakingStopped', { id, nativeEvent });\n };\n message.onerror = (nativeEvent: SpeechSynthesisErrorEvent) => {\n this.emit('Exponent.speakingError', { id, nativeEvent });\n };\n\n message.text = text;\n\n window.speechSynthesis.speak(message);\n\n return message;\n }\n async getVoices(): Promise<WebVoice[]> {\n const voices = await getVoices();\n return voices.map((voice) => ({\n identifier: voice.voiceURI,\n quality: VoiceQuality.Default,\n isDefault: voice.default,\n language: voice.lang,\n localService: voice.localService,\n name: voice.name,\n voiceURI: voice.voiceURI,\n }));\n }\n async isSpeaking(): Promise<boolean> {\n return window.speechSynthesis.speaking;\n }\n async stop(): Promise<void> {\n return window.speechSynthesis.cancel();\n }\n async pause(): Promise<void> {\n return window.speechSynthesis.pause();\n }\n async resume(): Promise<void> {\n return window.speechSynthesis.resume();\n }\n maxSpeechInputLength = MAX_SPEECH_INPUT_LENGTH;\n}\n\nexport default registerWebModule(ExpoSpeech, 'ExpoSpeech');\n"]}
|
package/build/Speech.d.ts.map
CHANGED
|
@@ -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;
|
|
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 =
|
|
75
|
+
const id = _makeCallbackId();
|
|
71
76
|
_CALLBACKS[id] = options;
|
|
72
77
|
_registerListenersIfNeeded();
|
|
73
78
|
ExponentSpeech.speak(String(id), text, options);
|
package/build/Speech.js.map
CHANGED
|
@@ -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;
|
|
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,EAAE,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,4BAA4B;IACnC,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAA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C,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"]}
|
package/expo-module.config.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"component": {
|
|
4
4
|
"group": "host.exp.exponent",
|
|
5
5
|
"module": "expo.modules.speech",
|
|
6
|
-
"version": "13.1.
|
|
6
|
+
"version": "13.1.4",
|
|
7
7
|
"attributes": {
|
|
8
8
|
"org.gradle.status": "release"
|
|
9
9
|
}
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
{
|
|
27
|
-
"name": "expo.modules.speech-13.1.
|
|
28
|
-
"url": "expo.modules.speech-13.1.
|
|
27
|
+
"name": "expo.modules.speech-13.1.4.aar",
|
|
28
|
+
"url": "expo.modules.speech-13.1.4.aar",
|
|
29
29
|
"size": 30104,
|
|
30
30
|
"sha512": "031d8c3f613ba6be2d4b6909cb263e394de17577dedf9a95eee47dafbaeee9463519e512df381d4c3ef0fb59201285a1c6d6943f7625de598b671d9273f02f7d",
|
|
31
31
|
"sha256": "91dc8a4689b3da6c077ed485fea90daae9372e5bdfd589e1ec3562ff3fe76cb6",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
],
|
|
54
54
|
"files": [
|
|
55
55
|
{
|
|
56
|
-
"name": "expo.modules.speech-13.1.
|
|
57
|
-
"url": "expo.modules.speech-13.1.
|
|
56
|
+
"name": "expo.modules.speech-13.1.4.aar",
|
|
57
|
+
"url": "expo.modules.speech-13.1.4.aar",
|
|
58
58
|
"size": 30104,
|
|
59
59
|
"sha512": "031d8c3f613ba6be2d4b6909cb263e394de17577dedf9a95eee47dafbaeee9463519e512df381d4c3ef0fb59201285a1c6d6943f7625de598b671d9273f02f7d",
|
|
60
60
|
"sha256": "91dc8a4689b3da6c077ed485fea90daae9372e5bdfd589e1ec3562ff3fe76cb6",
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
},
|
|
74
74
|
"files": [
|
|
75
75
|
{
|
|
76
|
-
"name": "expo.modules.speech-13.1.
|
|
77
|
-
"url": "expo.modules.speech-13.1.
|
|
76
|
+
"name": "expo.modules.speech-13.1.4-sources.jar",
|
|
77
|
+
"url": "expo.modules.speech-13.1.4-sources.jar",
|
|
78
78
|
"size": 4300,
|
|
79
79
|
"sha512": "da96e3592bc8eadeee376508feca7da36b54f37d55eda3839bff8a57980635601764dee698324c698581cc01f707596e83a96f8f84b706f60446ca2f0922c3a3",
|
|
80
80
|
"sha256": "3a9e571372d42a0a09f3f55e574aa7af6409aea92e4e69de91fc12ae256348f3",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
946aef3bce4875a742e4eaa8a20cc843
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cd0fc216cef80f3cfc941f1113485a58603553c6
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
42b686ea63f98b33b5fc7dda54068dbeb54ffd4fbbc5df16c89a4a71782f50b5
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
7744fc30f1877f77270bc6e3d09e1cb2155048ddd27e4aba24bffb972b4bbd8d3ecb953a001eea43bac98300834ab38bb1a8efe47ae19b739faf791b6ade33c9
|
|
@@ -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.
|
|
12
|
+
<version>13.1.4</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
|
+
1b946dff6d014297faa647657cf483e0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
c863d19ab70fbe1e0d82b777c4229cbf284d3c9f
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
495da24447180ce53aec0cdf0f13d91004b237cfb9db87a70b55c6e4c178e18f
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2cb18a12fbedb6d913febe8034986f4b863a3bf7e7bf043da5b3b9ac2bfde80dffc33ea3ce43a7bfec34423762dc1296f73cedf937c37e479c6a459e9a612fbe
|
|
@@ -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.
|
|
7
|
-
<release>13.1.
|
|
6
|
+
<latest>13.1.4</latest>
|
|
7
|
+
<release>13.1.4</release>
|
|
8
8
|
<versions>
|
|
9
|
-
<version>13.1.
|
|
9
|
+
<version>13.1.4</version>
|
|
10
10
|
</versions>
|
|
11
|
-
<lastUpdated>
|
|
11
|
+
<lastUpdated>20250414184111</lastUpdated>
|
|
12
12
|
</versioning>
|
|
13
13
|
</metadata>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
e8b9293a6189e4dc90bca508d5054ea2
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
f9d2316c6cc4fea4b9fbd04d23f4f9b70182e94e
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
6adb20f5ba41913b95866b053929b417f18f0b554ef145ec6ea86f354a53e9ad
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
e5201779650240d4b3165e335c6ffd6fa8dc68b19e6e6cffa69c77292bb85d4eab3088bca12f5f6777a0d7d94ba2a7587f7cf4ec3c2821a46558e3c3573dc8f0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-speech",
|
|
3
|
-
"version": "13.1.
|
|
3
|
+
"version": "13.1.4",
|
|
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.
|
|
40
|
+
"expo-module-scripts": "^4.1.2"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"expo": "*"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "335e9312f5caf634097354a230f0d4bbbfb9b0ba"
|
|
46
46
|
}
|
package/src/Speech/Speech.ts
CHANGED
|
@@ -5,10 +5,33 @@ import { SpeechOptions, SpeechEventCallback, VoiceQuality, Voice, WebVoice } fro
|
|
|
5
5
|
|
|
6
6
|
export { SpeechOptions, SpeechEventCallback, VoiceQuality, Voice, WebVoice };
|
|
7
7
|
|
|
8
|
-
|
|
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 =
|
|
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
|
|
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
|
-
69b1716288ca1173809078ca79f1389b
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
5bfce655be85f11880cedcb16607c061be725834
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
51f0568b6b8dcffd2dd7e3074aba8a64486e9302c3b2f545a9031560928008b2
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
65f5fad111fa0a86cdd5a68ea01239299e3f3e6f69c1c0eb624a3715fd71e7e6f13f8996e320a4060e04c8a6829dd3d7c13643ac6e2516fb46954cc4d912be1e
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
835af5d58b2af1efc914dc2d8d102757
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
b824700cd75ecc14c25ae7fdbcf046bb55bdf232
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
bc8e16f0f8a88b34e5d3611fc959dda85e6a28da9f2ed857f43e34510464f44d
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
b4542492f54fef54c5d6001956b7e5eb46cad0b416be007f8cdff73f3a21bd88bd432cfa363b17ade59e99cc2b86b4b9616fcacf88531842758b4b9acf890378
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|