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
feat: convert spoken punctuation
altic-devf01b67c81373
diff --git a/.github/screenshots/auto-convert-punctuation-toggle.png b/.github/screenshots/auto-convert-punctuation-toggle.pngnew file mode 100644index 00000000..1e00be26Binary files /dev/null and b/.github/screenshots/auto-convert-punctuation-toggle.png differdiff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swiftindex 90ef067c..df2c550d 100644--- a/Sources/Fluid/ContentView.swift+++ b/Sources/Fluid/ContentView.swift@@ -2786,7 +2786,8 @@ struct ContentView: View {NotchOverlayManager.shared.updateTranscriptionText("Reprocessing...")await Task.yield()- var finalText = transcribedText+ let normalizedTranscribedText = ASRService.applySpokenPunctuationFormatting(transcribedText)+ var finalText = normalizedTranscribedTextvar aiFallbackReason: String?var postProcessingModel: String?let appInfo = self.getCurrentAppInfo()@@ -2795,7 +2796,7 @@ struct ContentView: View {postProcessingModel = self.currentDictationAIModelInfo().modeldo {finalText = try await self.processTextWithAI(- transcribedText,+ normalizedTranscribedText,dictationSlot: .primary)} catch {@@ -2805,7 +2806,7 @@ struct ContentView: View {)aiFallbackReason = error.localizedDescriptionNotificationService.showAIProcessingFallback(error: error.localizedDescription)- finalText = transcribedText+ finalText = normalizedTranscribedText}}diff --git a/Sources/Fluid/Persistence/BackupService.swift b/Sources/Fluid/Persistence/BackupService.swiftindex 8d0b595a..f69a7966 100644--- a/Sources/Fluid/Persistence/BackupService.swift+++ b/Sources/Fluid/Persistence/BackupService.swift@@ -74,6 +74,7 @@ struct SettingsBackupPayload: Codable, Equatable {let weekendsDontBreakStreak: Boollet fillerWords: [String]let removeFillerWordsEnabled: Bool+ let autoConvertPunctuationEnabled: Bool?let gaavModeEnabled: Boollet gaavLowercaseFirstLetterEnabled: Bool?let gaavRemoveTrailingPeriodEnabled: Bool?diff --git a/Sources/Fluid/Persistence/SettingsStore.swift b/Sources/Fluid/Persistence/SettingsStore.swiftindex 6cf27640..d2ee5a68 100644--- a/Sources/Fluid/Persistence/SettingsStore.swift+++ b/Sources/Fluid/Persistence/SettingsStore.swift@@ -2860,6 +2860,7 @@ final class SettingsStore: ObservableObject {weekendsDontBreakStreak: self.weekendsDontBreakStreak,fillerWords: self.fillerWords,removeFillerWordsEnabled: self.removeFillerWordsEnabled,+ autoConvertPunctuationEnabled: self.autoConvertPunctuationEnabled,gaavModeEnabled: self.gaavModeEnabled,gaavLowercaseFirstLetterEnabled: self.gaavLowercaseFirstLetterEnabled,gaavRemoveTrailingPeriodEnabled: self.gaavRemoveTrailingPeriodEnabled,@@ -2970,6 +2971,9 @@ final class SettingsStore: ObservableObject {self.weekendsDontBreakStreak = payload.weekendsDontBreakStreakself.fillerWords = payload.fillerWordsself.removeFillerWordsEnabled = payload.removeFillerWordsEnabled+ if let autoConvertPunctuationEnabled = payload.autoConvertPunctuationEnabled {+ self.autoConvertPunctuationEnabled = autoConvertPunctuationEnabled+ }let restoredGaavModeEnabled = payload.gaavModeEnabledlet restoredContinuousDictationModeEnabled = payload.continuousDictationModeEnabled ?? falseself.gaavModeEnabled = restoredGaavModeEnabled@@ -3570,6 +3574,14 @@ final class SettingsStore: ObservableObject {}}+ var autoConvertPunctuationEnabled: Bool {+ get { self.defaults.object(forKey: Keys.autoConvertPunctuationEnabled) as? Bool ?? true }+ set {+ objectWillChange.send()+ self.defaults.set(newValue, forKey: Keys.autoConvertPunctuationEnabled)+ }+ }+// MARK: - GAAV Mode/// Legacy combined GAAV setting. New behavior uses the split formatting toggles below.@@ -4513,6 +4525,7 @@ private extension SettingsStore {// Filler Wordsstatic let fillerWords = "FillerWords"static let removeFillerWordsEnabled = "RemoveFillerWordsEnabled"+ static let autoConvertPunctuationEnabled = "AutoConvertPunctuationEnabled"/// GAAV Mode (removes capitalization and trailing punctuation)static let gaavModeEnabled = "GAAVModeEnabled"diff --git a/Sources/Fluid/Services/ASRService+SpokenPunctuationFormatting.swift b/Sources/Fluid/Services/ASRService+SpokenPunctuationFormatting.swiftnew file mode 100644index 00000000..87f55103--- /dev/null+++ b/Sources/Fluid/Services/ASRService+SpokenPunctuationFormatting.swift@@ -0,0 +1,631 @@+import Foundation++extension ASRService {+ static func applySpokenPunctuationFormatting(_ text: String) -> String {+ guard SettingsStore.shared.autoConvertPunctuationEnabled else { return text }+ return SpokenPunctuationFormatter.apply(text)+ }+}++private enum SpokenPunctuationFormatter {+ private enum Spacing {+ case rightAttached+ case leftAttached+ case noSpaceAround+ case spaceAround+ case toggleDoubleQuote+ case toggleSingleQuote+ }++ private struct PhraseRule {+ let words: [String]+ let symbol: String+ let spacing: Spacing+ var requiresSymbolContext = false+ }++ private enum Token {+ case word(original: String, normalized: String)+ case text(String)++ var normalizedWord: String? {+ if case let .word(_, normalized) = self { return normalized }+ return nil+ }++ var text: String? {+ switch self {+ case let .word(original, _):+ return original+ case let .text(text):+ return text+ }+ }++ var isHorizontalWhitespaceText: Bool {+ guard case let .text(text) = self, !text.isEmpty else { return false }+ return text.allSatisfy(\.isHorizontalWhitespace)+ }+ }++ private enum OutputPart {+ case text(String)+ case punctuation(symbol: String, spacing: Spacing)+ }++ private static let rulesByFirstWord: [String: [PhraseRule]] = {+ let rules = Self.makeRules()+ let grouped = Dictionary(grouping: rules) { $0.words.first ?? "" }+ return grouped.mapValues {+ $0.sorted {+ if $0.words.count != $1.words.count { return $0.words.count > $1.words.count }+ return $0.words.joined(separator: " ").count > $1.words.joined(separator: " ").count+ }+ }+ }()++ static func apply(_ text: String) -> String {+ guard !text.isEmpty else { return text }++ let tokens = self.tokenize(text)+ guard tokens.contains(where: { $0.normalizedWord != nil }) else {+ return self.cleanSymbolCommaNoise(in: text)+ }++ var output: [OutputPart] = []+ var index = 0+ while index < tokens.count {+ if let match = self.matchRule(in: tokens, at: index) {+ output.append(.punctuation(symbol: match.rule.symbol, spacing: match.rule.spacing))+ index = match.endIndex+ } else if let text = tokens[index].text {+ output.append(.text(text))+ index += 1+ } else {+ index += 1+ }+ }++ return self.cleanSymbolCommaNoise(in: self.render(output))+ }++ private static func makeRules() -> [PhraseRule] {+ self.rules(+ symbol: ",",+ spacing: .rightAttached,+ phrases: ["comma"]+ ) ++ self.rules(+ symbol: ".",+ spacing: .rightAttached,+ phrases: ["period", "full stop"]+ ) ++ self.rules(+ symbol: ".",+ spacing: .noSpaceAround,+ phrases: ["dot"]+ ) ++ self.rules(+ symbol: "?",+ spacing: .rightAttached,+ phrases: ["question mark", "questionmark"]+ ) ++ self.rules(+ symbol: "!",+ spacing: .rightAttached,+ phrases: ["exclamation mark", "exclamation point", "bang"]+ ) ++ self.rules(+ symbol: ":",+ spacing: .rightAttached,+ phrases: ["colon"]+ ) ++ self.rules(+ symbol: ";",+ spacing: .rightAttached,+ phrases: ["semicolon", "semi colon"]+ ) ++ self.rules(+ symbol: "...",+ spacing: .rightAttached,+ phrases: ["ellipsis", "dot dot dot", "three dots"]+ ) ++ self.rules(+ symbol: "/",+ spacing: .noSpaceAround,+ phrases: ["slash", "forward slash", "forwardslash"]+ ) ++ self.rules(+ symbol: "\\",+ spacing: .noSpaceAround,+ phrases: ["backslash", "back slash"]+ ) ++ self.rules(+ symbol: "-",+ spacing: .noSpaceAround,+ phrases: ["hyphen"]+ ) ++ self.rules(+ symbol: "-",+ spacing: .spaceAround,+ phrases: ["dash", "minus sign"]+ ) ++ self.rules(+ symbol: "—",+ spacing: .spaceAround,+ phrases: ["em dash", "long dash"]+ ) ++ self.rules(+ symbol: "–",+ spacing: .spaceAround,+ phrases: ["en dash"]+ ) ++ self.rules(+ symbol: "(",+ spacing: .leftAttached,+ phrases: ["open parenthesis", "open parentheses", "left parenthesis", "left parentheses", "open paren", "left paren"]+ ) ++ self.rules(+ symbol: ")",+ spacing: .rightAttached,+ phrases: ["close parenthesis", "close parentheses", "right parenthesis", "right parentheses", "close paren", "right paren"]+ ) ++ self.rules(+ symbol: "[",+ spacing: .leftAttached,+ phrases: ["open bracket", "left bracket", "open square bracket", "left square bracket"]+ ) ++ self.rules(+ symbol: "]",+ spacing: .rightAttached,+ phrases: ["close bracket", "right bracket", "close square bracket", "right square bracket"]+ ) ++ self.rules(+ symbol: "{",+ spacing: .leftAttached,+ phrases: ["open brace", "left brace", "open curly brace", "left curly brace", "open curly bracket", "left curly bracket"]+ ) ++ self.rules(+ symbol: "}",+ spacing: .rightAttached,+ phrases: ["close brace", "right brace", "close curly brace", "right curly brace", "close curly bracket", "right curly bracket"]+ ) ++ self.rules(+ symbol: "<",+ spacing: .leftAttached,+ phrases: ["open angle bracket", "left angle bracket", "less than sign"]+ ) ++ self.rules(+ symbol: ">",+ spacing: .rightAttached,+ phrases: ["close angle bracket", "right angle bracket", "greater than sign"]+ ) ++ self.rules(+ symbol: "\"",+ spacing: .toggleDoubleQuote,+ phrases: ["quote", "quotes", "quotation mark", "double quote"]+ ) ++ self.rules(+ symbol: "\"",+ spacing: .leftAttached,+ phrases: ["open quote", "opening quote", "open double quote", "opening double quote"]+ ) ++ self.rules(+ symbol: "\"",+ spacing: .rightAttached,+ phrases: ["close quote", "closing quote", "close double quote", "closing double quote"]+ ) ++ self.rules(+ symbol: "'",+ spacing: .toggleSingleQuote,+ phrases: ["single quote"]+ ) ++ self.rules(+ symbol: "'",+ spacing: .noSpaceAround,+ phrases: ["apostrophe"]+ ) ++ self.rules(+ symbol: "@",+ spacing: .noSpaceAround,+ phrases: ["at sign", "at the rate", "commercial at"]+ ) ++ self.rules(+ symbol: "&",+ spacing: .spaceAround,+ phrases: ["ampersand", "and sign"]+ ) ++ self.rules(+ symbol: "+",+ spacing: .spaceAround,+ phrases: ["plus sign"]+ ) ++ self.rules(+ symbol: "+",+ spacing: .spaceAround,+ phrases: ["plus"],+ requiresSymbolContext: true+ ) ++ self.rules(+ symbol: "=",+ spacing: .spaceAround,+ phrases: ["equals sign", "equal sign"]+ ) ++ self.rules(+ symbol: "=",+ spacing: .spaceAround,+ phrases: ["equal", "equals"],+ requiresSymbolContext: true+ ) ++ self.rules(+ symbol: "%",+ spacing: .rightAttached,+ phrases: ["percent sign", "percentage sign", "percent"]+ ) ++ self.rules(+ symbol: "$",+ spacing: .leftAttached,+ phrases: ["dollar sign", "dollar"]+ ) ++ self.rules(+ symbol: "#",+ spacing: .noSpaceAround,+ phrases: ["hash", "hash sign", "hashtag", "pound sign", "number sign"]+ ) ++ self.rules(+ symbol: "*",+ spacing: .noSpaceAround,+ phrases: ["asterisk", "star symbol"]+ ) ++ self.rules(+ symbol: "_",+ spacing: .noSpaceAround,+ phrases: ["underscore"]+ ) ++ self.rules(+ symbol: "|",+ spacing: .noSpaceAround,+ phrases: ["pipe", "vertical bar"]+ ) ++ self.rules(+ symbol: "~",+ spacing: .noSpaceAround,+ phrases: ["tilde"]+ ) ++ self.rules(+ symbol: "^",+ spacing: .noSpaceAround,+ phrases: ["caret"]+ ) ++ self.rules(+ symbol: "`",+ spacing: .noSpaceAround,+ phrases: ["backtick", "back tick"]+ )+ }++ private static func rules(+ symbol: String,+ spacing: Spacing,+ phrases: [String],+ requiresSymbolContext: Bool = false+ ) -> [PhraseRule] {+ phrases.compactMap { phrase in+ let words = phrase+ .split(separator: " ")+ .map { String($0).lowercased() }+ .filter { !$0.isEmpty }+ guard !words.isEmpty else { return nil }+ return PhraseRule(+ words: words,+ symbol: symbol,+ spacing: spacing,+ requiresSymbolContext: requiresSymbolContext+ )+ }+ }++ private static func tokenize(_ text: String) -> [Token] {+ var tokens: [Token] = []+ var current = ""+ var isBuildingWord = false++ func flushCurrent() {+ guard !current.isEmpty else { return }+ if isBuildingWord {+ tokens.append(.word(original: current, normalized: current.lowercased()))+ } else {+ tokens.append(.text(current))+ }+ current = ""+ }++ for character in text {+ let isWord = character.isPunctuationPhraseWordCharacter+ if current.isEmpty {+ current.append(character)+ isBuildingWord = isWord+ } else if isWord == isBuildingWord {+ current.append(character)+ } else {+ flushCurrent()+ current.append(character)+ isBuildingWord = isWord+ }+ }+ flushCurrent()+ return tokens+ }++ private static func matchRule(in tokens: [Token], at index: Int) -> (rule: PhraseRule, endIndex: Int)? {+ guard let firstWord = tokens[index].normalizedWord,+ let candidates = self.rulesByFirstWord[firstWord]+ else {+ return nil+ }++ for rule in candidates {+ var cursor = index+ var matched = true+ for (wordIndex, expectedWord) in rule.words.enumerated() {+ if wordIndex > 0 {+ guard cursor < tokens.count, tokens[cursor].isHorizontalWhitespaceText else {+ matched = false+ break+ }+ while cursor < tokens.count, tokens[cursor].isHorizontalWhitespaceText {+ cursor += 1+ }+ }+ guard cursor < tokens.count, tokens[cursor].normalizedWord == expectedWord else {+ matched = false+ break+ }+ cursor += 1+ }+ if matched,+ !rule.requiresSymbolContext ||+ self.hasSymbolContext(in: tokens, startIndex: index, endIndex: cursor)+ {+ return (rule, cursor)+ }+ }++ return nil+ }++ private static func hasSymbolContext(in tokens: [Token], startIndex: Int, endIndex: Int) -> Bool {+ let previous = self.significantToken(before: startIndex, in: tokens)+ let next = self.significantToken(atOrAfter: endIndex, in: tokens)++ if let previous, let next {+ return self.isSymbolContextToken(previous) || self.isSymbolContextToken(next) ||+ (self.isShortSymbolOperand(previous) && self.isShortSymbolOperand(next))+ }++ if let previous {+ return self.isSymbolContextToken(previous)+ }++ if let next {+ return self.isSymbolContextToken(next)+ }++ return false+ }++ private static func significantToken(before index: Int, in tokens: [Token]) -> Token? {+ guard index > 0 else { return nil }+ var cursor = index - 1+ while cursor >= 0 {+ if !tokens[cursor].isHorizontalWhitespaceText {+ return tokens[cursor]+ }+ if cursor == 0 { break }+ cursor -= 1+ }+ return nil+ }++ private static func significantToken(atOrAfter index: Int, in tokens: [Token]) -> Token? {+ var cursor = index+ while cursor < tokens.count {+ if !tokens[cursor].isHorizontalWhitespaceText {+ return tokens[cursor]+ }+ cursor += 1+ }+ return nil+ }++ private static func isSymbolContextToken(_ token: Token) -> Bool {+ switch token {+ case let .word(_, normalized):+ return self.rulesByFirstWord[normalized]?.contains { $0.symbol != "," && $0.symbol != "." } == true+ case let .text(text):+ return text.contains { self.symbolCommaCleanupCharacters.contains($0) }+ }+ }++ private static func isShortSymbolOperand(_ token: Token) -> Bool {+ switch token {+ case let .word(_, normalized):+ return normalized.count <= 2 || normalized.allSatisfy(\.isASCIIDigit)+ case let .text(text):+ return text.contains { self.symbolCommaCleanupCharacters.contains($0) }+ }+ }++ private static func render(_ parts: [OutputPart]) -> String {+ var result = ""+ var index = 0+ var shouldOpenDoubleQuote = true+ var shouldOpenSingleQuote = true++ while index < parts.count {+ switch parts[index] {+ case let .text(text):+ result += text+ index += 1++ case let .punctuation(symbol, spacing):+ let resolvedSpacing: Spacing+ switch spacing {+ case .toggleDoubleQuote:+ resolvedSpacing = shouldOpenDoubleQuote ? .leftAttached : .rightAttached+ shouldOpenDoubleQuote.toggle()+ case .toggleSingleQuote:+ resolvedSpacing = shouldOpenSingleQuote ? .leftAttached : .rightAttached+ shouldOpenSingleQuote.toggle()+ default:+ resolvedSpacing = spacing+ }++ switch resolvedSpacing {+ case .rightAttached:+ self.removeTrailingHorizontalWhitespace(from: &result)+ result += symbol+ index += 1+ case .leftAttached:+ result += symbol+ index = self.indexSkippingWhitespace(after: index, in: parts)+ case .noSpaceAround:+ self.removeTrailingHorizontalWhitespace(from: &result)+ result += symbol+ index = self.indexSkippingWhitespace(after: index, in: parts)+ case .spaceAround:+ self.removeTrailingHorizontalWhitespace(from: &result)+ if !result.isEmpty, result.last?.isNewline != true {+ result += " "+ }+ result += symbol+ index = self.indexSkippingWhitespace(after: index, in: parts)+ if self.hasFollowingNonWhitespacePart(in: parts, from: index) {+ result += " "+ }+ case .toggleDoubleQuote, .toggleSingleQuote:+ index += 1+ }+ }+ }++ return result+ }++ private static func removeTrailingHorizontalWhitespace(from text: inout String) {+ while text.last?.isHorizontalWhitespace == true {+ text.removeLast()+ }+ }++ private static func indexSkippingWhitespace(after index: Int, in parts: [OutputPart]) -> Int {+ var nextIndex = index + 1+ while nextIndex < parts.count {+ guard case let .text(text) = parts[nextIndex], text.allSatisfy(\.isHorizontalWhitespace) else {+ break+ }+ nextIndex += 1+ }+ return nextIndex+ }++ private static func hasFollowingNonWhitespacePart(in parts: [OutputPart], from index: Int) -> Bool {+ guard index < parts.count else { return false }+ for part in parts[index...] {+ switch part {+ case let .text(text):+ if text.contains(where: { !$0.isHorizontalWhitespace }) {+ return true+ }+ case .punctuation:+ return true+ }+ }+ return false+ }++ private static let symbolCommaCleanupCharacters = Set<Character>(+ ["+", "=", "%", "-", "—", "–", "/", "\\", "@", "#", "$", "&", "*", "_", "|", "~", "^", "<", ">"]+ )++ private static func cleanSymbolCommaNoise(in text: String) -> String {+ guard text.contains(",") else { return text }++ var result = ""+ var index = text.startIndex+ while index < text.endIndex {+ let character = text[index]+ if character == ",",+ self.shouldRemoveComma(+ previous: self.previousNonWhitespaceCharacter(in: result),+ next: self.nextNonWhitespaceCharacter(in: text, after: index)+ )+ {+ index = self.indexAfterSkippableComma(+ in: text,+ at: index,+ previous: self.previousNonWhitespaceCharacter(in: result),+ next: self.nextNonWhitespaceCharacter(in: text, after: index)+ )+ } else {+ result.append(character)+ index = text.index(after: index)+ }+ }++ return result+ }++ private static func shouldRemoveComma(previous: Character?, next: Character?) -> Bool {+ previous.map { self.symbolCommaCleanupCharacters.contains($0) } == true ||+ next.map { self.symbolCommaCleanupCharacters.contains($0) } == true+ }++ private static func indexAfterSkippableComma(+ in text: String,+ at index: String.Index,+ previous: Character?,+ next: Character?+ ) -> String.Index {+ var nextIndex = text.index(after: index)+ if next == "%",+ previous?.isASCIIDigit == true+ {+ while nextIndex < text.endIndex, text[nextIndex].isHorizontalWhitespace {+ nextIndex = text.index(after: nextIndex)+ }+ }+ return nextIndex+ }++ private static func previousNonWhitespaceCharacter(in text: String) -> Character? {+ text.reversed().first { !$0.isHorizontalWhitespace }+ }++ private static func nextNonWhitespaceCharacter(in text: String, after index: String.Index) -> Character? {+ var cursor = text.index(after: index)+ while cursor < text.endIndex {+ let character = text[cursor]+ if !character.isHorizontalWhitespace {+ return character+ }+ cursor = text.index(after: cursor)+ }+ return nil+ }+}++private extension Character {+ var isPunctuationPhraseWordCharacter: Bool {+ self.unicodeScalars.allSatisfy { CharacterSet.alphanumerics.contains($0) }+ }++ var isHorizontalWhitespace: Bool {+ self.unicodeScalars.allSatisfy { CharacterSet.whitespaces.contains($0) }+ }++ var isASCIIDigit: Bool {+ guard self.unicodeScalars.count == 1, let scalar = self.unicodeScalars.first else { return false }+ return (48...57).contains(scalar.value)+ }+}diff --git a/Sources/Fluid/Services/ASRService.swift b/Sources/Fluid/Services/ASRService.swiftindex 6c5fbae6..8efdf471 100644--- a/Sources/Fluid/Services/ASRService.swift+++ b/Sources/Fluid/Services/ASRService.swift@@ -1511,9 +1511,12 @@ final class ASRService: ObservableObject {// Do not update self.finalText here to avoid instant binding insert in playgroundlet textWithoutFillers = ASRService.removeFillerWords(result.text)- let outputText = useDictionaryTrainingPath+ let dictionaryText = useDictionaryTrainingPath? textWithoutFillers: ASRService.applyCustomDictionary(textWithoutFillers)+ let outputText = useDictionaryTrainingPath+ ? dictionaryText+ : ASRService.applySpokenPunctuationFormatting(dictionaryText)if !useDictionaryTrainingPath {self.recordWordBoostHitIfAny(transcribedText: outputText)}@@ -1602,7 +1605,9 @@ final class ASRService: ObservableObject {self.modelPreparationPhase = nil}- let cleanedText = ASRService.applyCustomDictionary(ASRService.removeFillerWords(result.text))+ let cleanedText = ASRService.applySpokenPunctuationFormatting(+ ASRService.applyCustomDictionary(ASRService.removeFillerWords(result.text))+ )self.recordWordBoostHitIfAny(transcribedText: cleanedText)return ASRTranscriptionResult(text: cleanedText, confidence: result.confidence)}@@ -1644,7 +1649,9 @@ final class ASRService: ObservableObject {self.modelPreparationPhase = nil}- let cleanedText = ASRService.applyCustomDictionary(ASRService.removeFillerWords(result.text))+ let cleanedText = ASRService.applySpokenPunctuationFormatting(+ ASRService.applyCustomDictionary(ASRService.removeFillerWords(result.text))+ )self.recordWordBoostHitIfAny(transcribedText: cleanedText)return (ASRTranscriptionResult(text: cleanedText, confidence: result.confidence), estimatedSamples)}@@ -3205,7 +3212,9 @@ final class ASRService: ObservableObject {source: "ASRService")let rawText = result.text.trimmingCharacters(in: .whitespacesAndNewlines)- let newText = ASRService.applyCustomDictionary(ASRService.removeFillerWords(rawText))+ let newText = ASRService.applySpokenPunctuationFormatting(+ ASRService.applyCustomDictionary(ASRService.removeFillerWords(rawText))+ )self.recordWordBoostHitIfAny(transcribedText: newText)self.benchmarkCompletedStreamingChunks += 1self.lastProcessedSampleCount = chunk.countdiff --git a/Sources/Fluid/UI/AISettings/VoiceEngineSettingsViewModel.swift b/Sources/Fluid/UI/AISettings/VoiceEngineSettingsViewModel.swiftindex bd561f02..d54f64ee 100644--- a/Sources/Fluid/UI/AISettings/VoiceEngineSettingsViewModel.swift+++ b/Sources/Fluid/UI/AISettings/VoiceEngineSettingsViewModel.swift@@ -45,6 +45,7 @@ final class VoiceEngineSettingsViewModel: ObservableObject {}@Published var removeFillerWordsEnabled: Bool+ @Published var autoConvertPunctuationEnabled: Boolinit(settings: SettingsStore, appServices: AppServices) {self.settings = settings@@ -52,6 +53,7 @@ final class VoiceEngineSettingsViewModel: ObservableObject {self.previewSpeechModel = settings.selectedSpeechModelself.selectedSpeechProvider = settings.selectedSpeechModel.providerself.removeFillerWordsEnabled = settings.removeFillerWordsEnabled+ self.autoConvertPunctuationEnabled = settings.autoConvertPunctuationEnabledappServices.objectWillChange.sink { [weak self] _ inTask { @MainActor in@@ -65,6 +67,7 @@ final class VoiceEngineSettingsViewModel: ObservableObject {self.previewSpeechModel = self.settings.selectedSpeechModelself.selectedSpeechProvider = self.settings.selectedSpeechModel.providerself.removeFillerWordsEnabled = self.settings.removeFillerWordsEnabled+ self.autoConvertPunctuationEnabled = self.settings.autoConvertPunctuationEnabledTask {await self.asr.checkIfModelsExistAsync()diff --git a/Sources/Fluid/UI/AISettingsView+SpeechRecognition.swift b/Sources/Fluid/UI/AISettingsView+SpeechRecognition.swiftindex 131ffc5d..269c633e 100644--- a/Sources/Fluid/UI/AISettingsView+SpeechRecognition.swift+++ b/Sources/Fluid/UI/AISettingsView+SpeechRecognition.swift@@ -724,6 +724,27 @@ extension VoiceEngineSettingsView {var fillerWordsSection: some View {VStack(alignment: .leading, spacing: 8) {+ HStack(alignment: .center) {+ VStack(alignment: .leading, spacing: 2) {+ Text("Auto-Convert Punctuation")+ .font(self.theme.typography.bodyStrong)+ .foregroundStyle(self.voiceEngineTitleText)+ Text("Turn spoken punctuation like comma, slash, and at sign into symbols before AI cleanup")+ .font(self.theme.typography.bodySmall)+ .foregroundStyle(self.voiceEngineSecondaryText)+ }+ Spacer()+ Toggle("", isOn: self.$viewModel.autoConvertPunctuationEnabled)+ .toggleStyle(.switch)+ .labelsHidden()+ .onChange(of: self.viewModel.autoConvertPunctuationEnabled) { _, newValue in+ self.settings.autoConvertPunctuationEnabled = newValue+ }+ }++ Divider()+ .opacity(0.2)+HStack(alignment: .center) {VStack(alignment: .leading, spacing: 2) {Text("Remove Filler Words")diff --git a/Sources/Fluid/UI/SettingsView.swift b/Sources/Fluid/UI/SettingsView.swiftindex a7c2de7c..5b551d40 100644--- a/Sources/Fluid/UI/SettingsView.swift+++ b/Sources/Fluid/UI/SettingsView.swift@@ -939,6 +939,16 @@ struct SettingsView: View {)Divider().opacity(0.2)+ self.optionToggleRow(+ title: "Auto-Convert Punctuation",+ description: "Turn spoken punctuation like comma, question mark, slash, and at sign into symbols before AI cleanup.",+ isOn: Binding(+ get: { SettingsStore.shared.autoConvertPunctuationEnabled },+ set: { SettingsStore.shared.autoConvertPunctuationEnabled = $0 }+ )+ )+ Divider().opacity(0.2)+self.optionToggleRow(title: "Space Between Dictations",description: "Add spacing so consecutive dictations chain without manually pressing the spacebar.",diff --git a/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift b/Tests/FluidDictationIntegrationTests/DictationE2ETests.swiftindex 12f9c424..23cbe924 100644--- a/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift+++ b/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift@@ -19,6 +19,7 @@ final class DictationE2ETests: XCTestCase {private let availableModelsByProviderKey = "AvailableModelsByProvider"private let selectedModelByProviderKey = "SelectedModelByProvider"private let customDictionaryEntriesKey = "CustomDictionaryEntries"+ private let autoConvertPunctuationEnabledKey = "AutoConvertPunctuationEnabled"private let commandModeLinkedToGlobalKey = "CommandModeLinkedToGlobal"private let commandModeSelectedProviderIDKey = "CommandModeSelectedProviderID"private let commandModeSelectedModelKey = "CommandModeSelectedModel"@@ -368,6 +369,82 @@ final class DictationE2ETests: XCTestCase {)}+ func testSpokenPunctuationFormattingConvertsCommonPhrases() {+ self.withRestoredDefaults(keys: [self.autoConvertPunctuationEnabledKey]) {+ UserDefaults.standard.set(true, forKey: self.autoConvertPunctuationEnabledKey)++ XCTAssertEqual(+ ASRService.applySpokenPunctuationFormatting(+ "Hello comma world question mark open paren yes close paren quote done quote"+ ),+ "Hello, world? (yes) \"done\""+ )+ }+ }++ func testSpokenPunctuationFormattingConvertsCodeAndContactPunctuation() {+ self.withRestoredDefaults(keys: [self.autoConvertPunctuationEnabledKey]) {+ UserDefaults.standard.set(true, forKey: self.autoConvertPunctuationEnabledKey)++ XCTAssertEqual(+ ASRService.applySpokenPunctuationFormatting(+ "email at sign example dot com slash help underscore me"+ ),+ "[email protected]/help_me"+ )+ XCTAssertEqual(+ ASRService.applySpokenPunctuationFormatting("x hyphen ray costs 50 percent"),+ "x-ray costs 50%"+ )+ XCTAssertEqual(+ ASRService.applySpokenPunctuationFormatting("a plus b equals c"),+ "a + b = c"+ )+ XCTAssertEqual(+ ASRService.applySpokenPunctuationFormatting("plus I need the normal word"),+ "plus I need the normal word"+ )+ }+ }++ func testSpokenPunctuationFormattingCleansSymbolCommaNoise() {+ self.withRestoredDefaults(keys: [self.autoConvertPunctuationEnabledKey]) {+ UserDefaults.standard.set(true, forKey: self.autoConvertPunctuationEnabledKey)++ XCTAssertEqual(+ ASRService.applySpokenPunctuationFormatting("hyphen comma hyphen comma hyphen"),+ "---"+ )+ XCTAssertEqual(+ ASRService.applySpokenPunctuationFormatting("-,-,-"),+ "---"+ )+ XCTAssertEqual(+ ASRService.applySpokenPunctuationFormatting("-, -, -"),+ "- - -"+ )+ XCTAssertEqual(+ ASRService.applySpokenPunctuationFormatting("+, =, %"),+ "+ = %"+ )+ XCTAssertEqual(+ ASRService.applySpokenPunctuationFormatting("50, %"),+ "50%"+ )+ }+ }++ func testSpokenPunctuationFormattingRespectsSetting() {+ self.withRestoredDefaults(keys: [self.autoConvertPunctuationEnabledKey]) {+ UserDefaults.standard.set(false, forKey: self.autoConvertPunctuationEnabledKey)++ XCTAssertEqual(+ ASRService.applySpokenPunctuationFormatting("Hello comma world question mark"),+ "Hello comma world question mark"+ )+ }+ }+func testTerminalLiteralAutocompleteSpacingRemovesTrailingSpaceForTargetApps() {XCTAssertEqual(ASRService.applyTerminalLiteralAutocompleteSpacing(@@ -578,6 +655,11 @@ final class DictationE2ETests: XCTestCase {func testDictationEndToEnd_whisperTiny_transcribesFixture() async throws {// Arrange+ // App-hosted test writes to the real host UserDefaults; restore the prior+ // selection so the next app launch doesn't silently come up on Whisper Tiny.+ let priorSpeechModel = SettingsStore.shared.selectedSpeechModel+ defer { SettingsStore.shared.selectedSpeechModel = priorSpeechModel }+SettingsStore.shared.shareAnonymousAnalytics = falseSettingsStore.shared.selectedSpeechModel = .whisperTiny