react-native-davoice 1.0.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.
Files changed (67) hide show
  1. package/README.md +319 -0
  2. package/TTSRNBridge.podspec +38 -0
  3. package/android/.gradle/8.9/checksums/checksums.lock +0 -0
  4. package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
  5. package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
  6. package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
  7. package/android/.gradle/8.9/gc.properties +0 -0
  8. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  9. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  10. package/android/.gradle/vcs-1/gc.properties +0 -0
  11. package/android/build.gradle +47 -0
  12. package/android/libs/com/davoice/tts/1.0.0/tts-1.0.0.aar +0 -0
  13. package/android/libs/com/davoice/tts/1.0.0/tts-1.0.0.aar.md5 +1 -0
  14. package/android/libs/com/davoice/tts/1.0.0/tts-1.0.0.aar.sha1 +1 -0
  15. package/android/libs/com/davoice/tts/1.0.0/tts-1.0.0.pom +38 -0
  16. package/android/libs/com/davoice/tts/1.0.0/tts-1.0.0.pom.md5 +1 -0
  17. package/android/libs/com/davoice/tts/1.0.0/tts-1.0.0.pom.sha1 +1 -0
  18. package/android/settings.gradle +2 -0
  19. package/android/src/main/AndroidManifest.xml +14 -0
  20. package/android/src/main/java/com/davoice/rn/DaVoicePackage.java +29 -0
  21. package/android/src/main/java/com/davoice/stt/rn/STTModule.kt +208 -0
  22. package/android/src/main/java/com/davoice/tts/rn/DaVoiceTTSBridge.java +733 -0
  23. package/android/src/main/libs/MyLibrary-release.aar +0 -0
  24. package/app.plugin.js +60 -0
  25. package/ios/STTRNBridge/STTBridge.h +7 -0
  26. package/ios/STTRNBridge/STTBridge.m +130 -0
  27. package/ios/SpeechBridge/SpeechBridge.h +7 -0
  28. package/ios/SpeechBridge/SpeechBridge.m +761 -0
  29. package/ios/TTSRNBridge/DaVoiceTTSBridge.h +7 -0
  30. package/ios/TTSRNBridge/DaVoiceTTSBridge.m +177 -0
  31. package/ios/TTSRNBridge/DavoiceTTS.xcframework/Info.plist +44 -0
  32. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/DavoiceTTS +0 -0
  33. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Headers/DavoiceTTS-Swift.h +424 -0
  34. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Info.plist +0 -0
  35. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.abi.json +13253 -0
  36. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.private.swiftinterface +213 -0
  37. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  38. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.swiftinterface +213 -0
  39. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/module.modulemap +4 -0
  40. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/DavoiceTTS +0 -0
  41. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Headers/DavoiceTTS-Swift.h +844 -0
  42. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Info.plist +0 -0
  43. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.abi.json +13253 -0
  44. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +213 -0
  45. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  46. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.swiftinterface +213 -0
  47. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.abi.json +13253 -0
  48. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +213 -0
  49. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  50. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +213 -0
  51. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/module.modulemap +4 -0
  52. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeDirectory +0 -0
  53. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeRequirements +0 -0
  54. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeRequirements-1 +0 -0
  55. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeResources +282 -0
  56. package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeSignature +0 -0
  57. package/ios/TTSRNBridge/libphonemes.a +0 -0
  58. package/ios/TTSRNBridge/libucd.a +0 -0
  59. package/package.json +46 -0
  60. package/react-native.config.js +10 -0
  61. package/speech/index.ts +1055 -0
  62. package/stt/index.d.ts +54 -0
  63. package/stt/index.ts +222 -0
  64. package/tts/DaVoiceTTSBridge.d.ts +18 -0
  65. package/tts/DaVoiceTTSBridge.js +71 -0
  66. package/tts/index.d.ts +3 -0
  67. package/tts/index.js +4 -0
@@ -0,0 +1,208 @@
1
+ package com.davoice.stt.rn
2
+
3
+ import com.facebook.react.bridge.*
4
+ import com.facebook.react.module.annotations.ReactModule
5
+ import com.facebook.react.modules.core.DeviceEventManagerModule
6
+ import com.davoice.stt.STT
7
+ import com.davoice.stt.STTDelegate
8
+ import com.davoice.tts.LicenseManager
9
+
10
+ @ReactModule(name = STTModule.NAME)
11
+ class STTModule(private val rc: ReactApplicationContext)
12
+ : ReactContextBaseJavaModule(rc), STTDelegate {
13
+
14
+ companion object { const val NAME = "STT" }
15
+
16
+ private var stt: STT? = null
17
+
18
+ override fun getName() = NAME
19
+
20
+ // RN event emitter stubs (required by RN)
21
+ @ReactMethod fun addListener(eventName: String) {}
22
+ @ReactMethod fun removeListeners(count: Double) {}
23
+
24
+ private fun send(name: String, body: WritableMap? = null) {
25
+ rc.runOnUiQueueThread {
26
+ rc.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
27
+ .emit(name, body)
28
+ }
29
+ }
30
+
31
+ private fun ensure(): STT {
32
+ if (stt == null) {
33
+ stt = STT(rc.applicationContext, continuous = true).also { it.delegate = this }
34
+ }
35
+ return stt!!
36
+ }
37
+
38
+ // ===== JS API =====
39
+
40
+ @ReactMethod
41
+ fun setLicense(licenseKey: String?, promise: Promise) {
42
+ try {
43
+ if (licenseKey.isNullOrBlank()) {
44
+ promise.reject("invalid_args", "Missing licenseKey")
45
+ return
46
+ }
47
+ promise.resolve(ensure().setLicenseKey(licenseKey))
48
+ } catch (t: Throwable) {
49
+ promise.reject("LicenseError", t.message, t)
50
+ }
51
+ }
52
+
53
+ @ReactMethod
54
+ fun isLicenseValid(licenseKey: String?, promise: Promise) {
55
+ try {
56
+ if (licenseKey.isNullOrBlank()) {
57
+ promise.reject("invalid_args", "Missing licenseKey")
58
+ return
59
+ }
60
+ promise.resolve(LicenseManager.isLicenseValid(licenseKey))
61
+ } catch (t: Throwable) {
62
+ promise.reject("LicenseError", t.message, t)
63
+ }
64
+ }
65
+
66
+ // ANDROID expects (locale, options, callback) like @react-native-voice
67
+ @ReactMethod
68
+ fun startSpeech(locale: String?, options: ReadableMap, cb: Callback) {
69
+ var onboardingJson: String? = null
70
+ try {
71
+ if (options.hasKey("onboardingJsonPath") && !options.isNull("onboardingJsonPath")) {
72
+ val p = options.getString("onboardingJsonPath")
73
+ if (!p.isNullOrBlank()) {
74
+ onboardingJson = java.io.File(p).readText(Charsets.UTF_8)
75
+ }
76
+ }
77
+ } catch (_: Throwable) {
78
+ onboardingJson = null
79
+ }
80
+
81
+ ensure().startSpeech(locale, onboardingJson, null)
82
+ cb.invoke(false) // parity with voice: callback(false) on success
83
+ }
84
+
85
+ @ReactMethod
86
+ fun stopSpeech(cb: Callback) {
87
+ stt?.stopSpeech()
88
+ cb.invoke(false)
89
+ }
90
+
91
+ @ReactMethod
92
+ fun cancelSpeech(cb: Callback) {
93
+ stt?.cancelSpeech()
94
+ cb.invoke(false)
95
+ }
96
+
97
+ @ReactMethod
98
+ fun destroySpeech(cb: Callback) {
99
+ stt?.destroySpeech()
100
+ stt = null
101
+ cb.invoke(false)
102
+ }
103
+
104
+ @ReactMethod
105
+ fun isSpeechAvailable(p: Promise) {
106
+ STT.isSpeechAvailable(rc) { ok -> p.resolve(ok) }
107
+ }
108
+
109
+ @ReactMethod
110
+ fun isRecognizing(cb: Callback) {
111
+ cb.invoke(stt?.isRecognizing() == true)
112
+ }
113
+
114
+ // --- SpeechRecognitionLite pause/unpause (counter-based) ---
115
+
116
+ @ReactMethod
117
+ fun pauseSpeechRecognitionLite(cb: Callback) {
118
+ // Match iOS: no-op if STT isn't initialized yet (avoid JS error spam).
119
+ if (stt == null) {
120
+ cb.invoke(true)
121
+ return
122
+ }
123
+ stt?.pauseSpeechRecognitionLite()
124
+ cb.invoke(true)
125
+ }
126
+
127
+ @ReactMethod
128
+ fun unPauseSpeechRecognitionLite(times: Double, cb: Callback) {
129
+ // Match iOS: no-op if STT isn't initialized yet (avoid JS error spam).
130
+ if (stt == null) {
131
+ cb.invoke(true)
132
+ return
133
+ }
134
+
135
+ // JS passes number; keep it simple and clamp
136
+ val t = times.toInt()
137
+ stt?.unPauseSpeechRecognitionLite(t)
138
+ cb.invoke(true)
139
+ }
140
+
141
+ @ReactMethod
142
+ fun pauseMicrophone(cb: Callback) {
143
+ ensure().pauseMicrophone()
144
+ cb.invoke(false)
145
+ }
146
+
147
+ @ReactMethod
148
+ fun unPauseMicrophone(cb: Callback) {
149
+ ensure().unPauseMicrophone()
150
+ cb.invoke(false)
151
+ }
152
+
153
+ /** Start MIC+VAD remote capture that emits a single WAV via onNewSpeechWAV */
154
+ @ReactMethod
155
+ fun startRemoteSpeech(cb: Callback) {
156
+ ensure().startRemoteSpeech()
157
+ cb.invoke(false)
158
+ }
159
+
160
+ // ===== Events -> JS =====
161
+
162
+ override fun onSpeechStart() {
163
+ val m = Arguments.createMap().apply { putBoolean("error", false) }
164
+ send("onSpeechStart", m)
165
+ }
166
+
167
+ override fun onSpeechRecognized() {
168
+ val m = Arguments.createMap().apply { putBoolean("error", false) }
169
+ send("onSpeechRecognized", m)
170
+ }
171
+
172
+ override fun onSpeechEnd() {
173
+ send("onSpeechEnd", null)
174
+ }
175
+
176
+ override fun onSpeechError(code: Int, message: String) {
177
+ val e = Arguments.createMap().apply {
178
+ putString("message", message)
179
+ putDouble("code", code.toDouble())
180
+ }
181
+ val m = Arguments.createMap().apply { putMap("error", e) }
182
+ send("onSpeechError", m)
183
+ }
184
+
185
+ override fun onSpeechResults(best: String, all: List<String>) {
186
+ val arr = Arguments.createArray().apply { all.forEach { pushString(it) } }
187
+ val m = Arguments.createMap().apply { putArray("value", arr) }
188
+ send("onSpeechResults", m)
189
+ }
190
+
191
+ override fun onSpeechPartialResults(list: List<String>) {
192
+ val arr = Arguments.createArray().apply { list.forEach { pushString(it) } }
193
+ val m = Arguments.createMap().apply { putArray("value", arr) }
194
+ send("onSpeechPartialResults", m)
195
+ }
196
+
197
+ override fun onSpeechVolumeChanged(value: Float) {
198
+ val m = Arguments.createMap().apply { putDouble("value", value.toDouble()) }
199
+ send("onSpeechVolumeChanged", m)
200
+ }
201
+
202
+ /** Forward the saved WAV file path to JS */
203
+ override fun onNewSpeechWAV(filePath: String) {
204
+ val m = Arguments.createMap().apply { putString("path", filePath) }
205
+ send("onNewSpeechWAV", m)
206
+ }
207
+
208
+ }