react-native-davoice-tts 1.0.271 → 1.0.272
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/TTSRNBridge.podspec
CHANGED
|
@@ -2,7 +2,7 @@ require 'json'
|
|
|
2
2
|
|
|
3
3
|
Pod::Spec.new do |s|
|
|
4
4
|
s.name = "TTSRNBridge"
|
|
5
|
-
s.version = "1.0.
|
|
5
|
+
s.version = "1.0.145" # Update to your package version
|
|
6
6
|
s.summary = "TTS for React Native."
|
|
7
7
|
s.description = <<-DESC
|
|
8
8
|
A React Native module for tts .
|
|
@@ -53,88 +53,89 @@ public class DaVoiceTTSBridge extends ReactContextBaseJavaModule {
|
|
|
53
53
|
|
|
54
54
|
@ReactMethod
|
|
55
55
|
public void initTTS(ReadableMap config, Promise promise) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
56
|
+
// DEBUG CODE
|
|
57
|
+
// try {
|
|
58
|
+
// final String fileName = config.getString("model");
|
|
59
|
+
// // Basic input debug
|
|
60
|
+
// Log.i(TAG, "ASSETDBG model raw input='" + fileName + "'");
|
|
61
|
+
// final String pkg = reactCtx.getPackageName();
|
|
62
|
+
// Log.i(TAG, "ASSETDBG packageName=" + pkg);
|
|
63
|
+
// // RN sometimes passes "assets_xxx" (no extension). Print normalized variants.
|
|
64
|
+
// final String[] candidates = new String[] {
|
|
65
|
+
// fileName,
|
|
66
|
+
// fileName + ".mp3",
|
|
67
|
+
// fileName + ".wav",
|
|
68
|
+
// fileName + ".dm",
|
|
69
|
+
// fileName + ".onnx",
|
|
70
|
+
// fileName + ".json",
|
|
71
|
+
// };
|
|
72
|
+
// Log.i(TAG, "ASSETDBG candidates=" + java.util.Arrays.toString(candidates));
|
|
73
|
+
|
|
74
|
+
// int res =
|
|
75
|
+
// reactCtx.getResources().getIdentifier(fileName, "raw", pkg);
|
|
76
|
+
|
|
77
|
+
// if (res != 0) {
|
|
78
|
+
// Log.i(TAG, "ASSETDBG res!=0" + res);
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
} catch (Exception e) {
|
|
136
|
-
|
|
137
|
-
}
|
|
80
|
+
// android.content.res.AssetFileDescriptor afd = reactCtx.getResources().openRawResourceFd(res);
|
|
81
|
+
// Log.i(TAG, "ASSETDBG res!=0 afd == " + afd);
|
|
82
|
+
// afd.close();
|
|
83
|
+
// }
|
|
84
|
+
// else {
|
|
85
|
+
// Log.i(TAG, "ASSETDBG res==0" + res);
|
|
86
|
+
// }
|
|
87
|
+
|
|
88
|
+
// // Now the important part: res/raw identifier lookup (this is what RN-Sound relies on)
|
|
89
|
+
// for (String name : candidates) {
|
|
90
|
+
// try {
|
|
91
|
+
// int resId = reactCtx.getResources().getIdentifier(name, "raw", pkg);
|
|
92
|
+
// Log.i(TAG, "ASSETDBG getIdentifier(name='" + name + "', type='raw') => resId=" + resId);
|
|
93
|
+
|
|
94
|
+
// if (resId != 0) {
|
|
95
|
+
// // Print extra details about the resource
|
|
96
|
+
// try {
|
|
97
|
+
// String entry = reactCtx.getResources().getResourceEntryName(resId);
|
|
98
|
+
// String type = reactCtx.getResources().getResourceTypeName(resId);
|
|
99
|
+
// String full = reactCtx.getResources().getResourceName(resId);
|
|
100
|
+
// Log.i(TAG, "ASSETDBG resource: entry=" + entry + " type=" + type + " full=" + full);
|
|
101
|
+
// } catch (Exception ignored) {
|
|
102
|
+
// Log.i(TAG, "ASSETDBG resource name lookup failed (non-fatal) resId=" + resId);
|
|
103
|
+
// }
|
|
104
|
+
|
|
105
|
+
// // Try openRawResourceFd (works for non-compressed raw)
|
|
106
|
+
// try {
|
|
107
|
+
// android.content.res.AssetFileDescriptor afd =
|
|
108
|
+
// reactCtx.getResources().openRawResourceFd(resId);
|
|
109
|
+
|
|
110
|
+
// if (afd == null) {
|
|
111
|
+
// Log.w(TAG, "ASSETDBG openRawResourceFd returned NULL for resId=" + resId + " (likely compressed) -> will try openRawResource()");
|
|
112
|
+
// } else {
|
|
113
|
+
// Log.i(TAG, "ASSETDBG openRawResourceFd OK resId=" + resId
|
|
114
|
+
// + " startOffset=" + afd.getStartOffset()
|
|
115
|
+
// + " length=" + afd.getLength()
|
|
116
|
+
// + " fdValid=" + (afd.getFileDescriptor() != null));
|
|
117
|
+
// afd.close();
|
|
118
|
+
// }
|
|
119
|
+
// } catch (Exception e) {
|
|
120
|
+
// Log.w(TAG, "ASSETDBG openRawResourceFd FAILED resId=" + resId + " err=" + e.getMessage(), e);
|
|
121
|
+
// }
|
|
122
|
+
|
|
123
|
+
// // Always try openRawResource() too (works even if compressed)
|
|
124
|
+
// try (java.io.InputStream in = reactCtx.getResources().openRawResource(resId)) {
|
|
125
|
+
// byte[] head = new byte[32];
|
|
126
|
+
// int n = in.read(head);
|
|
127
|
+
// Log.i(TAG, "ASSETDBG openRawResource OK resId=" + resId + " firstBytesRead=" + n);
|
|
128
|
+
// } catch (Exception e) {
|
|
129
|
+
// Log.w(TAG, "ASSETDBG openRawResource FAILED resId=" + resId + " err=" + e.getMessage(), e);
|
|
130
|
+
// }
|
|
131
|
+
// }
|
|
132
|
+
// } catch (Exception e) {
|
|
133
|
+
// Log.w(TAG, "ASSETDBG getIdentifier loop exception name='" + name + "' err=" + e.getMessage(), e);
|
|
134
|
+
// }
|
|
135
|
+
// }
|
|
136
|
+
// } catch (Exception e) {
|
|
137
|
+
// Log.w(TAG, "ASSETDBG list assets failed: " + e.getMessage());
|
|
138
|
+
// }
|
|
138
139
|
try {
|
|
139
140
|
if (config == null || !config.hasKey("model") || config.isNull("model")) {
|
|
140
141
|
promise.reject("invalid_config", "Missing required 'model' key");
|