voice
voice copied to clipboard
Every-time a new sentence is recognised it replaces the previously recognised text
export const SpeechRecognition = (props: any) => {
useEffect(() => {
Voice.onSpeechStart = startListening;
Voice.onSpeechEnd = stopListening;
Voice.onSpeechResults = onSpeechResults;
Voice.onSpeechError = (err) =>
console.error('err in chatai component', err);
return () => {
Voice.destroy().then(Voice.removeAllListeners);
};
}, []);
const onSpeechResults = (e: any) => {
const text = e.value[0];
setRecognizedText(text);
};
const startListening = async () => {
try {
await Voice.start('en-US');
setIsListening(true);
} 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);
}
};
}
The logs look something like this LOG textttt===>>> {"value": ["But the data was coming"]} LOG textttt===>>> {"value": ["Once"]} LOG textttt===>>> {"value": ["Once I"]} LOG textttt===>>> {"value": ["Once I made"]}
Expected result LOG textttt===>>> {"value": ["But the data was coming Once I made"]}
This mostly happens for Iphone above 13
this is a bug only happens in iOS 18.0, upgrade to 18.1 will fix this https://forums.developer.apple.com/forums/thread/762952
@AndyHuangWB Thank you
@AndyHuangWB is this issue specific to this package for iOS 18.0 versions?
Have you find any solution, I'm having same issue, I couldn't fix it
@Zecky-dev , nope, not sure though but I think it happens only in iOS 18.0 https://forums.developer.apple.com/forums/thread/762952