react-native-wakeword 1.0.43 → 1.0.45
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
CHANGED
|
@@ -12,14 +12,21 @@ npm install react-native-wakeword
|
|
|
12
12
|
Add this to your android/build.gradle file:
|
|
13
13
|
|
|
14
14
|
allprojects {
|
|
15
|
+
|
|
15
16
|
repositories {
|
|
17
|
+
|
|
16
18
|
// react-native-wakeword added
|
|
19
|
+
|
|
17
20
|
maven { url "${project(":react-native-wakeword").projectDir}/libs" }
|
|
21
|
+
|
|
18
22
|
maven { url("${project(':react-native-wakeword').projectDir}/libs") }
|
|
23
|
+
|
|
19
24
|
maven {
|
|
20
25
|
url("${project(':react-native-wakeword').projectDir}/libs")
|
|
21
26
|
}
|
|
27
|
+
|
|
22
28
|
// End react-native-wakeword added
|
|
29
|
+
|
|
23
30
|
... your other lines...
|
|
24
31
|
|
|
25
32
|
## Githhub examples:
|
|
@@ -27,6 +34,7 @@ allprojects {
|
|
|
27
34
|
### Checkout examples on:
|
|
28
35
|
https://github.com/frymanofer/ReactNative_WakeWordDetection
|
|
29
36
|
|
|
37
|
+
https://github.com/frymanofer/ReactNative_WakeWordDetection/example_npm
|
|
30
38
|
|
|
31
39
|
## FAQ:
|
|
32
40
|
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
|
11
11
|
|
|
12
12
|
<!-- Required for microphone access in Android 14 -->
|
|
13
|
-
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
|
14
13
|
<uses-permission android:name="android.permission.CAPTURE_AUDIO_OUTPUT"/>
|
|
15
14
|
<uses-permission android:name="android.permission.CAPTURE_MEDIA_OUTPUT"/>
|
|
16
15
|
|
package/package.json
CHANGED
|
@@ -14,4 +14,5 @@ export class KeyWordRNBridgeInstance {
|
|
|
14
14
|
onKeywordDetectionEvent(callback: any): void;
|
|
15
15
|
removeListeners(): void;
|
|
16
16
|
}
|
|
17
|
+
export function removeAllRNBridgeListeners(): Promise<void>;
|
|
17
18
|
export function createKeyWordRNBridgeInstance(instanceId: any, isSticky: any): Promise<KeyWordRNBridgeInstance>;
|
|
@@ -79,6 +79,10 @@ export class KeyWordRNBridgeInstance {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
export const removeAllRNBridgeListeners = async () => {
|
|
83
|
+
keywordRNBridgeEmitter.removeAllListeners('onKeywordDetectionEvent');
|
|
84
|
+
}
|
|
85
|
+
|
|
82
86
|
export const createKeyWordRNBridgeInstance = async (instanceId, isSticky) => {
|
|
83
87
|
return new KeyWordRNBridgeInstance(instanceId, isSticky);
|
|
84
88
|
};
|
package/wakewords/useModel.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useState, useEffect, useCallback } from "react";
|
|
2
2
|
import {
|
|
3
3
|
createKeyWordRNBridgeInstance,
|
|
4
|
+
removeAllRNBridgeListeners,
|
|
4
5
|
KeyWordRNBridgeInstance,
|
|
5
6
|
} from './KeyWordRNBridge';
|
|
6
7
|
import { Platform } from "react-native";
|
|
@@ -69,8 +70,11 @@ async function addInstance(
|
|
|
69
70
|
console.log(`Instance ${id} created ${instance} and licensed ${isLicesed}`);
|
|
70
71
|
|
|
71
72
|
keyWordRNBridgeInstances.push({ id, instance });
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
|
|
74
|
+
// Set up event listener
|
|
75
|
+
// Clean all listeners keywordRNBridgeEmitter.removeAllListeners('onKeywordDetectionEvent');
|
|
76
|
+
|
|
77
|
+
const eventListener = instance.onKeywordDetectionEvent((phrase: string) => {
|
|
74
78
|
phrase = formatWakeWord(id);
|
|
75
79
|
console.log(`Instance ${id} detected: ${id} with phrase`, phrase);
|
|
76
80
|
// callback(phrase); Does not work on IOS
|
|
@@ -212,6 +216,8 @@ export const useModel = () => {
|
|
|
212
216
|
return () => {
|
|
213
217
|
if (isListening) {
|
|
214
218
|
stopListening();
|
|
219
|
+
// Clean all listeners keywordRNBridgeEmitter.removeAllListeners('onKeywordDetectionEvent');
|
|
220
|
+
removeAllRNBridgeListeners();
|
|
215
221
|
}
|
|
216
222
|
};
|
|
217
223
|
}, [isListening, stopListening]);
|