react-native-davoice-tts 1.0.41 → 1.0.43
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 +6 -1
- package/android/src/main/java/com/davoice/tts/rn/DaVoiceTTSBridge.java +14 -27
- package/ios/STTRNBridge/STTBridge.h +7 -0
- package/ios/STTRNBridge/STTBridge.m +109 -0
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/Info.plist +5 -5
- 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 +27 -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 +1829 -934
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios.private.swiftinterface +27 -4
- 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 +27 -4
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64/DavoiceTTS.framework/Modules/module.modulemap +0 -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 +54 -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 +1829 -934
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +27 -4
- 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 +27 -4
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.abi.json +1829 -934
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/DavoiceTTS.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +27 -4
- 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 +27 -4
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/Modules/module.modulemap +0 -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 +28 -28
- package/ios/TTSRNBridge/DavoiceTTS.xcframework/ios-arm64_x86_64-simulator/DavoiceTTS.framework/_CodeSignature/CodeSignature +0 -0
- package/package.json +2 -1
- package/stt/index.d.ts +52 -0
- package/stt/index.ts +202 -0
package/TTSRNBridge.podspec
CHANGED
|
@@ -16,7 +16,12 @@ Pod::Spec.new do |s|
|
|
|
16
16
|
|
|
17
17
|
# s.source_files = "ios/*.{h,m,mm,swift}"
|
|
18
18
|
# s.resources = "ios/TTSRNBridge/models/*"
|
|
19
|
-
s.source_files = 'ios/TTSRNBridge/DaVoiceTTSBridge.m', 'ios/TTSRNBridge/DaVoiceTTSBridge.h'
|
|
19
|
+
# s.source_files = 'ios/TTSRNBridge/DaVoiceTTSBridge.m', 'ios/TTSRNBridge/DaVoiceTTSBridge.h'
|
|
20
|
+
s.source_files = [
|
|
21
|
+
"ios/TTSRNBridge/DaVoiceTTSBridge.{h,m}",
|
|
22
|
+
"ios/STTRNBridge/STTBridge.{h,m}",
|
|
23
|
+
"ios/STT/**/*.{swift}"
|
|
24
|
+
]
|
|
20
25
|
|
|
21
26
|
#s.static_framework = true
|
|
22
27
|
# Add your static libraries explicitly as vendored_libraries
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
//DaVoiceTTSBridge.java
|
|
2
1
|
package com.davoice.tts.rn;
|
|
3
2
|
|
|
4
|
-
import
|
|
3
|
+
import androidx.annotation.Nullable; // ✅ add
|
|
5
4
|
import com.facebook.react.bridge.Promise;
|
|
6
5
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
6
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
8
7
|
import com.facebook.react.bridge.ReactMethod;
|
|
9
8
|
import com.facebook.react.bridge.ReadableMap;
|
|
9
|
+
import com.facebook.react.bridge.WritableMap; // ✅ add
|
|
10
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule; // ✅ add
|
|
11
|
+
|
|
12
|
+
import com.davoice.tts.DaVoiceTTSInterface; // keep
|
|
10
13
|
|
|
11
|
-
/**
|
|
12
|
-
* Minimal RN bridge:
|
|
13
|
-
* NativeModules.DaVoiceTTSBridge.initTTS(modelName)
|
|
14
|
-
* NativeModules.DaVoiceTTSBridge.speak(text, speakerId)
|
|
15
|
-
* NativeModules.DaVoiceTTSBridge.stopSpeaking()
|
|
16
|
-
* // JS listens via new NativeEventEmitter(DaVoiceTTSBridge).addListener('onFinishedSpeaking', ...)
|
|
17
|
-
* Everything else is handled by DaVoiceTTSInterface.
|
|
18
|
-
*/
|
|
19
14
|
public class DaVoiceTTSBridge extends ReactContextBaseJavaModule {
|
|
20
15
|
|
|
21
16
|
private final DaVoiceTTSInterface tts;
|
|
@@ -32,10 +27,7 @@ public class DaVoiceTTSBridge extends ReactContextBaseJavaModule {
|
|
|
32
27
|
return "DaVoiceTTSBridge";
|
|
33
28
|
}
|
|
34
29
|
|
|
35
|
-
// ---- helpers ----
|
|
36
|
-
|
|
37
30
|
private void sendEvent(String name, @Nullable WritableMap params) {
|
|
38
|
-
// Emit on UI thread to be safe
|
|
39
31
|
reactCtx.runOnUiQueueThread(() ->
|
|
40
32
|
reactCtx
|
|
41
33
|
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
@@ -43,8 +35,6 @@ public class DaVoiceTTSBridge extends ReactContextBaseJavaModule {
|
|
|
43
35
|
);
|
|
44
36
|
}
|
|
45
37
|
|
|
46
|
-
// ---- API ----
|
|
47
|
-
|
|
48
38
|
@ReactMethod
|
|
49
39
|
public void initTTS(ReadableMap config, Promise promise) {
|
|
50
40
|
try {
|
|
@@ -53,19 +43,16 @@ public class DaVoiceTTSBridge extends ReactContextBaseJavaModule {
|
|
|
53
43
|
return;
|
|
54
44
|
}
|
|
55
45
|
final String modelName = config.getString("model");
|
|
56
|
-
// AAR handles the rest (tokens=<model>.json, espeak dir, etc.)
|
|
57
|
-
DaVoiceTTSInterface.Config cfg = new DaVoiceTTSInterface.Config(
|
|
58
|
-
modelName, // e.g. "model.onnx"
|
|
59
|
-
"en-US", // default voice (ignored/overridden by AAR if needed)
|
|
60
|
-
"phonemes_dir" // asset dir name (AAR copies recursively)
|
|
61
|
-
);
|
|
62
46
|
|
|
63
|
-
//
|
|
64
|
-
tts.setOnFinishedSpeakingListenerJava(() ->
|
|
65
|
-
// no payload required; JS just needs the signal
|
|
66
|
-
sendEvent("onFinishedSpeaking", null);
|
|
67
|
-
});
|
|
47
|
+
// 1) attach listener (works even if called before init)
|
|
48
|
+
tts.setOnFinishedSpeakingListenerJava(() -> sendEvent("onFinishedSpeaking", null));
|
|
68
49
|
|
|
50
|
+
// 2) init
|
|
51
|
+
DaVoiceTTSInterface.Config cfg = new DaVoiceTTSInterface.Config(
|
|
52
|
+
modelName,
|
|
53
|
+
"en-US",
|
|
54
|
+
"phonemes_dir"
|
|
55
|
+
);
|
|
69
56
|
boolean ok = tts.initTTS(cfg);
|
|
70
57
|
if (!ok) {
|
|
71
58
|
promise.reject("InitFailed", "Engine/TTS init failed");
|
|
@@ -97,7 +84,7 @@ public class DaVoiceTTSBridge extends ReactContextBaseJavaModule {
|
|
|
97
84
|
}
|
|
98
85
|
}
|
|
99
86
|
|
|
100
|
-
// RN event API stubs
|
|
87
|
+
// RN event API stubs
|
|
101
88
|
@ReactMethod public void addListener(String eventName) { /* no-op */ }
|
|
102
89
|
@ReactMethod public void removeListeners(double count) { /* no-op */ }
|
|
103
90
|
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#import "STTBridge.h"
|
|
2
|
+
#import <React/RCTLog.h>
|
|
3
|
+
#import <React/RCTConvert.h>
|
|
4
|
+
|
|
5
|
+
// Import the generated Swift header for your target.
|
|
6
|
+
// Replace "YourTargetName-Swift.h" with your actual target name.
|
|
7
|
+
#import "YourTargetName-Swift.h"
|
|
8
|
+
|
|
9
|
+
@interface STTBridge () <STTDelegate>
|
|
10
|
+
@property (nonatomic, strong, nullable) STT *stt;
|
|
11
|
+
@property (nonatomic, assign) BOOL hasListeners;
|
|
12
|
+
@end
|
|
13
|
+
|
|
14
|
+
@implementation STTBridge
|
|
15
|
+
|
|
16
|
+
RCT_EXPORT_MODULE(STT) // matches NativeModules.STT in stt/index.ts
|
|
17
|
+
|
|
18
|
+
+ (BOOL)requiresMainQueueSetup { return YES; }
|
|
19
|
+
|
|
20
|
+
- (NSArray<NSString *> *)supportedEvents
|
|
21
|
+
{
|
|
22
|
+
// Keep event names EXACTLY as the native STT emits.
|
|
23
|
+
return @[
|
|
24
|
+
@"onSpeechResults",
|
|
25
|
+
@"onSpeechStart",
|
|
26
|
+
@"onSpeechPartialResults",
|
|
27
|
+
@"onSpeechError",
|
|
28
|
+
@"onSpeechEnd",
|
|
29
|
+
@"onSpeechRecognized",
|
|
30
|
+
@"onSpeechVolumeChanged"
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
- (void)startObserving { self.hasListeners = YES; }
|
|
35
|
+
- (void)stopObserving { self.hasListeners = NO; }
|
|
36
|
+
- (dispatch_queue_t)methodQueue { return dispatch_get_main_queue(); }
|
|
37
|
+
|
|
38
|
+
- (void)dealloc {
|
|
39
|
+
// Tear down safely
|
|
40
|
+
[self.stt destroySpeech:^(id _){}]; // optional; or call a direct Swift method if you exposed one
|
|
41
|
+
self.stt = nil;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#pragma mark - STTDelegate (from Swift)
|
|
45
|
+
- (void)stt:(STT *)stt didEmitEvent:(NSString *)name body:(NSDictionary *)body
|
|
46
|
+
{
|
|
47
|
+
if (!self.hasListeners) return;
|
|
48
|
+
[self sendEventWithName:name body:body ?: @{}];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
#pragma mark - Helpers
|
|
52
|
+
- (void)ensureSTT {
|
|
53
|
+
if (!self.stt) {
|
|
54
|
+
self.stt = [STT new];
|
|
55
|
+
self.stt.delegate = self;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
#pragma mark - API (match your JS contract)
|
|
60
|
+
|
|
61
|
+
RCT_EXPORT_METHOD(startSpeech:(NSString *)locale
|
|
62
|
+
callback:(RCTResponseSenderBlock)callback)
|
|
63
|
+
{
|
|
64
|
+
[self ensureSTT];
|
|
65
|
+
[self.stt startSpeechWithLocaleStr:locale];
|
|
66
|
+
// parity with old Voice bridge: immediately callback with "false"
|
|
67
|
+
if (callback) callback(@[@(NO)]);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
RCT_EXPORT_METHOD(stopSpeech:(RCTResponseSenderBlock)callback)
|
|
71
|
+
{
|
|
72
|
+
if (!self.stt) { if (callback) callback(@[@(NO)]); return; }
|
|
73
|
+
[self.stt stopSpeech:^(BOOL _){}];
|
|
74
|
+
if (callback) callback(@[@(NO)]);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
RCT_EXPORT_METHOD(cancelSpeech:(RCTResponseSenderBlock)callback)
|
|
78
|
+
{
|
|
79
|
+
if (!self.stt) { if (callback) callback(@[@(NO)]); return; }
|
|
80
|
+
[self.stt cancelSpeech:^(BOOL _){}];
|
|
81
|
+
if (callback) callback(@[@(NO)]);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
RCT_EXPORT_METHOD(destroySpeech:(RCTResponseSenderBlock)callback)
|
|
85
|
+
{
|
|
86
|
+
if (self.stt) {
|
|
87
|
+
[self.stt destroySpeech:^(BOOL _){}];
|
|
88
|
+
self.stt = nil;
|
|
89
|
+
}
|
|
90
|
+
if (callback) callback(@[@(NO)]);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
RCT_EXPORT_METHOD(isSpeechAvailable:(RCTResponseSenderBlock)callback)
|
|
94
|
+
{
|
|
95
|
+
[STT new]; // ensures class is loaded; optional
|
|
96
|
+
// Call the Swift closure-based API
|
|
97
|
+
STT *tmp = self.stt ?: [STT new];
|
|
98
|
+
[tmp isSpeechAvailable:^(BOOL ok){
|
|
99
|
+
if (callback) callback(@[@(ok ? 1 : 0), [NSNull null]]);
|
|
100
|
+
}];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
RCT_EXPORT_METHOD(isRecognizing:(RCTResponseSenderBlock)callback)
|
|
104
|
+
{
|
|
105
|
+
BOOL running = self.stt ? [self.stt isRecognizing] : NO;
|
|
106
|
+
if (callback) callback(@[@(running ? 1 : 0)]);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@end
|
|
@@ -8,32 +8,32 @@
|
|
|
8
8
|
<key>BinaryPath</key>
|
|
9
9
|
<string>DavoiceTTS.framework/DavoiceTTS</string>
|
|
10
10
|
<key>LibraryIdentifier</key>
|
|
11
|
-
<string>ios-
|
|
11
|
+
<string>ios-arm64</string>
|
|
12
12
|
<key>LibraryPath</key>
|
|
13
13
|
<string>DavoiceTTS.framework</string>
|
|
14
14
|
<key>SupportedArchitectures</key>
|
|
15
15
|
<array>
|
|
16
16
|
<string>arm64</string>
|
|
17
|
-
<string>x86_64</string>
|
|
18
17
|
</array>
|
|
19
18
|
<key>SupportedPlatform</key>
|
|
20
19
|
<string>ios</string>
|
|
21
|
-
<key>SupportedPlatformVariant</key>
|
|
22
|
-
<string>simulator</string>
|
|
23
20
|
</dict>
|
|
24
21
|
<dict>
|
|
25
22
|
<key>BinaryPath</key>
|
|
26
23
|
<string>DavoiceTTS.framework/DavoiceTTS</string>
|
|
27
24
|
<key>LibraryIdentifier</key>
|
|
28
|
-
<string>ios-
|
|
25
|
+
<string>ios-arm64_x86_64-simulator</string>
|
|
29
26
|
<key>LibraryPath</key>
|
|
30
27
|
<string>DavoiceTTS.framework</string>
|
|
31
28
|
<key>SupportedArchitectures</key>
|
|
32
29
|
<array>
|
|
33
30
|
<string>arm64</string>
|
|
31
|
+
<string>x86_64</string>
|
|
34
32
|
</array>
|
|
35
33
|
<key>SupportedPlatform</key>
|
|
36
34
|
<string>ios</string>
|
|
35
|
+
<key>SupportedPlatformVariant</key>
|
|
36
|
+
<string>simulator</string>
|
|
37
37
|
</dict>
|
|
38
38
|
</array>
|
|
39
39
|
<key>CFBundlePackageType</key>
|
|
Binary file
|
|
@@ -282,7 +282,9 @@ typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
|
|
|
282
282
|
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
|
|
283
283
|
#endif
|
|
284
284
|
@import AVFAudio;
|
|
285
|
+
@import Foundation;
|
|
285
286
|
@import ObjectiveC;
|
|
287
|
+
@import Speech;
|
|
286
288
|
#endif
|
|
287
289
|
|
|
288
290
|
#endif
|
|
@@ -324,6 +326,31 @@ SWIFT_CLASS("_TtC10DavoiceTTS10DaVoiceTTS")
|
|
|
324
326
|
+ (nonnull instancetype)new SWIFT_UNAVAILABLE_MSG("-init is unavailable");
|
|
325
327
|
@end
|
|
326
328
|
|
|
329
|
+
@protocol STTDelegate;
|
|
330
|
+
@class SFSpeechRecognizer;
|
|
331
|
+
SWIFT_CLASS("_TtC10DavoiceTTS3STT")
|
|
332
|
+
@interface STT : NSObject <SFSpeechRecognizerDelegate>
|
|
333
|
+
@property (nonatomic, weak) id <STTDelegate> _Nullable delegate;
|
|
334
|
+
@property (nonatomic) BOOL continuous;
|
|
335
|
+
SWIFT_CLASS_PROPERTY(@property (nonatomic, class, readonly, copy) NSArray<NSString *> * _Nonnull supportedEvents;)
|
|
336
|
+
+ (NSArray<NSString *> * _Nonnull)supportedEvents SWIFT_WARN_UNUSED_RESULT;
|
|
337
|
+
- (void)isSpeechAvailable:(void (^ _Nonnull)(BOOL))completion;
|
|
338
|
+
- (BOOL)isRecognizing SWIFT_WARN_UNUSED_RESULT;
|
|
339
|
+
- (void)startSpeechWithLocaleStr:(NSString * _Nullable)localeStr;
|
|
340
|
+
- (void)stopSpeech:(void (^ _Nullable)(BOOL))completion;
|
|
341
|
+
- (void)cancelSpeech:(void (^ _Nullable)(BOOL))completion;
|
|
342
|
+
- (void)destroySpeech:(void (^ _Nullable)(BOOL))completion;
|
|
343
|
+
- (void)teardown;
|
|
344
|
+
- (void)teardown2;
|
|
345
|
+
- (void)speechRecognizer:(SFSpeechRecognizer * _Nonnull)speechRecognizer availabilityDidChange:(BOOL)available;
|
|
346
|
+
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
|
|
347
|
+
@end
|
|
348
|
+
|
|
349
|
+
SWIFT_PROTOCOL("_TtP10DavoiceTTS11STTDelegate_")
|
|
350
|
+
@protocol STTDelegate
|
|
351
|
+
- (void)stt:(STT * _Nonnull)stt didEmitEvent:(NSString * _Nonnull)name body:(NSDictionary<NSString *, id> * _Nullable)body;
|
|
352
|
+
@end
|
|
353
|
+
|
|
327
354
|
@class AVAudioPlayer;
|
|
328
355
|
SWIFT_CLASS("_TtC10DavoiceTTS15SwiftSoundQueue")
|
|
329
356
|
@interface SwiftSoundQueue : NSObject <AVAudioPlayerDelegate>
|