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
Enable Cohere preview streaming
altic-devb3a927a0df4d
diff --git a/Sources/Fluid/Persistence/SettingsStore.swift b/Sources/Fluid/Persistence/SettingsStore.swiftindex 491596e0..d8464d34 100644--- a/Sources/Fluid/Persistence/SettingsStore.swift+++ b/Sources/Fluid/Persistence/SettingsStore.swift@@ -2684,13 +2684,35 @@ final class SettingsStore: ObservableObject {/// Large Whisper models are too slow for streaming, so they only do final transcription on stop.var supportsStreaming: Bool {switch self {- case .qwen3Asr, .cohereTranscribeSixBit, .whisperMedium, .whisperLargeTurbo, .whisperLarge:+ case .qwen3Asr, .whisperMedium, .whisperLargeTurbo, .whisperLarge:return false // Too slow for real-time chunk processingdefault:return true // All other models support streaming}}+ /// Preview update cadence for real-time transcription.+ /// Models without native incremental decoding should use a slower interval.+ var streamingPreviewIntervalSeconds: Double {+ switch self {+ case .cohereTranscribeSixBit:+ return 2.0+ default:+ return 0.6+ }+ }++ /// Minimum audio required before attempting a preview decode.+ /// Cohere performs better with a slightly larger prefix than the default 1 second.+ var minimumStreamingPreviewSeconds: Double {+ switch self {+ case .cohereTranscribeSixBit:+ return 2.0+ default:+ return 1.0+ }+ }+/// Provider category for tab groupingenum Provider: String, CaseIterable {case nvidia = "NVIDIA"diff --git a/Sources/Fluid/Services/ASRService.swift b/Sources/Fluid/Services/ASRService.swiftindex e00e906e..df9906e6 100644--- a/Sources/Fluid/Services/ASRService.swift+++ b/Sources/Fluid/Services/ASRService.swift@@ -398,7 +398,6 @@ final class ASRService: ObservableObject {// Streaming transcription state (no VAD)private var streamingTask: Task<Void, Never>?private var lastProcessedSampleCount: Int = 0- private let chunkDurationSeconds: Double = 0.6 // Fast interval - TranscriptionExecutor actor handles CoreML serializationprivate var isProcessingChunk: Bool = falseprivate var skipNextChunk: Bool = falseprivate var previousFullTranscription: String = ""@@ -412,6 +411,14 @@ final class ASRService: ObservableObject {var audioLevelPublisher: AnyPublisher<CGFloat, Never> { self.audioLevelSubject.eraseToAnyPublisher() }private var lastAudioLevelSentAt: TimeInterval = 0+ private var streamingChunkDurationSeconds: Double {+ SettingsStore.shared.selectedSpeechModel.streamingPreviewIntervalSeconds+ }++ private var minimumStreamingPreviewSamples: Int {+ Int(SettingsStore.shared.selectedSpeechModel.minimumStreamingPreviewSeconds * 16_000)+ }+/// Handles AVAudioEngine tap processing off the @MainActor to avoid touching main-actor state/// from CoreAudio's realtime callback thread.private lazy var audioCapturePipeline: AudioCapturePipeline = .init(@@ -2190,7 +2197,10 @@ final class ASRService: ObservableObject {self.streamingTask?.cancel()guard self.isAsrReady else { return }- DebugLogger.shared.debug("Starting streaming transcription task (interval: \(self.chunkDurationSeconds)s)", source: "ASRService")+ DebugLogger.shared.debug(+ "Starting streaming transcription task (interval: \(self.streamingChunkDurationSeconds)s, minSamples: \(self.minimumStreamingPreviewSamples))",+ source: "ASRService"+ )self.streamingTask = Task { [weak self] inawait self?.runStreamingLoop()@@ -2251,7 +2261,7 @@ final class ASRService: ObservableObject {}do {- try await Task.sleep(nanoseconds: UInt64(self.chunkDurationSeconds * 1_000_000_000))+ try await Task.sleep(nanoseconds: UInt64(self.streamingChunkDurationSeconds * 1_000_000_000))} catch {DebugLogger.shared.debug("Streaming transcription task cancelled", source: "ASRService")break@@ -2281,7 +2291,7 @@ final class ASRService: ObservableObject {// Thread-safe count checklet currentSampleCount = self.audioBuffer.count// Most ASR models require at least 1 second of 16kHz audio (16,000 samples) to transcribe- let minSamples = 16_000 // 1 second minimum required by transcription providers+ let minSamples = self.minimumStreamingPreviewSamplesguard currentSampleCount >= minSamples else {// Only log once per recording session to avoid spamif currentSampleCount > 0, self.lastProcessedSampleCount == 0 {@@ -2342,8 +2352,11 @@ final class ASRService: ObservableObject {// If transcription takes longer than the interval, skip next to prevent queue buildup// This allows slower machines to still work without overwhelming the system- if duration > self.chunkDurationSeconds {- DebugLogger.shared.debug("⚠️ Transcription slow (\(String(format: "%.2f", duration))s > \(self.chunkDurationSeconds)s), skipping next chunk", source: "ASRService")+ if duration > self.streamingChunkDurationSeconds {+ DebugLogger.shared.debug(+ "⚠️ Transcription slow (\(String(format: "%.2f", duration))s > \(self.streamingChunkDurationSeconds)s), skipping next chunk",+ source: "ASRService"+ )self.skipNextChunk = true}} catch {diff --git a/Sources/Fluid/Services/ExternalCoreMLTranscriptionProvider.swift b/Sources/Fluid/Services/ExternalCoreMLTranscriptionProvider.swiftindex 3fed2ceb..7add2b71 100644--- a/Sources/Fluid/Services/ExternalCoreMLTranscriptionProvider.swift+++ b/Sources/Fluid/Services/ExternalCoreMLTranscriptionProvider.swift@@ -86,6 +86,14 @@ final class ExternalCoreMLTranscriptionProvider: TranscriptionProvider {try await self.transcribeFinal(samples)}+ func transcribeStreaming(_ samples: [Float]) async throws -> ASRTranscriptionResult {+ DebugLogger.shared.debug(+ "ExternalCoreML: streaming preview request [samples=\(samples.count)]",+ source: "ExternalCoreML"+ )+ return try await self.transcribeFinal(samples)+ }+func transcribeFile(at fileURL: URL) async throws -> ASRTranscriptionResult {guard let manager = self.cohereManager else {DebugLogger.shared.error(