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.
- package/README.md +319 -0
- package/TTSRNBridge.podspec +38 -0
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build.gradle +47 -0
- package/android/libs/com/davoice/tts/1.0.0/tts-1.0.0.aar +0 -0
- package/android/libs/com/davoice/tts/1.0.0/tts-1.0.0.aar.md5 +1 -0
- package/android/libs/com/davoice/tts/1.0.0/tts-1.0.0.aar.sha1 +1 -0
- package/android/libs/com/davoice/tts/1.0.0/tts-1.0.0.pom +38 -0
- package/android/libs/com/davoice/tts/1.0.0/tts-1.0.0.pom.md5 +1 -0
- package/android/libs/com/davoice/tts/1.0.0/tts-1.0.0.pom.sha1 +1 -0
- package/android/settings.gradle +2 -0
- package/android/src/main/AndroidManifest.xml +14 -0
- package/android/src/main/java/com/davoice/rn/DaVoicePackage.java +29 -0
- package/android/src/main/java/com/davoice/stt/rn/STTModule.kt +208 -0
- package/android/src/main/java/com/davoice/tts/rn/DaVoiceTTSBridge.java +733 -0
- package/android/src/main/libs/MyLibrary-release.aar +0 -0
- package/app.plugin.js +60 -0
- package/ios/STTRNBridge/STTBridge.h +7 -0
- package/ios/STTRNBridge/STTBridge.m +130 -0
- package/ios/SpeechBridge/SpeechBridge.h +7 -0
- package/ios/SpeechBridge/SpeechBridge.m +761 -0
- package/ios/TTSRNBridge/DaVoiceTTSBridge.h +7 -0
- package/ios/TTSRNBridge/DaVoiceTTSBridge.m +177 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/Info.plist +44 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/DavoiceTTS +0 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Headers/DavoiceTTS-Swift.h +424 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Info.plist +0 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.abi.json +13253 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.private.swiftinterface +213 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.swiftinterface +213 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/module.modulemap +4 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/DavoiceTTS +0 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Headers/DavoiceTTS-Swift.h +844 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Info.plist +0 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.abi.json +13253 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +213 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.swiftinterface +213 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.abi.json +13253 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +213 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +213 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/module.modulemap +4 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeDirectory +0 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeRequirements +0 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeRequirements-1 +0 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeResources +282 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeSignature +0 -0
- package/ios/TTSRNBridge/libphonemes.a +0 -0
- package/ios/TTSRNBridge/libucd.a +0 -0
- package/package.json +46 -0
- package/react-native.config.js +10 -0
- package/speech/index.ts +1055 -0
- package/stt/index.d.ts +54 -0
- package/stt/index.ts +222 -0
- package/tts/DaVoiceTTSBridge.d.ts +18 -0
- package/tts/DaVoiceTTSBridge.js +71 -0
- package/tts/index.d.ts +3 -0
- 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
|
+
}
|