voice
voice copied to clipboard
fix iOS 18 bug where onSpeechEnd is never called
Refers to #517
Just a few notes on this PR (as I work on a similar library):
- There's a bit of functionality change here to how would previously have worked on iOS. I'm pretty sure on the current version of react-native-voice for iOS, speech recognition runs continuously. On Android it stops once you've paused for a second or two and processes a final result. This PR brings the functionality similar to Android.
- So the part where you have
transcript = [@" " stringByAppendingString:transcription.formattedString];is unnecessary as this is actually meant for continuous speech transcription where multiple final segments occur in a speech recognition task. - If this library does implement continous recognition, you'll also need to reset the
_hasSeenFinalResultvariable back to it's initial state once starting speech recognition, otherwise you'll see an extra prepended space on your second and subsequent speech recognition attempts, such as the following:
onSpeechPartialResults "this"
onSpeechPartialResults "this is"
onSpeechPartialResults "this is a"
onSpeechPartialResults "this is a demo"
onSpeechPartialResults "this is a demo"
onSpeechResults " this is a demo"
i copied same lines , it does not work for me
opening this up for collab
i dug into the Voice.m file
NSLog(@"%@",result); shows the following:
<SFSpeechRecognitionResult: 0x3027a9980> final=0, bestTranscription=<SFTranscription: 0x3032c8f60>, formattedString=Hello there, segments=(
"<SFTranscriptionSegment: 0x3019585a0>, substringRange={0, 5}, timestamp=0, duration=0.011, confidence=0, substring=Hello, alternativeSubstrings=(\n), phoneSequence=, ipaPhoneSequence=, voiceAnalytics=(null)",
"<SFTranscriptionSegment: 0x301958c00>, substringRange={6, 5}, timestamp=0.011, duration=0.011, confidence=0, substring=there, alternativeSubstrings=(\n), phoneSequence=, ipaPhoneSequence=, voiceAnalytics=(null)"
), speakingRate=0.000000, averagePauseDuration=0.000000, speechRecognitionMetadata=(null)
result.speechRecognitionMetadata always returns null
and result.final always returns 0
is there a way to dig further into the root cause for why these values do not change?
RN: 0.76.5 ios: 18.2