react-native-wakeword 1.1.34 → 1.1.39
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/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
- package/android/libs/com/davoice/keyworddetection/1.0.0/keyworddetection-1.0.0.aar +0 -0
- package/android/libs/com/davoice/keyworddetection/1.0.0/keyworddetection-1.0.0.aar.md5 +1 -1
- package/android/libs/com/davoice/keyworddetection/1.0.0/keyworddetection-1.0.0.aar.sha1 +1 -1
- package/android/src/main/AndroidManifest.xml +0 -4
- package/android/src/main/assets/{hey_lookdeep.onnx → hey_lookdeep.dm} +0 -0
- package/android/src/main/assets/{need_help_now.onnx → need_help_now.dm} +0 -0
- package/android/src/main/java/com/davoice/DaVoiceUnifiedPackage.java +29 -0
- package/android/src/main/java/com/davoice/keywordspotting/KeyWordRNBridge.java +112 -0
- package/android/src/main/java/com/davoice/speakeridrn/SpeakerIdRNBridge.java +588 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64/KeyWordDetection.framework/KeyWordDetection +0 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64/KeyWordDetection.framework/Modules/KeyWordDetection.swiftmodule/arm64-apple-ios.abi.json +406 -41
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64/KeyWordDetection.framework/Modules/KeyWordDetection.swiftmodule/arm64-apple-ios.private.swiftinterface +5 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64/KeyWordDetection.framework/Modules/KeyWordDetection.swiftmodule/arm64-apple-ios.swiftinterface +5 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/KeyWordDetection +0 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/Modules/KeyWordDetection.swiftmodule/arm64-apple-ios-simulator.abi.json +406 -41
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/Modules/KeyWordDetection.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +5 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/Modules/KeyWordDetection.swiftmodule/arm64-apple-ios-simulator.swiftinterface +5 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/Modules/KeyWordDetection.swiftmodule/x86_64-apple-ios-simulator.abi.json +406 -41
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/Modules/KeyWordDetection.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +5 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/Modules/KeyWordDetection.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +5 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/_CodeSignature/CodeDirectory +0 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/_CodeSignature/CodeRequirements-1 +0 -0
- package/ios/KeyWordRNBridge/KeyWordDetection.xcframework/ios-arm64_x86_64-simulator/KeyWordDetection.framework/_CodeSignature/CodeResources +24 -24
- package/package.json +3 -1
- package/react-native.config.js +10 -0
- package/speakerid/SpeakerIdRNBridge.d.ts +49 -0
- package/speakerid/SpeakerIdRNBridge.js +193 -0
- package/speakerid/index.d.ts +22 -0
- package/speakerid/index.js +28 -0
- package/speakerid/models/speaker_id.dm +0 -0
- package/wakewords/index.d.ts +8 -8
- package/android/src/main/assets/coca_cola_model_28_05052025.onnx +0 -0
- package/android/src/main/assets/embedding_model.onnx +0 -0
- package/android/src/main/assets/melspectrogram.onnx +0 -0
- package/android/src/main/assets/silero_vad.onnx +0 -0
- package/android/src/main/java/com/davoice/keywordspotting/KeyWordRNBridgePackage.java +0 -25
- package/wakewords/index.d.ts.chat_idiot +0 -2
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// swift-module-flags-ignorable: -no-verify-emitted-module-interface -interface-compiler-version 6.1.2
|
|
5
5
|
import AVFAudio
|
|
6
6
|
import AVFoundation
|
|
7
|
+
import Accelerate
|
|
7
8
|
import AudioToolbox
|
|
8
9
|
import CommonCrypto
|
|
9
10
|
import Foundation
|
|
@@ -125,6 +126,10 @@ public class AVAudioWrapper {
|
|
|
125
126
|
@objc public func stopVADListening()
|
|
126
127
|
@objc deinit
|
|
127
128
|
}
|
|
129
|
+
public typealias EngineSchedule = (_ url: Foundation.URL, _ onDone: @escaping () -> Swift.Void) -> Swift.Bool
|
|
130
|
+
public enum AudioPlaybackHook {
|
|
131
|
+
public static var engineScheduleFile: KeyWordDetection.EngineSchedule?
|
|
132
|
+
}
|
|
128
133
|
@_inheritsConvenienceInitializers @objc public class AudioSessionAndDuckingManager : ObjectiveC.NSObject {
|
|
129
134
|
@objc public static let shared: KeyWordDetection.AudioSessionAndDuckingManager
|
|
130
135
|
@objc public func initAudioSessAndDuckManage()
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// swift-module-flags-ignorable: -no-verify-emitted-module-interface -interface-compiler-version 6.1.2
|
|
5
5
|
import AVFAudio
|
|
6
6
|
import AVFoundation
|
|
7
|
+
import Accelerate
|
|
7
8
|
import AudioToolbox
|
|
8
9
|
import CommonCrypto
|
|
9
10
|
import Foundation
|
|
@@ -125,6 +126,10 @@ public class AVAudioWrapper {
|
|
|
125
126
|
@objc public func stopVADListening()
|
|
126
127
|
@objc deinit
|
|
127
128
|
}
|
|
129
|
+
public typealias EngineSchedule = (_ url: Foundation.URL, _ onDone: @escaping () -> Swift.Void) -> Swift.Bool
|
|
130
|
+
public enum AudioPlaybackHook {
|
|
131
|
+
public static var engineScheduleFile: KeyWordDetection.EngineSchedule?
|
|
132
|
+
}
|
|
128
133
|
@_inheritsConvenienceInitializers @objc public class AudioSessionAndDuckingManager : ObjectiveC.NSObject {
|
|
129
134
|
@objc public static let shared: KeyWordDetection.AudioSessionAndDuckingManager
|
|
130
135
|
@objc public func initAudioSessAndDuckManage()
|
|
Binary file
|
|
Binary file
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
</data>
|
|
19
19
|
<key>Modules/KeyWordDetection.swiftmodule/arm64-apple-ios-simulator.abi.json</key>
|
|
20
20
|
<data>
|
|
21
|
-
|
|
21
|
+
JhMksokD2PvOi2fUofC9nyq5TgY=
|
|
22
22
|
</data>
|
|
23
23
|
<key>Modules/KeyWordDetection.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface</key>
|
|
24
24
|
<data>
|
|
25
|
-
|
|
25
|
+
X0qX2XmPfcJij9X/8VvUDjWA4Ag=
|
|
26
26
|
</data>
|
|
27
27
|
<key>Modules/KeyWordDetection.swiftmodule/arm64-apple-ios-simulator.swiftdoc</key>
|
|
28
28
|
<data>
|
|
@@ -30,19 +30,19 @@
|
|
|
30
30
|
</data>
|
|
31
31
|
<key>Modules/KeyWordDetection.swiftmodule/arm64-apple-ios-simulator.swiftinterface</key>
|
|
32
32
|
<data>
|
|
33
|
-
|
|
33
|
+
X0qX2XmPfcJij9X/8VvUDjWA4Ag=
|
|
34
34
|
</data>
|
|
35
35
|
<key>Modules/KeyWordDetection.swiftmodule/arm64-apple-ios-simulator.swiftmodule</key>
|
|
36
36
|
<data>
|
|
37
|
-
|
|
37
|
+
BuufFQUpAoiYkD7Qjhqqc+sEQP8=
|
|
38
38
|
</data>
|
|
39
39
|
<key>Modules/KeyWordDetection.swiftmodule/x86_64-apple-ios-simulator.abi.json</key>
|
|
40
40
|
<data>
|
|
41
|
-
|
|
41
|
+
JhMksokD2PvOi2fUofC9nyq5TgY=
|
|
42
42
|
</data>
|
|
43
43
|
<key>Modules/KeyWordDetection.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface</key>
|
|
44
44
|
<data>
|
|
45
|
-
|
|
45
|
+
xsyExyernCKMOl0ZAOV+DZdFczw=
|
|
46
46
|
</data>
|
|
47
47
|
<key>Modules/KeyWordDetection.swiftmodule/x86_64-apple-ios-simulator.swiftdoc</key>
|
|
48
48
|
<data>
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
</data>
|
|
51
51
|
<key>Modules/KeyWordDetection.swiftmodule/x86_64-apple-ios-simulator.swiftinterface</key>
|
|
52
52
|
<data>
|
|
53
|
-
|
|
53
|
+
xsyExyernCKMOl0ZAOV+DZdFczw=
|
|
54
54
|
</data>
|
|
55
55
|
<key>Modules/KeyWordDetection.swiftmodule/x86_64-apple-ios-simulator.swiftmodule</key>
|
|
56
56
|
<data>
|
|
57
|
-
|
|
57
|
+
9imz6yhq5UDly3yr9jNA15FpHbM=
|
|
58
58
|
</data>
|
|
59
59
|
<key>Modules/module.modulemap</key>
|
|
60
60
|
<data>
|
|
@@ -89,22 +89,22 @@
|
|
|
89
89
|
<dict>
|
|
90
90
|
<key>hash</key>
|
|
91
91
|
<data>
|
|
92
|
-
|
|
92
|
+
JhMksokD2PvOi2fUofC9nyq5TgY=
|
|
93
93
|
</data>
|
|
94
94
|
<key>hash2</key>
|
|
95
95
|
<data>
|
|
96
|
-
|
|
96
|
+
ZO+SrkXCRrEOjQOKSOXT0AjlcPCYPO1NCOcbcGKtQJ0=
|
|
97
97
|
</data>
|
|
98
98
|
</dict>
|
|
99
99
|
<key>Modules/KeyWordDetection.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface</key>
|
|
100
100
|
<dict>
|
|
101
101
|
<key>hash</key>
|
|
102
102
|
<data>
|
|
103
|
-
|
|
103
|
+
X0qX2XmPfcJij9X/8VvUDjWA4Ag=
|
|
104
104
|
</data>
|
|
105
105
|
<key>hash2</key>
|
|
106
106
|
<data>
|
|
107
|
-
|
|
107
|
+
ngmtjB/6cpItHMGbQAosuPGYerHi28sLeSZPSiu4kgw=
|
|
108
108
|
</data>
|
|
109
109
|
</dict>
|
|
110
110
|
<key>Modules/KeyWordDetection.swiftmodule/arm64-apple-ios-simulator.swiftdoc</key>
|
|
@@ -122,44 +122,44 @@
|
|
|
122
122
|
<dict>
|
|
123
123
|
<key>hash</key>
|
|
124
124
|
<data>
|
|
125
|
-
|
|
125
|
+
X0qX2XmPfcJij9X/8VvUDjWA4Ag=
|
|
126
126
|
</data>
|
|
127
127
|
<key>hash2</key>
|
|
128
128
|
<data>
|
|
129
|
-
|
|
129
|
+
ngmtjB/6cpItHMGbQAosuPGYerHi28sLeSZPSiu4kgw=
|
|
130
130
|
</data>
|
|
131
131
|
</dict>
|
|
132
132
|
<key>Modules/KeyWordDetection.swiftmodule/arm64-apple-ios-simulator.swiftmodule</key>
|
|
133
133
|
<dict>
|
|
134
134
|
<key>hash</key>
|
|
135
135
|
<data>
|
|
136
|
-
|
|
136
|
+
BuufFQUpAoiYkD7Qjhqqc+sEQP8=
|
|
137
137
|
</data>
|
|
138
138
|
<key>hash2</key>
|
|
139
139
|
<data>
|
|
140
|
-
|
|
140
|
+
bw7ZD5PzZGEiPNBxPyDV2CVs2GVLZE4qeLrcRGHth2I=
|
|
141
141
|
</data>
|
|
142
142
|
</dict>
|
|
143
143
|
<key>Modules/KeyWordDetection.swiftmodule/x86_64-apple-ios-simulator.abi.json</key>
|
|
144
144
|
<dict>
|
|
145
145
|
<key>hash</key>
|
|
146
146
|
<data>
|
|
147
|
-
|
|
147
|
+
JhMksokD2PvOi2fUofC9nyq5TgY=
|
|
148
148
|
</data>
|
|
149
149
|
<key>hash2</key>
|
|
150
150
|
<data>
|
|
151
|
-
|
|
151
|
+
ZO+SrkXCRrEOjQOKSOXT0AjlcPCYPO1NCOcbcGKtQJ0=
|
|
152
152
|
</data>
|
|
153
153
|
</dict>
|
|
154
154
|
<key>Modules/KeyWordDetection.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface</key>
|
|
155
155
|
<dict>
|
|
156
156
|
<key>hash</key>
|
|
157
157
|
<data>
|
|
158
|
-
|
|
158
|
+
xsyExyernCKMOl0ZAOV+DZdFczw=
|
|
159
159
|
</data>
|
|
160
160
|
<key>hash2</key>
|
|
161
161
|
<data>
|
|
162
|
-
|
|
162
|
+
93QNjXd2AP9IDtDf/KYjR0lnnQxQUzMavuLdk6AKMqc=
|
|
163
163
|
</data>
|
|
164
164
|
</dict>
|
|
165
165
|
<key>Modules/KeyWordDetection.swiftmodule/x86_64-apple-ios-simulator.swiftdoc</key>
|
|
@@ -177,22 +177,22 @@
|
|
|
177
177
|
<dict>
|
|
178
178
|
<key>hash</key>
|
|
179
179
|
<data>
|
|
180
|
-
|
|
180
|
+
xsyExyernCKMOl0ZAOV+DZdFczw=
|
|
181
181
|
</data>
|
|
182
182
|
<key>hash2</key>
|
|
183
183
|
<data>
|
|
184
|
-
|
|
184
|
+
93QNjXd2AP9IDtDf/KYjR0lnnQxQUzMavuLdk6AKMqc=
|
|
185
185
|
</data>
|
|
186
186
|
</dict>
|
|
187
187
|
<key>Modules/KeyWordDetection.swiftmodule/x86_64-apple-ios-simulator.swiftmodule</key>
|
|
188
188
|
<dict>
|
|
189
189
|
<key>hash</key>
|
|
190
190
|
<data>
|
|
191
|
-
|
|
191
|
+
9imz6yhq5UDly3yr9jNA15FpHbM=
|
|
192
192
|
</data>
|
|
193
193
|
<key>hash2</key>
|
|
194
194
|
<data>
|
|
195
|
-
|
|
195
|
+
uPLQKjpeHHaUCdorRTgtQHwHRJ19wHTh4ANA6sGdxwI=
|
|
196
196
|
</data>
|
|
197
197
|
</dict>
|
|
198
198
|
<key>Modules/module.modulemap</key>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-wakeword",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.39",
|
|
4
4
|
"description": "Voice/Wake-word detection library for React Native",
|
|
5
5
|
"main": "wakewords/index.js",
|
|
6
6
|
"types": "wakewords/index.d.ts",
|
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
13
|
"wakewords/",
|
|
14
|
+
"speakerid/",
|
|
14
15
|
"android/",
|
|
15
16
|
"ios/",
|
|
17
|
+
"react-native.config.js",
|
|
16
18
|
"./app.plugin.js",
|
|
17
19
|
"KeyWordRNBridge.podspec"
|
|
18
20
|
],
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export class SpeakerIdInstance {
|
|
2
|
+
constructor(instanceId: any);
|
|
3
|
+
instanceId: any;
|
|
4
|
+
listeners: any[];
|
|
5
|
+
/**
|
|
6
|
+
* Lifecycle
|
|
7
|
+
*/
|
|
8
|
+
createInstance(): Promise<any>;
|
|
9
|
+
createInstanceWWD(): Promise<any>;
|
|
10
|
+
onboardFromMicrophoneWWD(embNum?: number, maxMillis?: number): Promise<any>;
|
|
11
|
+
verifyFromMicrophoneWWD(maxMillis?: number): Promise<any>;
|
|
12
|
+
destroyInstance(): Promise<any>;
|
|
13
|
+
/**
|
|
14
|
+
* Onboarding
|
|
15
|
+
*/
|
|
16
|
+
onboardFromMicrophone(maxMillis?: number): Promise<any>;
|
|
17
|
+
onboardingStreamStart(): Promise<any>;
|
|
18
|
+
onboardingStreamFeed(blockInt16: any): Promise<any>;
|
|
19
|
+
onboardingStreamFinish(): Promise<any>;
|
|
20
|
+
onboardFromWav(absPath: any): Promise<any>;
|
|
21
|
+
/**
|
|
22
|
+
* Verification init
|
|
23
|
+
*/
|
|
24
|
+
initVerificationUsingDefaults(): Promise<any>;
|
|
25
|
+
initVerificationUsingCurrentConfig(): Promise<any>;
|
|
26
|
+
initVerificationWithFiles(meanNpyPath: any, clusterNpyPath: any): Promise<any>;
|
|
27
|
+
/**
|
|
28
|
+
* Verification
|
|
29
|
+
*/
|
|
30
|
+
verifyFromMicrophone(maxMillis?: number): Promise<any>;
|
|
31
|
+
verifyFromWav(absPath: any): Promise<any>;
|
|
32
|
+
verifyStreamPush(blockInt16: any): Promise<any>;
|
|
33
|
+
verifyStreamFinish(): Promise<any>;
|
|
34
|
+
/**
|
|
35
|
+
* Export helpers (Downloads/)
|
|
36
|
+
*/
|
|
37
|
+
exportDefaultClusterToDownloads(): Promise<any>;
|
|
38
|
+
exportDefaultMeanToDownloads(): Promise<any>;
|
|
39
|
+
exportDefaultMeanCountToDownloads(): Promise<any>;
|
|
40
|
+
/**
|
|
41
|
+
* Optional: subscribe to an event fired when a segment is finalized during mic verification
|
|
42
|
+
* Native side will emit { instanceId, result: {...same fields as verify...} }
|
|
43
|
+
*/
|
|
44
|
+
onVerificationEvent(callback: any): import("react-native").EmitterSubscription;
|
|
45
|
+
removeListeners(): void;
|
|
46
|
+
}
|
|
47
|
+
export function createSpeakerIdInstance(instanceId: any): Promise<SpeakerIdInstance>;
|
|
48
|
+
export function removeAllSpeakerIdListeners(): Promise<void>;
|
|
49
|
+
export function float32ToInt16(f32: any): Int16Array<any>;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
// speakerid/SpeakerIdRNBridge.js
|
|
2
|
+
import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
|
|
3
|
+
|
|
4
|
+
const { SpeakerIdRNBridge } = NativeModules;
|
|
5
|
+
const speakerIdEmitter = new NativeEventEmitter(SpeakerIdRNBridge);
|
|
6
|
+
|
|
7
|
+
if (!SpeakerIdRNBridge) {
|
|
8
|
+
console.error('SpeakerIdRNBridge is not linked.');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Helpers
|
|
13
|
+
*/
|
|
14
|
+
const ensureAndroid = () => {
|
|
15
|
+
if (Platform.OS !== 'android') {
|
|
16
|
+
throw new Error('SpeakerIdRNBridge is Android-only');
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export class SpeakerIdInstance {
|
|
21
|
+
instanceId;
|
|
22
|
+
listeners = [];
|
|
23
|
+
|
|
24
|
+
constructor(instanceId) {
|
|
25
|
+
this.instanceId = instanceId;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Lifecycle
|
|
30
|
+
*/
|
|
31
|
+
async createInstance() {
|
|
32
|
+
ensureAndroid();
|
|
33
|
+
return SpeakerIdRNBridge.createInstance(this.instanceId);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async createInstanceWWD() {
|
|
37
|
+
ensureAndroid();
|
|
38
|
+
return SpeakerIdRNBridge.createInstanceWWD(this.instanceId);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async onboardFromMicrophoneWWD(embNum = 3, maxMillis = 8000) {
|
|
42
|
+
ensureAndroid();
|
|
43
|
+
// Resolves to { clusterSize, embeddingDim }
|
|
44
|
+
return SpeakerIdRNBridge.onboardFromMicrophoneWWD(this.instanceId, embNum, maxMillis);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async verifyFromMicrophoneWWD(maxMillis = 5000) {
|
|
48
|
+
ensureAndroid();
|
|
49
|
+
// Resolves to { fullSec, voicedSec, bestScore, bestStrategy, bestTargetLabel, perTargetStrategy }
|
|
50
|
+
return SpeakerIdRNBridge.verifyFromMicrophoneWWD(this.instanceId, maxMillis);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async destroyInstance() {
|
|
54
|
+
ensureAndroid();
|
|
55
|
+
return SpeakerIdRNBridge.destroyInstance(this.instanceId);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Onboarding
|
|
60
|
+
*/
|
|
61
|
+
async onboardFromMicrophone(maxMillis = 15000) {
|
|
62
|
+
ensureAndroid();
|
|
63
|
+
// Resolves to { clusterSize, embDim }
|
|
64
|
+
return SpeakerIdRNBridge.onboardFromMicrophone(this.instanceId, maxMillis);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Streaming onboarding: feed Int16 blocks repeatedly; finish when you’re done.
|
|
68
|
+
async onboardingStreamStart() {
|
|
69
|
+
ensureAndroid();
|
|
70
|
+
return SpeakerIdRNBridge.onboardingStreamStart(this.instanceId);
|
|
71
|
+
}
|
|
72
|
+
async onboardingStreamFeed(blockInt16) {
|
|
73
|
+
ensureAndroid();
|
|
74
|
+
// RN passes arrays of numbers; provide Int16 values (range -32768..32767)
|
|
75
|
+
return SpeakerIdRNBridge.onboardingStreamFeed(this.instanceId, Array.from(blockInt16));
|
|
76
|
+
}
|
|
77
|
+
async onboardingStreamFinish() {
|
|
78
|
+
ensureAndroid();
|
|
79
|
+
// Resolves to { clusterSize, embDim } when enrollment completes, or null if not enough speech
|
|
80
|
+
return SpeakerIdRNBridge.onboardingStreamFinish(this.instanceId);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async onboardFromWav(absPath) {
|
|
84
|
+
ensureAndroid();
|
|
85
|
+
// Resolves to { clusterSize, embDim }
|
|
86
|
+
return SpeakerIdRNBridge.onboardFromWav(this.instanceId, String(absPath));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async initVerificationUsingCurrentConfig() {
|
|
90
|
+
ensureAndroid();
|
|
91
|
+
// Resolves to boolean
|
|
92
|
+
return SpeakerIdRNBridge.initVerificationUsingCurrentConfig(this.instanceId);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Verification init
|
|
98
|
+
*/
|
|
99
|
+
async initVerificationUsingDefaults() {
|
|
100
|
+
ensureAndroid();
|
|
101
|
+
// Resolves to boolean
|
|
102
|
+
return SpeakerIdRNBridge.initVerificationUsingDefaults(this.instanceId);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async initVerificationWithFiles(meanNpyPath, clusterNpyPath) {
|
|
106
|
+
ensureAndroid();
|
|
107
|
+
// Resolves to boolean
|
|
108
|
+
return SpeakerIdRNBridge.initVerificationWithFiles(this.instanceId, String(meanNpyPath), String(clusterNpyPath));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Verification
|
|
113
|
+
*/
|
|
114
|
+
async verifyFromMicrophone(maxMillis = 15000) {
|
|
115
|
+
ensureAndroid();
|
|
116
|
+
// Resolves to { fullSec, voicedSec, bestScore, bestStrategy, bestTargetLabel, perTargetStrategy }
|
|
117
|
+
return SpeakerIdRNBridge.verifyFromMicrophone(this.instanceId, maxMillis);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async verifyFromWav(absPath) {
|
|
121
|
+
ensureAndroid();
|
|
122
|
+
return SpeakerIdRNBridge.verifyFromWav(this.instanceId, String(absPath));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Streaming verification
|
|
126
|
+
async verifyStreamPush(blockInt16) {
|
|
127
|
+
ensureAndroid();
|
|
128
|
+
// May resolve to null (no finalized segment yet) OR a result object (same shape as verifyFromMicrophone)
|
|
129
|
+
return SpeakerIdRNBridge.verifyStreamPush(this.instanceId, Array.from(blockInt16));
|
|
130
|
+
}
|
|
131
|
+
async verifyStreamFinish() {
|
|
132
|
+
ensureAndroid();
|
|
133
|
+
return SpeakerIdRNBridge.verifyStreamFinish(this.instanceId);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Export helpers (Downloads/)
|
|
138
|
+
*/
|
|
139
|
+
async exportDefaultClusterToDownloads() {
|
|
140
|
+
ensureAndroid();
|
|
141
|
+
// Resolves to { uri }
|
|
142
|
+
return SpeakerIdRNBridge.exportDefaultClusterToDownloads(this.instanceId);
|
|
143
|
+
}
|
|
144
|
+
async exportDefaultMeanToDownloads() {
|
|
145
|
+
ensureAndroid();
|
|
146
|
+
return SpeakerIdRNBridge.exportDefaultMeanToDownloads(this.instanceId);
|
|
147
|
+
}
|
|
148
|
+
async exportDefaultMeanCountToDownloads() {
|
|
149
|
+
ensureAndroid();
|
|
150
|
+
return SpeakerIdRNBridge.exportDefaultMeanCountToDownloads(this.instanceId);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Optional: subscribe to an event fired when a segment is finalized during mic verification
|
|
155
|
+
* Native side will emit { instanceId, result: {...same fields as verify...} }
|
|
156
|
+
*/
|
|
157
|
+
onVerificationEvent(callback) {
|
|
158
|
+
const sub = speakerIdEmitter.addListener('onSpeakerVerificationEvent', (event) => {
|
|
159
|
+
if (event?.instanceId === this.instanceId) {
|
|
160
|
+
callback(event.result);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
this.listeners.push(sub);
|
|
164
|
+
return sub;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
removeListeners() {
|
|
168
|
+
this.listeners.forEach((l) => l.remove());
|
|
169
|
+
this.listeners = [];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** Factory to mirror your wakewords helper */
|
|
174
|
+
export const createSpeakerIdInstance = async (instanceId) => {
|
|
175
|
+
return new SpeakerIdInstance(instanceId);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/** Optional: bulk remove listeners if you use global events */
|
|
179
|
+
export const removeAllSpeakerIdListeners = async () => {
|
|
180
|
+
speakerIdEmitter.removeAllListeners('onSpeakerVerificationEvent');
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Utilities for converting audio to Int16 arrays for streaming APIs
|
|
185
|
+
*/
|
|
186
|
+
export const float32ToInt16 = (f32) => {
|
|
187
|
+
const out = new Int16Array(f32.length);
|
|
188
|
+
for (let i = 0; i < f32.length; i++) {
|
|
189
|
+
let s = Math.max(-1, Math.min(1, f32[i]));
|
|
190
|
+
out[i] = s < 0 ? s * 32768 : s * 32767;
|
|
191
|
+
}
|
|
192
|
+
return out;
|
|
193
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function createSpeakerIdInstance(instanceId?: string): Promise<{
|
|
2
|
+
createInstance: () => any;
|
|
3
|
+
createInstanceWWD: () => any;
|
|
4
|
+
onboardFromMicrophoneWWD: (embNum: any, ms: any) => any;
|
|
5
|
+
verifyFromMicrophoneWWD: (ms: any) => any;
|
|
6
|
+
initVerificationUsingDefaults: () => any;
|
|
7
|
+
initVerificationUsingCurrentConfig: () => any;
|
|
8
|
+
initVerificationWithFiles: (m: any, c: any) => any;
|
|
9
|
+
onboardFromMicrophone: (ms: any) => any;
|
|
10
|
+
onboardStartStream: () => any;
|
|
11
|
+
onboardStreamFeed: (int16: any) => any;
|
|
12
|
+
onboardStreamFinish: () => any;
|
|
13
|
+
onboardFromWav: (p: any) => any;
|
|
14
|
+
verifyFromMicrophone: (ms: any) => any;
|
|
15
|
+
verifyStreamPush: (int16: any) => any;
|
|
16
|
+
verifyStreamFinish: () => any;
|
|
17
|
+
verifyFromWav: (p: any) => any;
|
|
18
|
+
exportDefaultClusterToDownloads: () => any;
|
|
19
|
+
exportDefaultMeanToDownloads: () => any;
|
|
20
|
+
exportDefaultMeanCountToDownloads: () => any;
|
|
21
|
+
destroy: () => any;
|
|
22
|
+
}>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//speakerid/index.js
|
|
2
|
+
import { NativeModules } from 'react-native';
|
|
3
|
+
const { SpeakerIdRNBridge } = NativeModules;
|
|
4
|
+
|
|
5
|
+
export const createSpeakerIdInstance = async (instanceId = 'sid1') => ({
|
|
6
|
+
createInstance: () => SpeakerIdRNBridge.createInstance(instanceId),
|
|
7
|
+
createInstanceWWD: () => SpeakerIdRNBridge.createInstanceWWD(instanceId),
|
|
8
|
+
onboardFromMicrophoneWWD: (embNum, ms) =>
|
|
9
|
+
SpeakerIdRNBridge.onboardFromMicrophoneWWD(instanceId, embNum ?? 3, ms ?? 8000),
|
|
10
|
+
verifyFromMicrophoneWWD: (ms) =>
|
|
11
|
+
SpeakerIdRNBridge.verifyFromMicrophoneWWD(instanceId, ms ?? 5000),
|
|
12
|
+
initVerificationUsingDefaults: () => SpeakerIdRNBridge.initVerificationUsingDefaults(instanceId),
|
|
13
|
+
initVerificationUsingCurrentConfig: () => SpeakerIdRNBridge.initVerificationUsingDefaults(instanceId),
|
|
14
|
+
initVerificationWithFiles: (m, c) => SpeakerIdRNBridge.initVerificationWithFiles(instanceId, m, c),
|
|
15
|
+
onboardFromMicrophone: (ms) => SpeakerIdRNBridge.onboardFromMicrophone(instanceId, ms ?? 12000),
|
|
16
|
+
onboardStartStream: () => SpeakerIdRNBridge.onboardStartStream(instanceId),
|
|
17
|
+
onboardStreamFeed: (int16) => SpeakerIdRNBridge.onboardStreamFeed(instanceId, Array.from(int16)),
|
|
18
|
+
onboardStreamFinish: () => SpeakerIdRNBridge.onboardStreamFinish(instanceId),
|
|
19
|
+
onboardFromWav: (p) => SpeakerIdRNBridge.onboardFromWav(instanceId, p),
|
|
20
|
+
verifyFromMicrophone: (ms) => SpeakerIdRNBridge.verifyFromMicrophone(instanceId, ms ?? 8000),
|
|
21
|
+
verifyStreamPush: (int16) => SpeakerIdRNBridge.verifyStreamPush(instanceId, Array.from(int16)),
|
|
22
|
+
verifyStreamFinish: () => SpeakerIdRNBridge.verifyStreamFinish(instanceId),
|
|
23
|
+
verifyFromWav: (p) => SpeakerIdRNBridge.verifyFromWav(instanceId, p),
|
|
24
|
+
exportDefaultClusterToDownloads: () => SpeakerIdRNBridge.exportDefaultClusterToDownloads(instanceId),
|
|
25
|
+
exportDefaultMeanToDownloads: () => SpeakerIdRNBridge.exportDefaultMeanToDownloads(instanceId),
|
|
26
|
+
exportDefaultMeanCountToDownloads: () => SpeakerIdRNBridge.exportDefaultMeanCountToDownloads(instanceId),
|
|
27
|
+
destroy: () => SpeakerIdRNBridge.destroyInstance(instanceId),
|
|
28
|
+
});
|
|
Binary file
|
package/wakewords/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export default useModel;
|
|
2
|
-
import { enableDucking } from
|
|
3
|
-
import { disableDucking } from
|
|
4
|
-
import { initAudioSessAndDuckManage } from
|
|
5
|
-
import { restartListeningAfterDucking } from
|
|
6
|
-
import { removeAllRNBridgeListeners } from
|
|
7
|
-
import { createKeyWordRNBridgeInstance } from
|
|
8
|
-
import { KeyWordRNBridgeInstance } from
|
|
9
|
-
import useModel from
|
|
2
|
+
import { enableDucking } from './KeyWordRNBridge';
|
|
3
|
+
import { disableDucking } from './KeyWordRNBridge';
|
|
4
|
+
import { initAudioSessAndDuckManage } from './KeyWordRNBridge';
|
|
5
|
+
import { restartListeningAfterDucking } from './KeyWordRNBridge';
|
|
6
|
+
import { removeAllRNBridgeListeners } from './KeyWordRNBridge';
|
|
7
|
+
import { createKeyWordRNBridgeInstance } from './KeyWordRNBridge';
|
|
8
|
+
import { KeyWordRNBridgeInstance } from './KeyWordRNBridge';
|
|
9
|
+
import useModel from './useModel';
|
|
10
10
|
export { enableDucking, disableDucking, initAudioSessAndDuckManage, restartListeningAfterDucking, removeAllRNBridgeListeners, createKeyWordRNBridgeInstance, KeyWordRNBridgeInstance, useModel };
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
package com.davoice.keywordspotting;
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.ReactPackage;
|
|
4
|
-
import com.facebook.react.bridge.NativeModule;
|
|
5
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
6
|
-
import com.facebook.react.uimanager.ViewManager;
|
|
7
|
-
|
|
8
|
-
import java.util.ArrayList;
|
|
9
|
-
import java.util.Collections;
|
|
10
|
-
import java.util.List;
|
|
11
|
-
|
|
12
|
-
public class KeyWordRNBridgePackage implements ReactPackage {
|
|
13
|
-
|
|
14
|
-
@Override
|
|
15
|
-
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
|
16
|
-
List<NativeModule> modules = new ArrayList<>();
|
|
17
|
-
modules.add(new KeyWordRNBridge(reactContext));
|
|
18
|
-
return modules;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@Override
|
|
22
|
-
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
|
23
|
-
return Collections.emptyList();
|
|
24
|
-
}
|
|
25
|
-
}
|