Picovoice / porcupine

On-device wake word detection powered by deep learning
https://picovoice.ai/
Apache License 2.0
3.77k stars 499 forks source link

Porcupine with Expo Issue: ERROR Error while listening occurred [Error: unexpected code: undefined, message: Cannot read property 'fromBuiltInKeywords' of null] #1224

Closed wired87 closed 8 months ago

wired87 commented 8 months ago

Have you checked the docs and existing issues?

SDK

React Native

Porcupine package version

3.0.2

Framework version

React Native 0.71

Platform

Android

OS/Browser version

Android 13+

Describe the bug

Hey im facing the same issue as described here: https://github.com/Picovoice/porcupine/issues/1027 Im also (try) using Expo with Porcupine.

"expo": "~49.0.15",

Here is my code (followed the docs): `

let porcupineManager: PorcupineManager | undefined = undefined;

export const startListening = async () => { try { if (!porcupineManager) { console.log("Creating new PorcupineManager instance") porcupineManager = await PorcupineManager.fromBuiltInKeywords( PORCUPINE_API_KEY, [BuiltInKeywords.JARVIS], (keyword:number) => { console.log("Detected Keyword!"); // Code to run after Keyword detection }, () => {} ); } await porcupineManager?.start(); }catch (e:unknown) { if (e instanceof Error) { console.error("Error while listening occurred", e); } } };

export const stopListening = async () => { if (porcupineManager) { await porcupineManager.stop(); porcupineManager = undefined; } };

const detectedKeyWord = async ( detected: boolean, setDetected: Dispatch<SetStateAction> ) => { if (detected) { return } setDetected(true); // start processing

} `

On my Screen Component: // VOICE LISTENER LOGIC useEffect(() => { if (route.name === "EX1" || route.name === "EX2") { startListening() .then(() => { console.log("Start listening..."); } ) }else { stopListening() .then(() => { console.log("Route name changed Stop Listening..."); } ) } }, [route.name]);

UPDATE: I JUST FORGOT TO REBUILD THE APPLICATION! NOW EVERYTHIING IS WORKING THIS ISSUE CAN BE CLOSED!

Steps To Reproduce

1. Played around with some BuiltInKeywords 2. reinstalled the pckg

Expected Behavior

It should start liatening

ErisMik commented 8 months ago

I'm glad you found a solution to your issue!

wired87 commented 8 months ago

I'm glad you found a solution to your issue!

I'm glad you have developed such a fantastic piece of Software. Thank you!