react-native-wakeword 1.0.29 → 1.0.30
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/package.json +2 -1
- package/wakewords/useModel.tsx +13 -20
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-wakeword",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.30",
|
|
4
4
|
"description": "Voice/Wake-word detection library for React Native",
|
|
5
5
|
"main": "wakewords/index.js",
|
|
6
6
|
"types": "wakewords/index.d.ts",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"wake word",
|
|
34
34
|
"keyword detection",
|
|
35
35
|
"keyword spotting",
|
|
36
|
+
"speech to intent",
|
|
36
37
|
"phrase spotting"
|
|
37
38
|
],
|
|
38
39
|
"author": "Davoice.io",
|
package/wakewords/useModel.tsx
CHANGED
|
@@ -27,9 +27,8 @@ function findInstanceById(id: string): keyWordRNBridgeInstanceConfig | undefined
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
// Create an array of instance configurations
|
|
30
|
-
|
|
30
|
+
var instanceConfigs:instanceConfig[] = [
|
|
31
31
|
{ id: 'need_help_now', modelName: 'need_help_now.onnx', threshold: 0.9999, bufferCnt: 3 , sticky: false },
|
|
32
|
-
{ id: 'default', modelName: "", threshold: 0.9999, bufferCnt: 2 , sticky: false }
|
|
33
32
|
];
|
|
34
33
|
|
|
35
34
|
// Function to add a new instance dynamically
|
|
@@ -134,27 +133,16 @@ export const useModel = () => {
|
|
|
134
133
|
* @param bufferCount - The number of audio buffers
|
|
135
134
|
*/
|
|
136
135
|
const loadModel = useCallback(
|
|
137
|
-
async (
|
|
136
|
+
async (useConfigs: instanceConfig[], callback: (phrase: string) => void): Promise<void> => {
|
|
138
137
|
|
|
139
138
|
console.log("loadModel()");
|
|
140
|
-
|
|
139
|
+
instanceConfigs = useConfigs;
|
|
141
140
|
let element:any = null;
|
|
142
|
-
console.log("loadModel() -
|
|
141
|
+
console.log("loadModel() - instanceConfigs == ", instanceConfigs)
|
|
143
142
|
try {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (element == null || element == undefined) {
|
|
148
|
-
//console.error('element id' + sId + " not found in instanceConfigs");
|
|
149
|
-
//return;
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
element = Object.assign({}, instanceConfigs.find(element => element.id === 'default'));
|
|
153
|
-
element.modelName = sId;
|
|
154
|
-
element.id = sId.split(".")[0];
|
|
155
|
-
}
|
|
156
|
-
console.log('element:', element);
|
|
157
|
-
const id = addInstance(element, callback);
|
|
143
|
+
instanceConfigs.forEach(element => {
|
|
144
|
+
console.log('Adding element:', element);
|
|
145
|
+
const id = addInstance(element, callback);
|
|
158
146
|
});
|
|
159
147
|
} catch (error) {
|
|
160
148
|
console.error("[useModel] Error loading model:", error);
|
|
@@ -168,7 +156,12 @@ export const useModel = () => {
|
|
|
168
156
|
try {
|
|
169
157
|
keyWordRNBridgeInstances.forEach(element => {
|
|
170
158
|
const instance = element.instance;
|
|
171
|
-
instance.
|
|
159
|
+
const conf = instanceConfigs.find(element => element.id === instance.instanceId);
|
|
160
|
+
if (conf) {
|
|
161
|
+
instance.startKeywordDetection(conf.threshold);
|
|
162
|
+
} else {
|
|
163
|
+
console.error(`No configuration found for instance ID: ${instance.instanceId}`);
|
|
164
|
+
}
|
|
172
165
|
/*if (instance.isSticky == false) {
|
|
173
166
|
instance.stopKeywordDetection();
|
|
174
167
|
} else if (Platform.OS != 'ios') {
|