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
refactor: split dictation formatting toggles
altic-devac394ada73df
diff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swiftindex 242ae4da..17cee7da 100644--- a/Sources/Fluid/ContentView.swift+++ b/Sources/Fluid/ContentView.swift@@ -1444,9 +1444,8 @@ struct ContentView: View {source: "ContentView")- // Capture text before the caret for Continuous Dictation Mode smart caps.- // Only read the field when the feature is enabled (low-resource: one AX round-trip).- if SettingsStore.shared.continuousDictationModeEnabled {+ // Capture text before the caret only when formatting needs focused-field context.+ if SettingsStore.shared.needsDictationFormattingContext {self.recordingPrecedingText = TypingService.textBeforeCursorInFocusedField()DebugLogger.shared.debug("Captured preceding text for continuous dictation (chars=\(self.recordingPrecedingText.count))",@@ -2371,7 +2370,7 @@ struct ContentView: View {}let gaavText = ASRService.applyGAAVFormatting(text)- let precedingText = SettingsStore.shared.continuousDictationModeEnabled+ let precedingText = SettingsStore.shared.needsDictationFormattingContext? TypingService.textBeforeCursorInFocusedField(): ""let finalText = ASRService.applyContinuousDictationFormatting(gaavText, precedingText: precedingText)diff --git a/Sources/Fluid/Persistence/BackupService.swift b/Sources/Fluid/Persistence/BackupService.swiftindex 1a3ea706..d53523e6 100644--- a/Sources/Fluid/Persistence/BackupService.swift+++ b/Sources/Fluid/Persistence/BackupService.swift@@ -67,7 +67,11 @@ struct SettingsBackupPayload: Codable, Equatable {let fillerWords: [String]let removeFillerWordsEnabled: Boollet gaavModeEnabled: Bool- let continuousDictationModeEnabled: Bool+ let gaavLowercaseFirstLetterEnabled: Bool?+ let gaavRemoveTrailingPeriodEnabled: Bool?+ let continuousDictationModeEnabled: Bool?+ let continuousDictationSpacingEnabled: Bool?+ let contextAwareCapitalizationEnabled: Bool?let pauseMediaDuringTranscription: Boollet vocabularyBoostingEnabled: Boollet customDictionaryEntries: [SettingsStore.CustomDictionaryEntry]diff --git a/Sources/Fluid/Persistence/SettingsStore.swift b/Sources/Fluid/Persistence/SettingsStore.swiftindex d799b240..74e99df2 100644--- a/Sources/Fluid/Persistence/SettingsStore.swift+++ b/Sources/Fluid/Persistence/SettingsStore.swift@@ -2688,7 +2688,11 @@ final class SettingsStore: ObservableObject {fillerWords: self.fillerWords,removeFillerWordsEnabled: self.removeFillerWordsEnabled,gaavModeEnabled: self.gaavModeEnabled,+ gaavLowercaseFirstLetterEnabled: self.gaavLowercaseFirstLetterEnabled,+ gaavRemoveTrailingPeriodEnabled: self.gaavRemoveTrailingPeriodEnabled,continuousDictationModeEnabled: self.continuousDictationModeEnabled,+ continuousDictationSpacingEnabled: self.continuousDictationSpacingEnabled,+ contextAwareCapitalizationEnabled: self.contextAwareCapitalizationEnabled,pauseMediaDuringTranscription: self.pauseMediaDuringTranscription,vocabularyBoostingEnabled: self.vocabularyBoostingEnabled,customDictionaryEntries: self.customDictionaryEntries,@@ -2780,7 +2784,21 @@ final class SettingsStore: ObservableObject {self.fillerWords = payload.fillerWordsself.removeFillerWordsEnabled = payload.removeFillerWordsEnabledself.gaavModeEnabled = payload.gaavModeEnabled- self.continuousDictationModeEnabled = payload.continuousDictationModeEnabled+ if let gaavLowercaseFirstLetterEnabled = payload.gaavLowercaseFirstLetterEnabled {+ self.gaavLowercaseFirstLetterEnabled = gaavLowercaseFirstLetterEnabled+ }+ if let gaavRemoveTrailingPeriodEnabled = payload.gaavRemoveTrailingPeriodEnabled {+ self.gaavRemoveTrailingPeriodEnabled = gaavRemoveTrailingPeriodEnabled+ }+ if let continuousDictationModeEnabled = payload.continuousDictationModeEnabled {+ self.continuousDictationModeEnabled = continuousDictationModeEnabled+ }+ if let continuousDictationSpacingEnabled = payload.continuousDictationSpacingEnabled {+ self.continuousDictationSpacingEnabled = continuousDictationSpacingEnabled+ }+ if let contextAwareCapitalizationEnabled = payload.contextAwareCapitalizationEnabled {+ self.contextAwareCapitalizationEnabled = contextAwareCapitalizationEnabled+ }self.pauseMediaDuringTranscription = payload.pauseMediaDuringTranscriptionself.vocabularyBoostingEnabled = payload.vocabularyBoostingEnabledself.customDictionaryEntries = payload.customDictionaryEntries@@ -3363,9 +3381,7 @@ final class SettingsStore: ObservableObject {// MARK: - GAAV Mode- /// GAAV Mode: Removes first letter capitalization and trailing period from transcriptions.- /// Useful for search queries, form fields, or casual text input where sentence formatting is unwanted.- /// Feature requested by maxgaav – thank you for the suggestion!+ /// Legacy combined GAAV setting. New behavior uses the split formatting toggles below.var gaavModeEnabled: Bool {get { self.defaults.object(forKey: Keys.gaavModeEnabled) as? Bool ?? false }set {@@ -3374,12 +3390,29 @@ final class SettingsStore: ObservableObject {}}+ var gaavLowercaseFirstLetterEnabled: Bool {+ get {+ self.defaults.object(forKey: Keys.gaavLowercaseFirstLetterEnabled) as? Bool ?? self.gaavModeEnabled+ }+ set {+ objectWillChange.send()+ self.defaults.set(newValue, forKey: Keys.gaavLowercaseFirstLetterEnabled)+ }+ }++ var gaavRemoveTrailingPeriodEnabled: Bool {+ get {+ self.defaults.object(forKey: Keys.gaavRemoveTrailingPeriodEnabled) as? Bool ?? self.gaavModeEnabled+ }+ set {+ objectWillChange.send()+ self.defaults.set(newValue, forKey: Keys.gaavRemoveTrailingPeriodEnabled)+ }+ }+// MARK: - Continuous Dictation Mode- /// Continuous Dictation Mode: Appends a trailing space to transcriptions and adjusts- /// capitalization based on the text already in the focused field, so multiple dictation- /// segments chain naturally without manual spacebar presses.- /// Implements the chaining behavior requested in GitHub issue #390.+ /// Legacy combined continuous-dictation setting. New behavior uses the split toggles below.var continuousDictationModeEnabled: Bool {get { self.defaults.object(forKey: Keys.continuousDictationModeEnabled) as? Bool ?? false }set {@@ -3388,6 +3421,30 @@ final class SettingsStore: ObservableObject {}}+ var continuousDictationSpacingEnabled: Bool {+ get {+ self.defaults.object(forKey: Keys.continuousDictationSpacingEnabled) as? Bool ?? self.continuousDictationModeEnabled+ }+ set {+ objectWillChange.send()+ self.defaults.set(newValue, forKey: Keys.continuousDictationSpacingEnabled)+ }+ }++ var contextAwareCapitalizationEnabled: Bool {+ get {+ self.defaults.object(forKey: Keys.contextAwareCapitalizationEnabled) as? Bool ?? self.continuousDictationModeEnabled+ }+ set {+ objectWillChange.send()+ self.defaults.set(newValue, forKey: Keys.contextAwareCapitalizationEnabled)+ }+ }++ var needsDictationFormattingContext: Bool {+ self.continuousDictationSpacingEnabled || self.contextAwareCapitalizationEnabled+ }+// MARK: - Media Playback Control/// When enabled, automatically pauses system media playback when transcription starts.@@ -4219,9 +4276,13 @@ private extension SettingsStore {/// GAAV Mode (removes capitalization and trailing punctuation)static let gaavModeEnabled = "GAAVModeEnabled"+ static let gaavLowercaseFirstLetterEnabled = "GAAVLowercaseFirstLetterEnabled"+ static let gaavRemoveTrailingPeriodEnabled = "GAAVRemoveTrailingPeriodEnabled"/// Continuous Dictation Mode (append trailing space + smart caps for chaining)static let continuousDictationModeEnabled = "ContinuousDictationModeEnabled"+ static let continuousDictationSpacingEnabled = "ContinuousDictationSpacingEnabled"+ static let contextAwareCapitalizationEnabled = "ContextAwareCapitalizationEnabled"// Custom Dictionarystatic let customDictionaryEntries = "CustomDictionaryEntries"diff --git a/Sources/Fluid/Services/ASRService.swift b/Sources/Fluid/Services/ASRService.swiftindex 7c9bf61b..2231ac1f 100644--- a/Sources/Fluid/Services/ASRService.swift+++ b/Sources/Fluid/Services/ASRService.swift@@ -2906,18 +2906,15 @@ final class ASRService: ObservableObject {////// Feature requested by maxgaav – thank you for the suggestion!static func applyGAAVFormatting(_ text: String) -> String {- guard SettingsStore.shared.gaavModeEnabled else { return text }guard !text.isEmpty else { return text }var result = text- // Remove trailing period (if present)- if result.hasSuffix(".") {+ if SettingsStore.shared.gaavRemoveTrailingPeriodEnabled, result.hasSuffix(".") {result.removeLast()}- // Lowercase the first character (if it's uppercase)- if let first = result.first, first.isUppercase {+ if SettingsStore.shared.gaavLowercaseFirstLetterEnabled, let first = result.first, first.isUppercase {result = first.lowercased() + result.dropFirst()}@@ -2926,43 +2923,38 @@ final class ASRService: ObservableObject {// MARK: - Continuous Dictation Mode Formatting- /// Applies Continuous Dictation Mode formatting so transcribed segments chain naturally.- /// - Appends a trailing space so the next dictation continues without a manual spacebar press.- /// - Adjusts capitalization based on the text already in the field: if the preceding text- /// (after trimming trailing whitespace) ends with sentence-ending punctuation (.!?), the- /// first character is capitalized; otherwise it is lowercased so segments flow inline.- /// An empty field is treated as a sentence start (capitalized).- /// Only applied when `continuousDictationModeEnabled` is on.+ /// Applies split continuous-dictation formatting so transcribed segments chain naturally.+ /// Spacing and context-aware capitalization are independently controlled.////// Implements the chaining behavior requested in GitHub issue #390.static func applyContinuousDictationFormatting(_ text: String, precedingText: String) -> String {- guard SettingsStore.shared.continuousDictationModeEnabled else { return text }guard !text.isEmpty else { return text }+ let spacingEnabled = SettingsStore.shared.continuousDictationSpacingEnabled+ let smartCapsEnabled = SettingsStore.shared.contextAwareCapitalizationEnabled+ guard spacingEnabled || smartCapsEnabled else { return text }var result = text- let precedingTrimmed = precedingText.trimmingCharacters(in: .whitespacesAndNewlines)- if precedingTrimmed.isEmpty {- result = self.replacingFirstLetter(in: result, transform: { $0.uppercased() })- } else if let lastChar = precedingTrimmed.last, lastChar.isLetter || lastChar.isNumber {- // Last char before cursor is alphanumeric (no terminal punctuation): lowercase the- // first character so this segment flows inline with the existing text.- result = self.replacingFirstLetter(in: result, transform: { $0.lowercased() })- }- // If preceding text ends with .!? (or any other punctuation), leave the model's- // capitalization as-is (sentence start).-- // Add a separator when continuing after existing inline text, then leave a trailing- // space so the next dictation can chain without a manual spacebar press.- if let lastPreceding = precedingText.last,- !lastPreceding.isWhitespace,- result.first?.isWhitespace != true- {- result = " " + result+ if smartCapsEnabled {+ let precedingTrimmed = precedingText.trimmingCharacters(in: .whitespacesAndNewlines)+ if precedingTrimmed.isEmpty || precedingTrimmed.last?.isSentenceEndingPunctuation == true {+ result = self.replacingFirstLetter(in: result, transform: { $0.uppercased() })+ } else {+ result = self.replacingFirstLetter(in: result, transform: { $0.lowercased() })+ }}- if result.last?.isWhitespace != true {- result += " "+ if spacingEnabled {+ if let lastPreceding = precedingText.last,+ !lastPreceding.isWhitespace,+ result.first?.isWhitespace != true+ {+ result = " " + result+ }++ if result.last?.isWhitespace != true {+ result += " "+ }}return result@@ -2975,6 +2967,12 @@ final class ASRService: ObservableObject {}}+private extension Character {+ var isSentenceEndingPunctuation: Bool {+ self == "." || self == "!" || self == "?"+ }+}+// swiftlint:enable type_body_lengthprivate extension SettingsStore.SpeechModel {diff --git a/Sources/Fluid/UI/SettingsView.swift b/Sources/Fluid/UI/SettingsView.swiftindex 2acc0f94..323a8a86 100644--- a/Sources/Fluid/UI/SettingsView.swift+++ b/Sources/Fluid/UI/SettingsView.swift@@ -868,22 +868,41 @@ struct SettingsView: View {Divider().opacity(0.2)self.optionToggleRow(- title: "GAAV Mode",- description: "Remove first letter capitalization and trailing period. Useful for search queries, form fields, or casual text.\nFeature requested by MaxGaav.",+ title: "Lowercase First Letter",+ description: "Start each transcription with a lowercase letter. Useful for search queries, form fields, or casual text.",isOn: Binding(- get: { SettingsStore.shared.gaavModeEnabled },- set: { SettingsStore.shared.gaavModeEnabled = $0 }+ get: { SettingsStore.shared.gaavLowercaseFirstLetterEnabled },+ set: { SettingsStore.shared.gaavLowercaseFirstLetterEnabled = $0 }))Divider().opacity(0.2)self.optionToggleRow(- title: "Continuous Dictation Mode",- description: "Append a trailing space and adjust capitalization so consecutive dictations chain naturally. "- + "Smart caps: if the text in the field ends with a period, the next segment starts capitalized; otherwise it flows inline.",+ title: "Remove Trailing Period",+ description: "Drop a final period from transcriptions. Feature requested by MaxGaav.",isOn: Binding(- get: { SettingsStore.shared.continuousDictationModeEnabled },- set: { SettingsStore.shared.continuousDictationModeEnabled = $0 }+ get: { SettingsStore.shared.gaavRemoveTrailingPeriodEnabled },+ set: { SettingsStore.shared.gaavRemoveTrailingPeriodEnabled = $0 }+ )+ )+ Divider().opacity(0.2)++ self.optionToggleRow(+ title: "Space Between Dictations",+ description: "Add spacing so consecutive dictations chain without manually pressing the spacebar.",+ isOn: Binding(+ get: { SettingsStore.shared.continuousDictationSpacingEnabled },+ set: { SettingsStore.shared.continuousDictationSpacingEnabled = $0 }+ )+ )+ Divider().opacity(0.2)++ self.optionToggleRow(+ title: "Smart Capitalization",+ description: "Use text before the cursor to decide whether the next dictation should start capitalized or lowercase.",+ isOn: Binding(+ get: { SettingsStore.shared.contextAwareCapitalizationEnabled },+ set: { SettingsStore.shared.contextAwareCapitalizationEnabled = $0 }))Divider().opacity(0.2)