Closed TheFysionX closed 5 months ago
I am closing this issue because it seems to be confusing. Although the title suggests that there is an issue with our documentation (/doc/faq/general), the problem actually lies with one of our SDKs. Please open a new issue using our template so that I can assign it to the appropriate person.
I am getting this error:
Failed to initialize Porcupine: [Error: unexpected code: undefined, message: Cannot read property 'fromBuiltInKeywords' of null]
With this code :
import React, { useEffect, useState } from 'react'; import { View, Text, StyleSheet } from 'react-native'; import { PorcupineManager, BuiltInKeywords } from '@picovoice/porcupine-react-native';
import PageDefault from '../../components/PageDefault'; import DarkTheme from '../../themes/DarkTheme';
const SettingsScreen = () => { const [isListening, setIsListening] = useState(false); const [detectedWord, setDetectedWord] = useState(""); const [porcupineManager, setPorcupineManager] = useState(null);
const wakeWordCallback = (keywordIndex) => { if (keywordIndex === BuiltInKeywords.Porcupine) { setDetectedWord('Porcupine'); } else if (keywordIndex === BuiltInKeywords.Bumblebee) { setDetectedWord('Bumblebee'); } // Add other keywords you are interested in };
useEffect(() => { const accessKey = "MY API KEY WAS HERE"; // Replace with your Picovoice AccessKey
}, []);
return ( <PageDefault title="Wake Word Test" src={require('../../assets/images/backgrounds/Menu2.webp')}>
); };
const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', padding: 20, }, infoText: { fontSize: 24, fontFamily: DarkTheme.quadraFont, textAlign: 'center', color: DarkTheme.contrast, marginBottom: 10, }, detectedText: { fontSize: 24, fontFamily: DarkTheme.quadraFont, textAlign: 'center', color: DarkTheme.green, marginTop: 20, }, });
export default SettingsScreen;
I cannot find any explanation as to why this is occurring at all. I cannot use fromKeywordPaths either as that also returns the same error. The docs and the github give completely different ways to do the same thing and neither of them work at all. I have tried everything under the sun. There is no alternative for wake word detection for mobile and there is no solution to my error, I cannot find any other understand the error at all. What is going on and what do I do?