Skip to content

Commit

Permalink
fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
jamsch committed Oct 11, 2024
1 parent 1f18118 commit a706bd1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ios/ExpoSpeechRecognitionModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit a706bd1

Please sign in to comment.