Skip to content

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

format n lint

altic-dev86bfbd34a62e
diff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swift
index 24098e05..33511149 100644
--- a/Sources/Fluid/ContentView.swift
+++ b/Sources/Fluid/ContentView.swift
@@ -1144,40 +1144,28 @@ struct ContentView: View {
/// Build a general system prompt with voice editing commands support
private func buildSystemPrompt(appInfo: (name: String, bundleId: String, windowTitle: String)) -> String {
+ // Use custom prompt if set, otherwise use the default
+ let customPrompt = SettingsStore.shared.customDictationPrompt
+ if !customPrompt.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
+ return customPrompt
+ }
+
return """
- CRITICAL: You are a TEXT CLEANER, NOT an assistant. You ONLY fix typos and grammar. You NEVER answer, respond, or add content.
-
- YOUR ONLY JOB: Clean the transcribed text. Return ONLY the cleaned version.
-
- RULES:
- - Fix grammar, punctuation, capitalization
- - Remove filler words (uh, um, like, you know)
- - Fix obvious typos and transcription errors
- - NEVER answer questions - just clean them and return them as questions
- - NEVER add explanations, responses, or new content
- - NEVER say "I can help" or "Here's" or anything like that
- - If someone says "what is X" → return "What is X?" (cleaned, NOT answered)
- - Output ONLY the cleaned text, nothing else
-
- VOICE COMMANDS TO PROCESS:
- - "new line" → line break
- - "new paragraph" → double line break
- - "period/comma/question mark" → actual punctuation
- - "bullet point X" → "- X"
-
- EXAMPLES:
- Input: "uh what is the capital of france"
- Output: "What is the capital of France?"
-
- Input: "can you help me with this"
- Output: "Can you help me with this?"
-
- Input: "um the meeting is at um 3 PM"
- Output: "The meeting is at 3 PM."
-
- Input: "hello new line how are you question mark"
- Output: "Hello
- How are you?"
+ You are a voice-to-text dictation cleaner. Your task is to clean and format raw transcribed speech into polished, properly formatted text.
+
+ ## Core Rules:
+ 1. CLEAN the text - remove filler words (um, uh, like, you know), false starts, and stutters
+ 2. FORMAT properly - add correct punctuation, capitalization, and structure
+ 3. CONVERT numbers - spoken numbers to digits (two → 2, five thirty → 5:30)
+ 4. EXECUTE commands - handle "new line", "period", "comma", etc.
+ 5. APPLY corrections - when user says "no wait", "actually", "scratch that", use the corrected version
+ 6. PRESERVE intent - keep the user's meaning, just clean the delivery
+
+ ## Critical:
+ - Output ONLY the cleaned text
+ - Do NOT answer questions - just clean them
+ - Do NOT add explanations or commentary
+ - Do NOT wrap in quotes unless the input had quotes
"""
}
diff --git a/Sources/Fluid/Persistence/SettingsStore.swift b/Sources/Fluid/Persistence/SettingsStore.swift
index d2656b57..75c89933 100644
--- a/Sources/Fluid/Persistence/SettingsStore.swift
+++ b/Sources/Fluid/Persistence/SettingsStore.swift
@@ -85,6 +85,9 @@ final class SettingsStore: ObservableObject {
static let overlayPosition = "OverlayPosition"
static let overlayBottomOffset = "OverlayBottomOffset"
static let overlaySize = "OverlaySize"
+
+ // Custom Dictation Prompt
+ static let customDictationPrompt = "CustomDictationPrompt"
}
// MARK: - Model Reasoning Configuration
@@ -792,6 +795,17 @@ final class SettingsStore: ObservableObject {
}
}
+ // MARK: - Custom Dictation Prompt
+
+ /// Custom system prompt for dictation mode. When empty, uses the default built-in prompt.
+ var customDictationPrompt: String {
+ get { self.defaults.string(forKey: Keys.customDictationPrompt) ?? "" }
+ set {
+ objectWillChange.send()
+ self.defaults.set(newValue, forKey: Keys.customDictationPrompt)
+ }
+ }
+
/// Whether to save transcription history for stats tracking
/// When disabled, transcriptions are not stored and stats won't update
var saveTranscriptionHistory: Bool {
diff --git a/Sources/Fluid/Services/ASRService.swift b/Sources/Fluid/Services/ASRService.swift
index 5b443795..cbd4fa44 100644
--- a/Sources/Fluid/Services/ASRService.swift
+++ b/Sources/Fluid/Services/ASRService.swift
@@ -426,7 +426,7 @@ final class ASRService: ObservableObject {
DebugLogger.shared.debug("✅ startEngine() completed", source: "ASRService")
DebugLogger.shared.debug("🎧 Setting up engine tap...", source: "ASRService")
- self.setupEngineTap()
+ try self.setupEngineTap()
DebugLogger.shared.debug("✅ Engine tap setup complete", source: "ASRService")
self.isRunning = true
@@ -1062,19 +1062,51 @@ final class ASRService: ObservableObject {
self.engine.inputNode.removeTap(onBus: 0)
}
- private func setupEngineTap() {
+ private func setupEngineTap() throws {
DebugLogger.shared.debug("🎧 setupEngineTap() - ENTERED", source: "ASRService")
let input = self.engine.inputNode
- let inFormat = input.inputFormat(forBus: 0)
- // Validate format before installing tap (VoiceInk approach)
- // This prevents hanging if the format is invalid (0Hz/0ch)
- guard inFormat.sampleRate > 0, inFormat.channelCount > 0 else {
- DebugLogger.shared.error(
- "❌ INVALID INPUT FORMAT: \(inFormat.sampleRate)Hz \(inFormat.channelCount)ch - Cannot install tap!",
+ // On Intel Macs (especially after wake from sleep), the audio HAL may not have
+ // finished initializing even after engine.start() returns. The format can be
+ // temporarily 0Hz/0ch while the hardware negotiates with CoreAudio.
+ // We retry a few times with small delays to handle this race condition.
+ var inFormat = input.inputFormat(forBus: 0)
+ var retryCount = 0
+ let maxRetries = 5
+ let retryDelayMs: UInt32 = 100_000 // 100ms in microseconds
+
+ while inFormat.sampleRate == 0 || inFormat.channelCount == 0 {
+ retryCount += 1
+ if retryCount > maxRetries {
+ DebugLogger.shared.error(
+ "❌ INVALID INPUT FORMAT after \(maxRetries) retries: \(inFormat.sampleRate)Hz \(inFormat.channelCount)ch - Cannot install tap!",
+ source: "ASRService"
+ )
+ throw NSError(
+ domain: "ASRService",
+ code: -1,
+ userInfo: [NSLocalizedDescriptionKey: "Audio input format is invalid (\(inFormat.sampleRate)Hz, \(inFormat.channelCount)ch). The microphone may still be initializing after wake from sleep. Please try again in a few seconds."]
+ )
+ }
+
+ DebugLogger.shared.warning(
+ "⏳ Input format not ready (attempt \(retryCount)/\(maxRetries)): \(inFormat.sampleRate)Hz \(inFormat.channelCount)ch - waiting 100ms...",
+ source: "ASRService"
+ )
+
+ // Small synchronous delay to let HAL initialize
+ // Using usleep since we're on MainActor and need to block briefly
+ usleep(retryDelayMs)
+
+ // Re-query the format
+ inFormat = input.inputFormat(forBus: 0)
+ }
+
+ if retryCount > 0 {
+ DebugLogger.shared.info(
+ "✅ Input format became valid after \(retryCount) retries: \(inFormat.sampleRate)Hz \(inFormat.channelCount)ch",
source: "ASRService"
)
- fatalError("AVAudioEngine input format is invalid. This should never happen with fresh engine instance.")
}
DebugLogger.shared.debug(
@@ -1108,7 +1140,7 @@ final class ASRService: ObservableObject {
do {
try self.configureSession()
try self.startEngine()
- self.setupEngineTap()
+ try self.setupEngineTap()
} catch {}
}
// Nudge visualizer
@@ -1380,7 +1412,7 @@ final class ASRService: ObservableObject {
try self.startEngine()
DebugLogger.shared.debug("Setting up engine tap...", source: "ASRService")
- self.setupEngineTap()
+ try self.setupEngineTap()
// Start monitoring the new device
self.startMonitoringDevice(device.id)
diff --git a/Sources/Fluid/UI/AISettingsView.swift b/Sources/Fluid/UI/AISettingsView.swift
index c4c7e96a..798b7159 100644
--- a/Sources/Fluid/UI/AISettingsView.swift
+++ b/Sources/Fluid/UI/AISettingsView.swift
@@ -782,6 +782,9 @@ struct AISettingsView: View {
// API Keys Guide
self.apiKeysGuideCard
+
+ // Advanced Settings Card
+ self.advancedSettingsCard
}
}
@@ -1482,4 +1485,76 @@ struct AISettingsView: View {
}
.modifier(CardAppearAnimation(delay: 0.2, appear: self.$appear))
}
+
+ // MARK: - Advanced Settings Card
+
+ private var advancedSettingsCard: some View {
+ ThemedCard(style: .prominent, hoverEffect: false) {
+ VStack(alignment: .leading, spacing: 12) {
+ // Header
+ HStack {
+ Image(systemName: "gearshape.2.fill")
+ .font(.title3)
+ .foregroundStyle(self.theme.palette.accent)
+ Text("Advanced")
+ .font(.headline)
+ .fontWeight(.semibold)
+ Spacer()
+ }
+
+ Divider().padding(.vertical, 3)
+
+ // Custom Dictation Prompt Section
+ VStack(alignment: .leading, spacing: 8) {
+ Text("Custom Dictation Prompt")
+ .font(.system(size: 15, weight: .semibold))
+ .foregroundStyle(self.theme.palette.primaryText)
+
+ Text("Customize the AI system prompt used for dictation mode. Leave empty to use the default prompt.")
+ .font(.system(size: 13))
+ .foregroundStyle(self.theme.palette.secondaryText)
+
+ TextEditor(text: Binding(
+ get: { SettingsStore.shared.customDictationPrompt },
+ set: { SettingsStore.shared.customDictationPrompt = $0 }
+ ))
+ .font(.system(.caption, design: .monospaced))
+ .frame(minHeight: 100, maxHeight: 180)
+ .scrollContentBackground(.hidden)
+ .background(
+ RoundedRectangle(cornerRadius: 8, style: .continuous)
+ .fill(.ultraThinMaterial.opacity(0.3))
+ .overlay(
+ RoundedRectangle(cornerRadius: 8, style: .continuous)
+ .stroke(.white.opacity(0.1), lineWidth: 1)
+ )
+ )
+ .padding(2)
+
+ HStack {
+ Button("Reset to Default") {
+ SettingsStore.shared.customDictationPrompt = ""
+ }
+ .buttonStyle(GlassButtonStyle())
+ .disabled(SettingsStore.shared.customDictationPrompt.isEmpty)
+
+ Spacer()
+
+ if !SettingsStore.shared.customDictationPrompt.isEmpty {
+ Label("Using custom prompt", systemImage: "checkmark.circle.fill")
+ .font(.caption)
+ .foregroundStyle(.green)
+ } else {
+ Label("Using default prompt", systemImage: "info.circle")
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ }
+ }
+ }
+ .padding(.horizontal, 4)
+ }
+ .padding(14)
+ }
+ .modifier(CardAppearAnimation(delay: 0.3, appear: self.$appear))
+ }
}