Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more
fix: handle continuous dictation context edges
altic-devebf7a9a8cdd5
diff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swiftindex 5c9c24aa..706ebb37 100644--- a/Sources/Fluid/ContentView.swift+++ b/Sources/Fluid/ContentView.swift@@ -2457,7 +2457,10 @@ struct ContentView: View {self.menuBarManager.setProcessing(false)finalText = ASRService.applyGAAVFormatting(finalText)- finalText = ASRService.applyContinuousDictationFormatting(finalText, precedingText: self.recordingPrecedingText)+ let precedingText = SettingsStore.shared.needsDictationFormattingContext+ ? TypingService.textBeforeCursorInFocusedField()+ : ""+ finalText = ASRService.applyContinuousDictationFormatting(finalText, precedingText: precedingText)self.recordingPrecedingText = ""if SettingsStore.shared.saveTranscriptionHistory {diff --git a/Sources/Fluid/Services/ASRService.swift b/Sources/Fluid/Services/ASRService.swiftindex 2231ac1f..6b21b482 100644--- a/Sources/Fluid/Services/ASRService.swift+++ b/Sources/Fluid/Services/ASRService.swift@@ -2936,8 +2936,9 @@ final class ASRService: ObservableObject {var result = textif smartCapsEnabled {- let precedingTrimmed = precedingText.trimmingCharacters(in: .whitespacesAndNewlines)- if precedingTrimmed.isEmpty || precedingTrimmed.last?.isSentenceEndingPunctuation == true {+ let precedingTrimmed = precedingText.trimmingCharacters(in: .whitespaces)+ let boundaryCharacter = self.lastCapitalizationBoundaryCharacter(in: precedingTrimmed)+ if boundaryCharacter == nil || boundaryCharacter?.isSentenceEndingPunctuation == true {result = self.replacingFirstLetter(in: result, transform: { $0.uppercased() })} else {result = self.replacingFirstLetter(in: result, transform: { $0.lowercased() })@@ -2960,6 +2961,19 @@ final class ASRService: ObservableObject {return result}+ private static func lastCapitalizationBoundaryCharacter(in text: String) -> Character? {+ for character in text.reversed() {+ if character.isNewline {+ return nil+ }+ if character.isHorizontalWhitespace || character.isClosingPunctuationWrapper {+ continue+ }+ return character+ }+ return nil+ }+private static func replacingFirstLetter(in text: String, transform: (Character) -> String) -> String {guard let index = text.firstIndex(where: { $0.isLetter }) else { return text }let nextIndex = text.index(after: index)@@ -2971,6 +2985,19 @@ private extension Character {var isSentenceEndingPunctuation: Bool {self == "." || self == "!" || self == "?"}++ var isHorizontalWhitespace: Bool {+ self.unicodeScalars.allSatisfy { CharacterSet.whitespaces.contains($0) }+ }++ var isClosingPunctuationWrapper: Bool {+ switch self {+ case "\"", "'", "”", "’", "»", "›", ")", "]", "}", "」", "』":+ return true+ default:+ return false+ }+ }}// swiftlint:enable type_body_length