react-native-wakeword 1.0.31 → 1.0.32
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 +4 -2
- package/wakewords/useModel.tsx +10 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-wakeword",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"description": "Voice/Wake-word detection library for React Native",
|
|
5
5
|
"main": "wakewords/index.js",
|
|
6
6
|
"types": "wakewords/index.d.ts",
|
|
@@ -37,7 +37,9 @@
|
|
|
37
37
|
"keyword spotting",
|
|
38
38
|
"speech to intent",
|
|
39
39
|
"voice to intent",
|
|
40
|
-
"phrase spotting"
|
|
40
|
+
"phrase spotting",
|
|
41
|
+
"react native wake word",
|
|
42
|
+
"rn wake word"
|
|
41
43
|
],
|
|
42
44
|
"author": "Davoice.io",
|
|
43
45
|
"license": "MIT"
|
package/wakewords/useModel.tsx
CHANGED
|
@@ -31,6 +31,14 @@ var instanceConfigs:instanceConfig[] = [
|
|
|
31
31
|
{ id: 'need_help_now', modelName: 'need_help_now.onnx', threshold: 0.9999, bufferCnt: 3 , sticky: false },
|
|
32
32
|
];
|
|
33
33
|
|
|
34
|
+
// Helper function to format the ONNX file name
|
|
35
|
+
const formatWakeWord = (fileName) => {
|
|
36
|
+
return fileName
|
|
37
|
+
.replace(/_/g, ' ') // Use global flag to replace all underscores
|
|
38
|
+
.replace('.onnx', '')
|
|
39
|
+
.replace(/\b\w/g, (char) => char.toUpperCase()); // Capitalize each word
|
|
40
|
+
};
|
|
41
|
+
|
|
34
42
|
// Function to add a new instance dynamically
|
|
35
43
|
//async function addInstance(
|
|
36
44
|
// conf: instanceConfig)
|
|
@@ -63,9 +71,10 @@ async function addInstance(
|
|
|
63
71
|
keyWordRNBridgeInstances.push({ id, instance });
|
|
64
72
|
// Set up event listener
|
|
65
73
|
instance.onKeywordDetectionEvent((phrase: string) => {
|
|
74
|
+
phrase = formatWakeWord(id);
|
|
66
75
|
console.log(`Instance ${id} detected: ${id} with phrase`, phrase);
|
|
67
76
|
// callback(phrase); Does not work on IOS
|
|
68
|
-
callback(
|
|
77
|
+
callback(phrase);
|
|
69
78
|
});
|
|
70
79
|
console.log(`Instance ${id} calling startKeywordDetection()`);
|
|
71
80
|
await instance.startKeywordDetection(conf.threshold);
|