From a706bd1d413e4160917356ca3101dab3139e7a50 Mon Sep 17 00:00:00 2001 From: jamsch <12927717+jamsch@users.noreply.github.com> Date: Fri, 11 Oct 2024 14:18:43 +1300 Subject: [PATCH] fix typos --- ios/ExpoSpeechRecognitionModule.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ios/ExpoSpeechRecognitionModule.swift b/ios/ExpoSpeechRecognitionModule.swift index ce7f8fd..80438d8 100644 --- a/ios/ExpoSpeechRecognitionModule.swift +++ b/ios/ExpoSpeechRecognitionModule.swift @@ -139,7 +139,7 @@ public class ExpoSpeechRecognitionModule: Module { let currentLocale = await speechRecognizer?.getLocale() // Reset the previous result - self?.previousResult = nil + self.previousResult = nil // Re-create the speech recognizer when locales change if self.speechRecognizer == nil || currentLocale != options.lang { @@ -437,11 +437,13 @@ public class ExpoSpeechRecognitionModule: Module { if isFinal && results.isEmpty { // Hack for iOS 18 to avoid sending a "nomatch" event after the final-final result var previousResultWasFinal = false + var previousResultHadTranscriptions = false if #available(iOS 18.0, *), let previousResult = previousResult { previousResultWasFinal = previousResult.speechRecognitionMetadata?.speechDuration ?? 0 > 0 + previousResultHadTranscriptions = !previousResult.transcriptions.isEmpty } - if !previousResultWasFinal || previousResult?.transcriptions.isEmpty { + if !previousResultWasFinal || !previousResultHadTranscriptions { // https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition/nomatch_event // The nomatch event of the Web Speech API is fired // when the speech recognition service returns a final result with no significant recognition.