-
Notifications
You must be signed in to change notification settings - Fork 515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error starting voice recognition: [TypeError: Cannot read property 'startSpeech' of null] #523
Comments
same error did you find the solution |
you can fix this by running your project in java 11 if your react native project supports java 11 but right now it didn't work on java 17 on later version |
set the new architecture in your android/gradl.properties file, like this newArchEnabled=false |
@Prashantrajput11 , but its working fine the functionality , while build the apk , i got the build failed/issues. Reason: Task ':@react-native-voice_voice:bundleDebugAar' uses this output of task ':react-native-voice_voice:writeDebugAarMetadata' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. when i change the newArchEnable=true , it was build successful and created apk also, |
Same error here, doesn't work even with Java 11 and the newArchEnabled property in false |
Title: Error starting voice recognition: [TypeError: Cannot read property 'startSpeech' of null]
this project it based on java 17 and i'm using java 17 but this package runs on java if you have any solution then help me
I am facing the following error when attempting to use voice recognition with @react-native-voice/voice:
import React, { useState, useEffect } from 'react';
import { View, Text, Button } from 'react-native';
import Voice from '@react-native-voice/voice';
const VoiceDetection = () => {
const [recognizedText, setRecognizedText] = useState('');
const [isListening, setIsListening] = useState(false);
useEffect(() => {
Voice.onSpeechStart = onSpeechStart;
Voice.onSpeechEnd = onSpeechEnd;
Voice.onSpeechResults = onSpeechResults;
Voice.onSpeechError = onSpeechError;
}, []);
const startListening = async () => {
try {
setIsListening(true);
await Voice.start('en-US'); // You can change the locale to your desired language
} catch (error) {
console.error('Error starting voice recognition:', error);
}
};
const stopListening = async () => {
try {
await Voice.stop();
setIsListening(false);
} catch (error) {
console.error('Error stopping voice recognition:', error);
}
};
const onSpeechStart = (e) => {
console.log('Speech recognition started', e);
};
const onSpeechEnd = (e) => {
console.log('Speech recognition ended', e);
};
const onSpeechResults = (e) => {
const results = e.value;
if (results && results.length > 0) {
setRecognizedText(results[0]);
}
};
const onSpeechError = (e) => {
console.error('Speech recognition error', e);
};
return (
<Button
title={isListening ? 'Stop Listening' : 'Start Listening'}
onPress={isListening ? stopListening : startListening}
/>
Recognized Speech: {recognizedText}
);
};
export default VoiceDetection;
Error starting voice recognition: [TypeError: Cannot read property 'startSpeech' of null]
Steps to Reproduce:
Install the @react-native-voice/voice package and set it up as per the official documentation.
Call Voice.startSpeech() to initiate speech recognition.
Expected Behavior:
The speech recognition should start without any issues.
Actual Behavior:
I receive the error: [TypeError: Cannot read property 'startSpeech' of null], indicating that the Voice object is null when attempting to call startSpeech.
Environment:
React Native version: [Your RN version]
@react-native-voice/voice version: [Version you're using]
Platform: [Android/iOS version]
Permissions: Microphone permissions are granted.
Additional Information:
I have followed all the setup instructions from the official documentation.
The Voice object is null when trying to access startSpeech.
I have tried clearing the cache and rebuilding the project, but the issue persists.
The text was updated successfully, but these errors were encountered: