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: scope at sign punctuation
altic-dev593e46540000
diff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swiftindex df2c550d..39e6d0be 100644--- a/Sources/Fluid/ContentView.swift+++ b/Sources/Fluid/ContentView.swift@@ -2206,6 +2206,12 @@ struct ContentView: View {var aiFallbackReason: String?var postProcessingModel: String?let appInfo = self.recordingAppInfo ?? self.getCurrentAppInfo()+ let normalizedTranscribedText = ASRService.applySpokenPunctuationFormatting(+ transcribedText,+ appName: appInfo.name,+ bundleID: appInfo.bundleId,+ windowTitle: appInfo.windowTitle+ )let shouldUseAI = activeDictationSlot.map {DictationAIPostProcessingGate.isConfigured(for: $0, appBundleID: appInfo.bundleId)@@ -2216,7 +2222,7 @@ struct ContentView: View {DebugLogger.shared.debug("Routing transcription through AI post-processing", source: "ContentView")let postProcessingModelInfo = self.currentDictationAIModelInfo()postProcessingModel = postProcessingModelInfo.model- let postProcessingInputChars = transcribedText.count+ let postProcessingInputChars = normalizedTranscribedText.countlet postProcessingStart = Date()// Update overlay text to show we're now refining (processing already true)@@ -2229,7 +2235,7 @@ struct ContentView: View {do {finalText = try await self.processTextWithAI(- transcribedText,+ normalizedTranscribedText,overrideSystemPrompt: promptOverride,dictationSlot: activeDictationSlot)@@ -2252,7 +2258,7 @@ struct ContentView: View {} else {NotificationService.showAIProcessingFallback(error: error.localizedDescription)}- finalText = transcribedText+ finalText = normalizedTranscribedText}let postProcessingLatencyMs = Int((Date().timeIntervalSince(postProcessingStart) * 1000).rounded())AnalyticsService.shared.capture(@@ -2272,7 +2278,7 @@ struct ContentView: View {NotchOverlayManager.shared.updateTranscriptionText("")} else {- finalText = transcribedText+ finalText = normalizedTranscribedText}// Normalize literal command and mention syntax after AI cleanup and before final user preferences.@@ -2786,11 +2792,16 @@ struct ContentView: View {NotchOverlayManager.shared.updateTranscriptionText("Reprocessing...")await Task.yield()- let normalizedTranscribedText = ASRService.applySpokenPunctuationFormatting(transcribedText)- var finalText = normalizedTranscribedTextvar aiFallbackReason: String?var postProcessingModel: String?let appInfo = self.getCurrentAppInfo()+ let normalizedTranscribedText = ASRService.applySpokenPunctuationFormatting(+ transcribedText,+ appName: appInfo.name,+ bundleID: appInfo.bundleId,+ windowTitle: appInfo.windowTitle+ )+ var finalText = normalizedTranscribedTextlet shouldUseAI = DictationAIPostProcessingGate.isConfigured(for: .primary, appBundleID: appInfo.bundleId)if shouldUseAI {postProcessingModel = self.currentDictationAIModelInfo().modeldiff --git a/Sources/Fluid/Services/ASRService+SpokenPunctuationFormatting.swift b/Sources/Fluid/Services/ASRService+SpokenPunctuationFormatting.swiftindex c28d4ccf..2db90ae1 100644--- a/Sources/Fluid/Services/ASRService+SpokenPunctuationFormatting.swift+++ b/Sources/Fluid/Services/ASRService+SpokenPunctuationFormatting.swift@@ -1,13 +1,52 @@import Foundationextension ASRService {- static func applySpokenPunctuationFormatting(_ text: String) -> String {+ static func applySpokenPunctuationFormatting(+ _ text: String,+ appName: String? = nil,+ bundleID: String? = nil,+ windowTitle: String? = nil+ ) -> String {guard SettingsStore.shared.autoConvertPunctuationEnabled else { return text }- return SpokenPunctuationFormatter.apply(text)+ return SpokenPunctuationFormatter.apply(+ text,+ appName: appName,+ bundleID: bundleID,+ windowTitle: windowTitle+ )}}private enum SpokenPunctuationFormatter {+ private struct FormattingContext {+ let appName: String?+ let bundleID: String?+ let windowTitle: String?++ var isAtSignPunctuationApp: Bool {+ let haystack = [self.appName, self.bundleID, self.windowTitle]+ .compactMap { $0?.lowercased() }+ .joined(separator: " ")+ return haystack.contains("codex") ||+ haystack.contains("chatgpt") ||+ haystack.contains("claude") ||+ haystack.contains("cursor") ||+ haystack.contains("windsurf") ||+ haystack.contains("xcode") ||+ haystack.contains("visual studio code") ||+ haystack.contains("vscode") ||+ haystack.contains("terminal") ||+ haystack.contains("iterm") ||+ haystack.contains("warp") ||+ haystack.contains("ghostty") ||+ haystack.contains("kitty") ||+ haystack.contains("alacritty") ||+ haystack.contains("slack") ||+ haystack.contains("discord") ||+ haystack.contains("teams")+ }+ }+private enum Spacing {case rightAttachedcase leftAttached@@ -22,6 +61,7 @@ private enum SpokenPunctuationFormatter {let symbol: Stringlet spacing: Spacingvar requiresSymbolContext = false+ var requiresAtSignPunctuationApp = false}private enum Token {@@ -64,9 +104,15 @@ private enum SpokenPunctuationFormatter {}}()- static func apply(_ text: String) -> String {+ static func apply(+ _ text: String,+ appName: String? = nil,+ bundleID: String? = nil,+ windowTitle: String? = nil+ ) -> String {guard !text.isEmpty else { return text }+ let context = FormattingContext(appName: appName, bundleID: bundleID, windowTitle: windowTitle)let tokens = self.tokenize(text)guard tokens.contains(where: { $0.normalizedWord != nil }) else {return self.cleanSymbolCommaNoise(in: text)@@ -75,7 +121,7 @@ private enum SpokenPunctuationFormatter {var output: [OutputPart] = []var index = 0while index < tokens.count {- if let match = self.matchRule(in: tokens, at: index) {+ if let match = self.matchRule(in: tokens, at: index, context: context) {output.append(.punctuation(symbol: match.rule.symbol, spacing: match.rule.spacing))index = match.endIndex} else if let text = tokens[index].text {@@ -228,7 +274,13 @@ private enum SpokenPunctuationFormatter {self.rules(symbol: "@",spacing: .noSpaceAround,- phrases: ["at sign", "at the rate", "commercial at"]+ phrases: ["at the rate"]+ ) ++ self.rules(+ symbol: "@",+ spacing: .noSpaceAround,+ phrases: ["at sign", "commercial at"],+ requiresAtSignPunctuationApp: true) +self.rules(symbol: "&",@@ -308,7 +360,8 @@ private enum SpokenPunctuationFormatter {symbol: String,spacing: Spacing,phrases: [String],- requiresSymbolContext: Bool = false+ requiresSymbolContext: Bool = false,+ requiresAtSignPunctuationApp: Bool = false) -> [PhraseRule] {phrases.compactMap { phrase inlet words = phrase@@ -320,7 +373,8 @@ private enum SpokenPunctuationFormatter {words: words,symbol: symbol,spacing: spacing,- requiresSymbolContext: requiresSymbolContext+ requiresSymbolContext: requiresSymbolContext,+ requiresAtSignPunctuationApp: requiresAtSignPunctuationApp)}}@@ -357,7 +411,11 @@ private enum SpokenPunctuationFormatter {return tokens}- private static func matchRule(in tokens: [Token], at index: Int) -> (rule: PhraseRule, endIndex: Int)? {+ private static func matchRule(+ in tokens: [Token],+ at index: Int,+ context: FormattingContext+ ) -> (rule: PhraseRule, endIndex: Int)? {guard let firstWord = tokens[index].normalizedWord,let candidates = self.rulesByFirstWord[firstWord]else {@@ -385,7 +443,8 @@ private enum SpokenPunctuationFormatter {}if matched,!rule.requiresSymbolContext ||- self.hasSymbolContext(in: tokens, startIndex: index, endIndex: cursor)+ self.hasSymbolContext(in: tokens, startIndex: index, endIndex: cursor),+ !rule.requiresAtSignPunctuationApp || context.isAtSignPunctuationApp{return (rule, cursor)}diff --git a/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift b/Tests/FluidDictationIntegrationTests/DictationE2ETests.swiftindex 602b38a6..fa255b8b 100644--- a/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift+++ b/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift@@ -388,10 +388,22 @@ final class DictationE2ETests: XCTestCase {XCTAssertEqual(ASRService.applySpokenPunctuationFormatting(- "email at sign example dot com slash help underscore me"+ "email at the rate example dot com slash help underscore me"),"[email protected]/help_me")+ XCTAssertEqual(+ ASRService.applySpokenPunctuationFormatting(+ "email at sign example dot com",+ appName: "Codex",+ bundleID: "com.openai.codex"+ ),+ )+ XCTAssertEqual(+ ASRService.applySpokenPunctuationFormatting("email at sign example"),+ "email at sign example"+ )XCTAssertEqual(ASRService.applySpokenPunctuationFormatting("x hyphen ray costs 50 percent"),"x-ray costs 50%"