react-native-davoice-tts 1.0.44 → 1.0.45
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/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 -1
- package/android/libs/com/davoice/tts/1.0.0/tts-1.0.0.aar.sha1 +1 -1
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/davoice/rn/DaVoicePackage.java +29 -0
- package/android/src/main/java/com/davoice/stt/rn/STTModule.kt +68 -0
- package/package.json +1 -1
- /package/android/src/main/java/com/davoice/tts/rn/{DaVoiceTTSPackage.java → DaVoiceTTSPackage.java_old_using_new_for_both_stt_and_tts} +0 -0
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
97cd542ddcf068525377dd654036865a tts-1.0.0.aar
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
2ae5c33daf7bed773b905089bd5169746bc670eb tts-1.0.0.aar
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
|
|
7
7
|
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
|
8
8
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>
|
|
9
|
+
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
|
9
10
|
|
|
10
11
|
</manifest>
|
|
11
12
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package com.davoice.rn;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage;
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
5
|
+
import com.facebook.react.bridge.NativeModule;
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
7
|
+
|
|
8
|
+
import java.util.Collections;
|
|
9
|
+
import java.util.ArrayList;
|
|
10
|
+
import java.util.List;
|
|
11
|
+
|
|
12
|
+
import com.davoice.tts.rn.DaVoiceTTSBridge;
|
|
13
|
+
import com.davoice.stt.rn.STTModule;
|
|
14
|
+
|
|
15
|
+
public class DaVoicePackage implements ReactPackage {
|
|
16
|
+
|
|
17
|
+
@Override
|
|
18
|
+
public List<NativeModule> createNativeModules(ReactApplicationContext rc) {
|
|
19
|
+
List<NativeModule> modules = new ArrayList<>();
|
|
20
|
+
modules.add(new DaVoiceTTSBridge(rc)); // "DaVoiceTTSBridge"
|
|
21
|
+
modules.add(new STTModule(rc)); // "STT"
|
|
22
|
+
return modules;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@Override
|
|
26
|
+
public List<ViewManager> createViewManagers(ReactApplicationContext rc) {
|
|
27
|
+
return Collections.emptyList();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
|
|
9
|
+
@ReactModule(name = STTModule.NAME)
|
|
10
|
+
class STTModule(private val rc: ReactApplicationContext)
|
|
11
|
+
: ReactContextBaseJavaModule(rc), STTDelegate {
|
|
12
|
+
|
|
13
|
+
companion object { const val NAME = "STT" }
|
|
14
|
+
|
|
15
|
+
private var stt: STT? = null
|
|
16
|
+
|
|
17
|
+
override fun getName() = NAME
|
|
18
|
+
|
|
19
|
+
// RN event emitter stubs
|
|
20
|
+
@ReactMethod fun addListener(eventName: String) {}
|
|
21
|
+
@ReactMethod fun removeListeners(count: Double) {}
|
|
22
|
+
|
|
23
|
+
private fun send(name: String, body: WritableMap? = null) {
|
|
24
|
+
rc.runOnUiQueueThread {
|
|
25
|
+
rc.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
26
|
+
.emit(name, body)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private fun ensure(): STT {
|
|
31
|
+
if (stt == null) {
|
|
32
|
+
stt = STT(rc.applicationContext, continuous = true).also { it.delegate = this }
|
|
33
|
+
}
|
|
34
|
+
return stt!!
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// JS API
|
|
38
|
+
@ReactMethod fun startSpeech(locale: String?, cb: Callback) { ensure().startSpeech(locale); cb.invoke(false) }
|
|
39
|
+
@ReactMethod fun stopSpeech(cb: Callback) { stt?.stopSpeech(); cb.invoke(false) }
|
|
40
|
+
@ReactMethod fun cancelSpeech(cb: Callback) { stt?.cancelSpeech(); cb.invoke(false) }
|
|
41
|
+
@ReactMethod fun destroySpeech(cb: Callback) { stt?.destroySpeech(); stt = null; cb.invoke(false) }
|
|
42
|
+
@ReactMethod fun isSpeechAvailable(p: Promise) { STT.isSpeechAvailable(rc) { ok -> p.resolve(ok) } }
|
|
43
|
+
@ReactMethod fun isRecognizing(cb: Callback) { cb.invoke(stt?.isRecognizing() == true) }
|
|
44
|
+
|
|
45
|
+
// Events -> JS
|
|
46
|
+
override fun onSpeechStart() { val m=Arguments.createMap(); m.putBoolean("error",false); send("onSpeechStart", m) }
|
|
47
|
+
override fun onSpeechRecognized() { val m=Arguments.createMap(); m.putBoolean("error",false); send("onSpeechRecognized", m) }
|
|
48
|
+
override fun onSpeechEnd() { send("onSpeechEnd", null) }
|
|
49
|
+
override fun onSpeechError(code:Int, msg:String) {
|
|
50
|
+
val e=Arguments.createMap().apply{ putString("message", msg); putDouble("code", code.toDouble()) }
|
|
51
|
+
val m=Arguments.createMap().apply{ putMap("error", e) }
|
|
52
|
+
send("onSpeechError", m)
|
|
53
|
+
}
|
|
54
|
+
override fun onSpeechResults(best:String, all:List<String>) {
|
|
55
|
+
val arr=Arguments.createArray().apply{ all.forEach{ pushString(it) } }
|
|
56
|
+
val m=Arguments.createMap().apply{ putArray("value", arr) }
|
|
57
|
+
send("onSpeechResults", m)
|
|
58
|
+
}
|
|
59
|
+
override fun onSpeechPartialResults(list: List<String>) {
|
|
60
|
+
val arr=Arguments.createArray().apply{ list.forEach{ pushString(it) } }
|
|
61
|
+
val m=Arguments.createMap().apply{ putArray("value", arr) }
|
|
62
|
+
send("onSpeechPartialResults", m)
|
|
63
|
+
}
|
|
64
|
+
override fun onSpeechVolumeChanged(value: Float) {
|
|
65
|
+
val m=Arguments.createMap().apply{ putDouble("value", value.toDouble()) }
|
|
66
|
+
send("onSpeechVolumeChanged", m)
|
|
67
|
+
}
|
|
68
|
+
}
|
package/package.json
CHANGED