react-native-wakeword 1.0.30 → 1.0.31
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 +1 -5
- package/package.json +4 -1
- package/wakewords/KeyWordRNBridge.d.ts +7 -7
- package/wakewords/KeyWordRNBridge.js +10 -15
- package/wakewords/useModel.d.ts +8 -1
- package/wakewords/useModel.tsx +9 -9
package/README.md
CHANGED
|
@@ -3,11 +3,7 @@ DaVoice.io Voice commands / Wake words / Voice to Intent / keyword detection npm
|
|
|
3
3
|
|
|
4
4
|
Contact us at info@DaVoice.io
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
### This package includes
|
|
9
|
-
1. "Wake Word" (also known as: "keyword detection" and "phrase spotting") api to enable ios and android applications.
|
|
10
|
-
2. "Speech to Intent" (also known as: "voice commands" and "phrase spotting") very similar to "Wake Word" however mainly used to use speech command to control the application rather than waking up the application.
|
|
6
|
+
# IOS and Android Package
|
|
11
7
|
|
|
12
8
|
## Installation
|
|
13
9
|
npm install react-native-wakeword
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-wakeword",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.31",
|
|
4
4
|
"description": "Voice/Wake-word detection library for React Native",
|
|
5
5
|
"main": "wakewords/index.js",
|
|
6
6
|
"types": "wakewords/index.d.ts",
|
|
@@ -31,9 +31,12 @@
|
|
|
31
31
|
"react-native",
|
|
32
32
|
"voice commands",
|
|
33
33
|
"wake word",
|
|
34
|
+
"wakeword",
|
|
35
|
+
"wake words",
|
|
34
36
|
"keyword detection",
|
|
35
37
|
"keyword spotting",
|
|
36
38
|
"speech to intent",
|
|
39
|
+
"voice to intent",
|
|
37
40
|
"phrase spotting"
|
|
38
41
|
],
|
|
39
42
|
"author": "Davoice.io",
|
|
@@ -4,13 +4,13 @@ export class KeyWordRNBridgeInstance {
|
|
|
4
4
|
listeners: any[];
|
|
5
5
|
isFirstInstance: boolean;
|
|
6
6
|
isSticky: any;
|
|
7
|
-
createInstance(modelName: any, threshold: any, bufferCnt: any): any
|
|
8
|
-
setKeywordDetectionLicense(license: any): any
|
|
9
|
-
replaceKeywordDetectionModel(modelName: any, threshold: any, bufferCnt: any): any
|
|
10
|
-
setKeywordLicense(license: any): any
|
|
11
|
-
startKeywordDetection(threshold: any): any
|
|
12
|
-
stopKeywordDetection(): any
|
|
13
|
-
destroyInstance(): any
|
|
7
|
+
createInstance(modelName: any, threshold: any, bufferCnt: any): Promise<any>;
|
|
8
|
+
setKeywordDetectionLicense(license: any): Promise<any>;
|
|
9
|
+
replaceKeywordDetectionModel(modelName: any, threshold: any, bufferCnt: any): Promise<any>;
|
|
10
|
+
setKeywordLicense(license: any): Promise<any>;
|
|
11
|
+
startKeywordDetection(threshold: any): Promise<any>;
|
|
12
|
+
stopKeywordDetection(): Promise<any>;
|
|
13
|
+
destroyInstance(): Promise<any>;
|
|
14
14
|
onKeywordDetectionEvent(callback: any): void;
|
|
15
15
|
removeListeners(): void;
|
|
16
16
|
}
|
|
@@ -20,30 +20,25 @@ export class KeyWordRNBridgeInstance {
|
|
|
20
20
|
this.isSticky = isSticky;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
createInstance(
|
|
24
|
-
|
|
25
|
-
threshold,
|
|
26
|
-
bufferCnt)
|
|
27
|
-
{
|
|
28
|
-
instance = KeyWordRNBridge.createInstance(
|
|
23
|
+
async createInstance(modelName, threshold, bufferCnt) {
|
|
24
|
+
instance = await KeyWordRNBridge.createInstance(
|
|
29
25
|
this.instanceId,
|
|
30
26
|
modelName,
|
|
31
27
|
threshold,
|
|
32
|
-
bufferCnt
|
|
33
|
-
);
|
|
28
|
+
bufferCnt);
|
|
34
29
|
if (instance && this.isFirstInstance)
|
|
35
30
|
{
|
|
36
31
|
this.isFirstInstance = false;
|
|
37
|
-
KeyWordRNBridge.startForegroundService(this.instanceId);
|
|
32
|
+
await KeyWordRNBridge.startForegroundService(this.instanceId);
|
|
38
33
|
}
|
|
39
34
|
return instance;
|
|
40
35
|
}
|
|
41
36
|
|
|
42
|
-
setKeywordDetectionLicense(license) {
|
|
37
|
+
async setKeywordDetectionLicense(license) {
|
|
43
38
|
return KeyWordRNBridge.setKeywordDetectionLicense(this.instanceId, license);
|
|
44
39
|
}
|
|
45
40
|
|
|
46
|
-
replaceKeywordDetectionModel(modelName, threshold, bufferCnt) {
|
|
41
|
+
async replaceKeywordDetectionModel(modelName, threshold, bufferCnt) {
|
|
47
42
|
return KeyWordRNBridge.replaceKeywordDetectionModel(this.instanceId, modelName, threshold, bufferCnt);
|
|
48
43
|
}
|
|
49
44
|
/*startForegroundService() {
|
|
@@ -53,19 +48,19 @@ export class KeyWordRNBridgeInstance {
|
|
|
53
48
|
stopForegroundService() {
|
|
54
49
|
return KeyWordRNBridge.stopForegroundService(this.instanceId);
|
|
55
50
|
}*/
|
|
56
|
-
setKeywordLicense(license) {
|
|
51
|
+
async setKeywordLicense(license) {
|
|
57
52
|
return KeyWordRNBridge.setKeywordLicense(this.instanceId, license);
|
|
58
53
|
}
|
|
59
54
|
|
|
60
|
-
startKeywordDetection(threshold) {
|
|
55
|
+
async startKeywordDetection(threshold) {
|
|
61
56
|
return KeyWordRNBridge.startKeywordDetection(this.instanceId, threshold);
|
|
62
57
|
}
|
|
63
58
|
|
|
64
|
-
stopKeywordDetection() {
|
|
59
|
+
async stopKeywordDetection() {
|
|
65
60
|
return KeyWordRNBridge.stopKeywordDetection(this.instanceId);
|
|
66
61
|
}
|
|
67
62
|
|
|
68
|
-
destroyInstance() {
|
|
63
|
+
async destroyInstance() {
|
|
69
64
|
return KeyWordRNBridge.destroyInstance(this.instanceId);
|
|
70
65
|
}
|
|
71
66
|
|
package/wakewords/useModel.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
interface instanceConfig {
|
|
2
|
+
id: string;
|
|
3
|
+
modelName: string;
|
|
4
|
+
threshold: number;
|
|
5
|
+
bufferCnt: number;
|
|
6
|
+
sticky: boolean;
|
|
7
|
+
}
|
|
1
8
|
/**
|
|
2
9
|
* Custom hook for handling keyword detection using KeyWordRNBridge
|
|
3
10
|
* @returns An object with functions and state for keyword detection
|
|
@@ -5,7 +12,7 @@
|
|
|
5
12
|
export declare const useModel: () => {
|
|
6
13
|
isListening: boolean;
|
|
7
14
|
startListening: () => Promise<void>;
|
|
8
|
-
loadModel: (
|
|
15
|
+
loadModel: (useConfigs: instanceConfig[], callback: (phrase: string) => void) => Promise<void>;
|
|
9
16
|
setKeywordDetectionLicense: (licenseKey: string) => Promise<void>;
|
|
10
17
|
stopListening: () => Promise<void>;
|
|
11
18
|
};
|
package/wakewords/useModel.tsx
CHANGED
|
@@ -43,7 +43,7 @@ async function addInstance(
|
|
|
43
43
|
if (instanceConf != null) {
|
|
44
44
|
console.log("Found Instance: ", id, "starting to listen");
|
|
45
45
|
const instance = instanceConf.instance;
|
|
46
|
-
instance.startKeywordDetection(conf.threshold);
|
|
46
|
+
await instance.startKeywordDetection(conf.threshold);
|
|
47
47
|
return instance;
|
|
48
48
|
}
|
|
49
49
|
const instance = await createKeyWordRNBridgeInstance(id, conf.sticky);
|
|
@@ -68,7 +68,7 @@ async function addInstance(
|
|
|
68
68
|
callback(id);
|
|
69
69
|
});
|
|
70
70
|
console.log(`Instance ${id} calling startKeywordDetection()`);
|
|
71
|
-
instance.startKeywordDetection(conf.threshold);
|
|
71
|
+
await instance.startKeywordDetection(conf.threshold);
|
|
72
72
|
console.log(`Instance ${id} started Keyword Detection`);
|
|
73
73
|
return instance;
|
|
74
74
|
}
|
|
@@ -140,9 +140,9 @@ export const useModel = () => {
|
|
|
140
140
|
let element:any = null;
|
|
141
141
|
console.log("loadModel() - instanceConfigs == ", instanceConfigs)
|
|
142
142
|
try {
|
|
143
|
-
instanceConfigs.forEach(element => {
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
instanceConfigs.forEach(async element => {
|
|
144
|
+
console.log('Adding element:', element);
|
|
145
|
+
const id = await addInstance(element, callback);
|
|
146
146
|
});
|
|
147
147
|
} catch (error) {
|
|
148
148
|
console.error("[useModel] Error loading model:", error);
|
|
@@ -154,11 +154,11 @@ export const useModel = () => {
|
|
|
154
154
|
*/
|
|
155
155
|
const startListening = useCallback(async () => {
|
|
156
156
|
try {
|
|
157
|
-
keyWordRNBridgeInstances.forEach(element => {
|
|
157
|
+
keyWordRNBridgeInstances.forEach(async element => {
|
|
158
158
|
const instance = element.instance;
|
|
159
159
|
const conf = instanceConfigs.find(element => element.id === instance.instanceId);
|
|
160
160
|
if (conf) {
|
|
161
|
-
instance.startKeywordDetection(conf.threshold);
|
|
161
|
+
await instance.startKeywordDetection(conf.threshold);
|
|
162
162
|
} else {
|
|
163
163
|
console.error(`No configuration found for instance ID: ${instance.instanceId}`);
|
|
164
164
|
}
|
|
@@ -179,9 +179,9 @@ export const useModel = () => {
|
|
|
179
179
|
*/
|
|
180
180
|
const stopListening = useCallback(async () => {
|
|
181
181
|
try {
|
|
182
|
-
keyWordRNBridgeInstances.forEach(element => {
|
|
182
|
+
keyWordRNBridgeInstances.forEach(async element => {
|
|
183
183
|
const instance = element.instance;
|
|
184
|
-
instance.stopKeywordDetection();
|
|
184
|
+
await instance.stopKeywordDetection();
|
|
185
185
|
/*if (instance.isSticky == false) {
|
|
186
186
|
instance.stopKeywordDetection();
|
|
187
187
|
} else if (Platform.OS != 'ios') {
|