























@@ -230,15 +230,23 @@ final class VoiceWakeTester {
230230if self.holdingAfterDetect {
231231return
232232}
233-if let match, !match.command.isEmpty {
233+let triggerOnlyMatch = match == nil
234+? VoiceWakeRecognitionDebugSupport.triggerOnlyFallbackMatch(
235+ transcript: text,
236+ triggers: self.currentTriggers,
237+ trimWake: WakeWordGate.stripWake)
238+: nil
239+let acceptedMatch = match.flatMap { $0.command.isEmpty ? nil : $0 } ?? triggerOnlyMatch
240+if let match = acceptedMatch {
234241self.holdingAfterDetect = true
235-self.detectedText = match.command
236-self.logger.info("voice wake detected (test) (len=\(match.command.count))")
242+let detectedText = match.command.isEmpty ? (match.trigger ?? text) : match.command
243+self.detectedText = detectedText
244+self.logger.info("voice wake detected (test) (len=\(detectedText.count))")
237245await MainActor.run { AppStateStore.shared.triggerVoiceEars(ttl: nil) }
238246self.stop()
239247await MainActor.run {
240248AppStateStore.shared.stopVoiceEars()
241-onUpdate(.detected(match.command))
249+onUpdate(.detected(detectedText))
242250}
243251return
244252}
@@ -399,20 +407,26 @@ final class VoiceWakeTester {
399407guard !self.isStopping, !self.holdingAfterDetect else { return }
400408guard let lastSeenAt, let lastText else { return }
401409guard self.lastTranscriptAt == lastSeenAt, self.lastTranscript == lastText else { return }
402-guard let match = VoiceWakeRecognitionDebugSupport.textOnlyFallbackMatch(
410+let gateConfig = WakeWordGateConfig(triggers: triggers)
411+let match = VoiceWakeRecognitionDebugSupport.textOnlyFallbackMatch(
403412 transcript: lastText,
404413 triggers: triggers,
405- config: WakeWordGateConfig(triggers: triggers),
414+ config: gateConfig,
406415 trimWake: WakeWordGate.stripWake)
407-else { return }
416+?? VoiceWakeRecognitionDebugSupport.triggerOnlyFallbackMatch(
417+ transcript: lastText,
418+ triggers: triggers,
419+ trimWake: WakeWordGate.stripWake)
420+guard let match else { return }
408421self.holdingAfterDetect = true
409-self.detectedText = match.command
410-self.logger.info("voice wake detected (test, silence) (len=\(match.command.count))")
422+let detectedText = match.command.isEmpty ? (match.trigger ?? lastText) : match.command
423+self.detectedText = detectedText
424+self.logger.info("voice wake detected (test, silence) (len=\(detectedText.count))")
411425await MainActor.run { AppStateStore.shared.triggerVoiceEars(ttl: nil) }
412426self.stop()
413427await MainActor.run {
414428AppStateStore.shared.stopVoiceEars()
415-onUpdate(.detected(match.command))
429+onUpdate(.detected(detectedText))
416430}
417431}
418432}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。