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
|
Binary file
|
package/app.plugin.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// app.plugin.js
|
|
2
|
+
const { withAndroidManifest, withProjectBuildGradle } = require('@expo/config-plugins');
|
|
3
|
+
|
|
4
|
+
function withReactNativeWakeword(config) {
|
|
5
|
+
//
|
|
6
|
+
// 1. Add necessary permissions to AndroidManifest (if needed).
|
|
7
|
+
// For example, if `react-native-wakeword` needs RECORD_AUDIO.
|
|
8
|
+
//
|
|
9
|
+
config = withAndroidManifest(config, (config) => {
|
|
10
|
+
const androidManifest = config.modResults;
|
|
11
|
+
|
|
12
|
+
// Ensure 'uses-permission' array exists
|
|
13
|
+
if (!androidManifest.manifest['uses-permission']) {
|
|
14
|
+
androidManifest.manifest['uses-permission'] = [];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const permissions = androidManifest.manifest['uses-permission'];
|
|
18
|
+
const hasRecordAudio = permissions.some(
|
|
19
|
+
(permission) => permission.$['android:name'] === 'android.permission.RECORD_AUDIO'
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
// Add RECORD_AUDIO permission if not present
|
|
23
|
+
if (!hasRecordAudio) {
|
|
24
|
+
permissions.push({ $: { 'android:name': 'android.permission.RECORD_AUDIO' } });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return config;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
//
|
|
31
|
+
// 2. Insert Maven repository or other Gradle config in the project's
|
|
32
|
+
// top-level build.gradle (only if your library requires custom artifacts).
|
|
33
|
+
//
|
|
34
|
+
config = withProjectBuildGradle(config, (config) => {
|
|
35
|
+
const buildGradle = config.modResults.contents;
|
|
36
|
+
|
|
37
|
+
// This snippet references a local "libs" folder inside your library package.
|
|
38
|
+
// Adjust the path if your artifacts are elsewhere or not needed.
|
|
39
|
+
const wakewordMaven = `
|
|
40
|
+
// react-native-wakeword added
|
|
41
|
+
maven { url("$rootDir/../node_modules/react-native-wakeword/libs") }
|
|
42
|
+
// End react-native-wakeword added
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
// Only add the snippet once
|
|
46
|
+
if (!buildGradle.includes('react-native-wakeword added')) {
|
|
47
|
+
config.modResults.contents = buildGradle.replace(
|
|
48
|
+
/repositories\s*{/,
|
|
49
|
+
`repositories {\n${wakewordMaven}`
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return config;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return config;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
module.exports = withReactNativeWakeword;
|
|
60
|
+
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// STTBridge.m
|
|
2
|
+
#import "STTBridge.h"
|
|
3
|
+
#import <React/RCTLog.h>
|
|
4
|
+
#import <React/RCTConvert.h>
|
|
5
|
+
#import <DaVoiceTTS/DaVoiceTTS-Swift.h> // correct for your single-module setup
|
|
6
|
+
|
|
7
|
+
@interface STTBridge () <STTDelegate>
|
|
8
|
+
@property (nonatomic, strong, nullable) STT *stt;
|
|
9
|
+
@property (nonatomic, assign) BOOL hasListeners;
|
|
10
|
+
@end
|
|
11
|
+
|
|
12
|
+
@implementation STTBridge
|
|
13
|
+
|
|
14
|
+
RCT_EXPORT_MODULE(STT)
|
|
15
|
+
|
|
16
|
+
+ (BOOL)requiresMainQueueSetup { return YES; }
|
|
17
|
+
|
|
18
|
+
- (NSArray<NSString *> *)supportedEvents {
|
|
19
|
+
return @[
|
|
20
|
+
@"onSpeechResults",
|
|
21
|
+
@"onSpeechStart",
|
|
22
|
+
@"onSpeechPartialResults",
|
|
23
|
+
@"onSpeechError",
|
|
24
|
+
@"onSpeechEnd",
|
|
25
|
+
@"onSpeechRecognized",
|
|
26
|
+
@"onSpeechVolumeChanged"
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
- (void)startObserving { self.hasListeners = YES; }
|
|
31
|
+
- (void)stopObserving { self.hasListeners = NO; }
|
|
32
|
+
- (dispatch_queue_t)methodQueue { return dispatch_get_main_queue(); }
|
|
33
|
+
|
|
34
|
+
- (void)dealloc {
|
|
35
|
+
if (_stt) {
|
|
36
|
+
[_stt destroySpeech:nil]; // or ^(BOOL ok){}
|
|
37
|
+
_stt = nil;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#pragma mark - STTDelegate
|
|
42
|
+
- (void)stt:(STT *)stt didEmitEvent:(NSString *)name body:(NSDictionary *)body {
|
|
43
|
+
if (!self.hasListeners) return;
|
|
44
|
+
[self sendEventWithName:name body:body ?: @{}];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
#pragma mark - Helpers
|
|
48
|
+
- (void)ensureSTT {
|
|
49
|
+
if (!self.stt) {
|
|
50
|
+
self.stt = [STT new];
|
|
51
|
+
self.stt.delegate = self;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
#pragma mark - API
|
|
56
|
+
RCT_EXPORT_METHOD(setLicense:(NSString *)licenseKey
|
|
57
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
58
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
59
|
+
{
|
|
60
|
+
if (licenseKey == nil || (id)licenseKey == [NSNull null] || licenseKey.length == 0) {
|
|
61
|
+
reject(@"invalid_args", @"Missing licenseKey", nil);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
[self ensureSTT];
|
|
66
|
+
BOOL ok = [self.stt setLicenseWithLicenseKey:licenseKey];
|
|
67
|
+
resolve(@(ok));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
RCT_EXPORT_METHOD(isLicenseValid:(NSString *)licenseKey
|
|
71
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
72
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
73
|
+
{
|
|
74
|
+
if (licenseKey == nil || (id)licenseKey == [NSNull null] || licenseKey.length == 0) {
|
|
75
|
+
reject(@"invalid_args", @"Missing licenseKey", nil);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
BOOL ok = [LicenseManager isLicenseValidWithLicenseKey:licenseKey];
|
|
80
|
+
resolve(@(ok));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
RCT_EXPORT_METHOD(startSpeech:(NSString *)locale
|
|
84
|
+
callback:(RCTResponseSenderBlock)callback)
|
|
85
|
+
{
|
|
86
|
+
[self ensureSTT];
|
|
87
|
+
[self.stt startSpeechWithLocaleStr:locale];
|
|
88
|
+
if (callback) callback(@[@(NO)]);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
RCT_EXPORT_METHOD(stopSpeech:(RCTResponseSenderBlock)callback)
|
|
92
|
+
{
|
|
93
|
+
if (!self.stt) { if (callback) callback(@[@(NO)]); return; }
|
|
94
|
+
[self.stt stopSpeech:^(BOOL ok) {
|
|
95
|
+
if (callback) callback(@[@(NO)]);
|
|
96
|
+
}];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
RCT_EXPORT_METHOD(cancelSpeech:(RCTResponseSenderBlock)callback)
|
|
100
|
+
{
|
|
101
|
+
if (!self.stt) { if (callback) callback(@[@(NO)]); return; }
|
|
102
|
+
[self.stt cancelSpeech:^(BOOL ok) {
|
|
103
|
+
if (callback) callback(@[@(NO)]);
|
|
104
|
+
}];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
RCT_EXPORT_METHOD(destroySpeech:(RCTResponseSenderBlock)callback)
|
|
108
|
+
{
|
|
109
|
+
if (self.stt) {
|
|
110
|
+
[self.stt destroySpeech:^(BOOL ok) {}];
|
|
111
|
+
self.stt = nil;
|
|
112
|
+
}
|
|
113
|
+
if (callback) callback(@[@(NO)]);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
RCT_EXPORT_METHOD(isSpeechAvailable:(RCTResponseSenderBlock)callback)
|
|
117
|
+
{
|
|
118
|
+
[self ensureSTT];
|
|
119
|
+
[self.stt isSpeechAvailable:^(BOOL ok){
|
|
120
|
+
if (callback) callback(@[@(ok ? 1 : 0), [NSNull null]]);
|
|
121
|
+
}];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
RCT_EXPORT_METHOD(isRecognizing:(RCTResponseSenderBlock)callback)
|
|
125
|
+
{
|
|
126
|
+
BOOL running = self.stt ? [self.stt isRecognizing] : NO;
|
|
127
|
+
if (callback) callback(@[@(running ? 1 : 0)]);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@end
|