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

fix: clarify speaker-label fallback behavior

postosob040f0643020
diff --git a/Sources/Fluid/Services/AudioBufferConverter.swift b/Sources/Fluid/Services/AudioBufferConverter.swift
index 8847cb7a..503dc280 100644
--- a/Sources/Fluid/Services/AudioBufferConverter.swift
+++ b/Sources/Fluid/Services/AudioBufferConverter.swift
@@ -1,4 +1,4 @@
-import AVFoundation
+@preconcurrency import AVFoundation
import Foundation
enum AudioBufferConverter {
@@ -28,7 +28,7 @@ enum AudioBufferConverter {
}
}
- static func monoSamples(
+ nonisolated static func monoSamples(
from buffer: AVAudioPCMBuffer,
targetSampleRate: Double
) throws -> [Float] {
diff --git a/Sources/Fluid/Services/MeetingTranscriptionService.swift b/Sources/Fluid/Services/MeetingTranscriptionService.swift
index 73150471..3123daa3 100644
--- a/Sources/Fluid/Services/MeetingTranscriptionService.swift
+++ b/Sources/Fluid/Services/MeetingTranscriptionService.swift
@@ -91,6 +91,7 @@ final class MeetingTranscriptionService: ObservableObject {
@Published var currentStatus: String = ""
@Published var error: String?
@Published var result: TranscriptionResult?
+ @Published var fallbackNotice: String?
// MARK: - Supported Formats
@@ -185,6 +186,7 @@ final class MeetingTranscriptionService: ObservableObject {
func transcribeFile(_ fileURL: URL) async throws -> TranscriptionResult {
self.isTranscribing = true
error = nil
+ self.fallbackNotice = nil
self.progress = 0.0
let startTime = Date()
@@ -233,7 +235,10 @@ final class MeetingTranscriptionService: ObservableObject {
// Speaker-labeled path: diarize first, then transcribe each speaker turn.
// Any diarization failure falls back to the standard paths below.
- if SettingsStore.shared.fileTranscriptionSpeakerLabelsEnabled, SpeakerDiarizationService.isSupported {
+ if SettingsStore.shared.fileTranscriptionSpeakerLabelsEnabled,
+ SpeakerDiarizationService.isSupported,
+ !isVideoContainer
+ {
if let labeledResult = await self.transcribeFileWithSpeakerLabels(
fileURL,
provider: provider,
@@ -246,6 +251,13 @@ final class MeetingTranscriptionService: ObservableObject {
"Speaker labeling unavailable for this file; falling back to standard transcription",
source: "MeetingTranscriptionService"
)
+ self.fallbackNotice = "Speaker labeling was unavailable for this file. The transcript was completed without speaker labels."
+ self.progress = 0.3
+ } else if SettingsStore.shared.fileTranscriptionSpeakerLabelsEnabled, isVideoContainer {
+ DebugLogger.shared.info(
+ "Speaker labeling skipped for video container; using standard transcription",
+ source: "MeetingTranscriptionService"
+ )
}
if provider.prefersNativeFileTranscription && !isVideoContainer {
@@ -471,6 +483,7 @@ final class MeetingTranscriptionService: ObservableObject {
func reset() {
self.result = nil
self.error = nil
+ self.fallbackNotice = nil
self.currentStatus = ""
self.progress = 0.0
}
@@ -601,9 +614,8 @@ final class MeetingTranscriptionService: ObservableObject {
return result
}
- /// Transcribe a single speaker turn, splitting overlong turns into model-sized chunks so a
- /// long single-speaker stretch never exceeds the ASR input limit (mirrors the standard
- /// path's 20-minute chunking). Returns the concatenated text and mean confidence, or nil
+ /// Transcribe a single speaker turn, splitting overlong turns into bounded chunks.
+ /// Returns the concatenated text and mean confidence, or nil
/// when the turn holds no usable audio (too short or silent). Throws on a genuine audio-read
/// or ASR failure so the caller can fall back to full-file transcription rather than emit a
/// transcript with silent gaps.
@@ -612,7 +624,8 @@ final class MeetingTranscriptionService: ObservableObject {
from audioFile: AVAudioFile,
provider: TranscriptionProvider
) async throws -> (text: String, confidence: Float)? {
- // Keep each ASR request well under the model's input limit, matching the standard path.
+ // Bound memory for unusually long single-speaker stretches. Providers remain free to
+ // apply their own model-specific, energy-aware chunking within each request.
let maxChunkSeconds: Double = 20 * 60
var ranges: [(start: Double, end: Double)] = []
@@ -701,17 +714,7 @@ final class MeetingTranscriptionService: ObservableObject {
// MARK: - Audio Resampling Helpers
- /// Resample an audio buffer to 16 kHz mono Float32 samples.
- ///
- /// Delegates to `AudioBufferConverter`, which is the tested implementation and the one the
- /// standard file-transcription path already uses. The copy that used to live here built its
- /// own `AVAudioConverter` and never set `downmix`, so a multi-channel source was
- /// channel-mapped rather than mixed: **only the left channel was transcribed and the right
- /// one silently discarded.** Verified by feeding a stereo file with different speech on each
- /// channel — the transcript contained only the left one, and swapping the channels swapped
- /// the output. After the fix both orderings produce identical output, which is what mixing
- /// means. Stereo sources are common: in one real-world archive of 164 recordings, 72 were
- /// stereo.
+ /// Resample an audio buffer to 16 kHz mono Float32 samples using the shared downmixer.
private nonisolated func resampleBuffer(
_ buffer: AVAudioPCMBuffer,
targetSampleRate: Double = 16_000
diff --git a/Sources/Fluid/UI/MeetingTranscriptionView.swift b/Sources/Fluid/UI/MeetingTranscriptionView.swift
index 8e204aff..82254046 100644
--- a/Sources/Fluid/UI/MeetingTranscriptionView.swift
+++ b/Sources/Fluid/UI/MeetingTranscriptionView.swift
@@ -34,6 +34,11 @@ struct MeetingTranscriptionView: View {
}
}
+ private var selectedFileIsVideo: Bool {
+ guard let fileExtension = selectedFileURL?.pathExtension.lowercased() else { return false }
+ return UTType(filenameExtension: fileExtension)?.conforms(to: .movie) ?? false
+ }
+
var body: some View {
VStack(spacing: 0) {
// Header
@@ -173,14 +178,17 @@ struct MeetingTranscriptionView: View {
Text("Label speakers")
.font(.subheadline)
- Text("Identify who said what (downloads speaker models on first use)")
+ Text(self.selectedFileIsVideo
+ ? "Available for audio files only"
+ : "Identify who said what (downloads speaker models on first use)")
.font(.caption)
.foregroundColor(.secondary)
}
}
.toggleStyle(.switch)
+ .disabled(self.selectedFileIsVideo)
- if self.settings.fileTranscriptionSpeakerLabelsEnabled {
+ if self.settings.fileTranscriptionSpeakerLabelsEnabled, !self.selectedFileIsVideo {
HStack {
Text("Number of speakers")
.font(.subheadline)
@@ -354,6 +362,12 @@ struct MeetingTranscriptionView: View {
.buttonStyle(.borderless)
}
+ if let notice = transcriptionService.fallbackNotice {
+ Label(notice, systemImage: "exclamationmark.triangle.fill")
+ .font(.caption)
+ .foregroundColor(.secondary)
+ }
+
Divider()
// Transcription text
diff --git a/Tests/FluidDictationIntegrationTests/SpeakerTurnMergingTests.swift b/Tests/FluidDictationIntegrationTests/SpeakerTurnMergingTests.swift
index 35f9927d..8c663cf4 100644
--- a/Tests/FluidDictationIntegrationTests/SpeakerTurnMergingTests.swift
+++ b/Tests/FluidDictationIntegrationTests/SpeakerTurnMergingTests.swift
@@ -3,12 +3,9 @@ import XCTest
#if arch(arm64)
-// `mergeAdjacentTurns` joins consecutive turns of the *same* speaker across short pauses.
-// That is correct behaviour, but it has a consequence worth pinning down: when clustering
-// collapses and every turn carries the same label, the merge happily welds question and
-// answer into one segment. The mangled segment boundaries seen on 2026-07-27 were that
-// artifact, not a separate defect in the segmentation — so nothing here needs "fixing",
-// but the coupling should not be discovered again from scratch.
+// `mergeAdjacentTurns` joins consecutive turns from the same speaker across short pauses.
+// When clustering collapses to one label, that intentionally produces one longer segment;
+// the tests below pin down both the merge rules and that interaction.
final class SpeakerTurnMergingTests: XCTestCase {
private typealias Turn = SpeakerDiarizationService.SpeakerTurn
@@ -78,7 +75,7 @@ final class SpeakerTurnMergingTests: XCTestCase {
self.turn($0.offset % 2 == 0 ? "Speaker 1" : "Speaker 2", $0.element.0, $0.element.1)
}
let kept = SpeakerDiarizationService.mergeAdjacentTurns(alternating)
- XCTAssertEqual(kept.count, 5, "correct labels keep the exchange apart — no segmentation fix needed")
+ XCTAssertEqual(kept.count, 5, "correct labels keep the exchange separated")
}
func testOverlongRunIsCappedNotMergedIndefinitely() {