react-native-davoice-tts 1.0.52 → 1.0.53
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/java/com/davoice/tts/rn/DaVoiceTTSBridge.java +19 -10
- package/package.json +1 -1
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
7319a004de8f53e8f3650b376f00e4f3 tts-1.0.0.aar
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
6135b0933aedf843a8967a0889e34ff8b2ae2386 tts-1.0.0.aar
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
// android/src/main/java/com/davoice/tts/rn/DaVoiceTTSBridge.java
|
|
1
2
|
package com.davoice.tts.rn;
|
|
2
3
|
|
|
3
|
-
import androidx.annotation.Nullable;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
4
5
|
import com.facebook.react.bridge.Promise;
|
|
5
6
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
6
7
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
7
8
|
import com.facebook.react.bridge.ReactMethod;
|
|
8
9
|
import com.facebook.react.bridge.ReadableMap;
|
|
9
|
-
import com.facebook.react.bridge.WritableMap;
|
|
10
|
-
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
10
|
+
import com.facebook.react.bridge.WritableMap;
|
|
11
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
11
12
|
|
|
12
|
-
import com.davoice.tts.DaVoiceTTSInterface;
|
|
13
|
+
import com.davoice.tts.DaVoiceTTSInterface;
|
|
13
14
|
|
|
14
15
|
public class DaVoiceTTSBridge extends ReactContextBaseJavaModule {
|
|
15
16
|
|
|
@@ -23,9 +24,7 @@ public class DaVoiceTTSBridge extends ReactContextBaseJavaModule {
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
@Override
|
|
26
|
-
public String getName() {
|
|
27
|
-
return "DaVoiceTTSBridge";
|
|
28
|
-
}
|
|
27
|
+
public String getName() { return "DaVoiceTTSBridge"; }
|
|
29
28
|
|
|
30
29
|
private void sendEvent(String name, @Nullable WritableMap params) {
|
|
31
30
|
reactCtx.runOnUiQueueThread(() ->
|
|
@@ -44,10 +43,9 @@ public class DaVoiceTTSBridge extends ReactContextBaseJavaModule {
|
|
|
44
43
|
}
|
|
45
44
|
final String modelName = config.getString("model");
|
|
46
45
|
|
|
47
|
-
//
|
|
46
|
+
// fire RN event when the last utterance finishes
|
|
48
47
|
tts.setOnFinishedSpeakingListenerJava(() -> sendEvent("onFinishedSpeaking", null));
|
|
49
48
|
|
|
50
|
-
// 2) init
|
|
51
49
|
DaVoiceTTSInterface.Config cfg = new DaVoiceTTSInterface.Config(
|
|
52
50
|
modelName,
|
|
53
51
|
"en-US",
|
|
@@ -84,7 +82,18 @@ public class DaVoiceTTSBridge extends ReactContextBaseJavaModule {
|
|
|
84
82
|
}
|
|
85
83
|
}
|
|
86
84
|
|
|
87
|
-
|
|
85
|
+
@ReactMethod
|
|
86
|
+
public void destroy(Promise promise) {
|
|
87
|
+
try {
|
|
88
|
+
// stop & free native resources; after this, JS should create a fresh instance before use
|
|
89
|
+
tts.destroy();
|
|
90
|
+
promise.resolve(null);
|
|
91
|
+
} catch (Exception e) {
|
|
92
|
+
promise.reject("DestroyError", e.getMessage(), e);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// RN event API stubs (required by RN)
|
|
88
97
|
@ReactMethod public void addListener(String eventName) { /* no-op */ }
|
|
89
98
|
@ReactMethod public void removeListeners(double count) { /* no-op */ }
|
|
90
99
|
}
|