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(meetings): normalize mic audio and rename Meet Assist

altic-devda09cfe1b649
diff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swift
index 5862d66b..32d5a4ac 100644
--- a/Sources/Fluid/ContentView.swift
+++ b/Sources/Fluid/ContentView.swift
@@ -1410,8 +1410,8 @@ struct ContentView: View {
self.sidebarNavigationLink(.fileTranscription, title: "File Transcription", systemImage: "doc.text.fill")
self.sidebarNavigationLink(
.meetingTranscription,
- title: "Fluid Notes",
- systemImage: "note.text"
+ title: "Meet Assist",
+ systemImage: "person.2.fill"
)
} header: {
self.sidebarSectionHeader("Use")
@@ -5662,7 +5662,7 @@ private enum SidebarSymbolCache {
"text.book.closed.fill",
"terminal.fill",
"doc.text.fill",
- "note.text",
+ "person.2.fill",
"clock.arrow.circlepath",
"chart.bar.fill",
"house.fill",
diff --git a/Sources/Fluid/Services/Meeting/Backend/MeetingNemotronModelLocator.swift b/Sources/Fluid/Services/Meeting/Backend/MeetingNemotronModelLocator.swift
index 945789fd..4d837ebe 100644
--- a/Sources/Fluid/Services/Meeting/Backend/MeetingNemotronModelLocator.swift
+++ b/Sources/Fluid/Services/Meeting/Backend/MeetingNemotronModelLocator.swift
@@ -36,7 +36,7 @@ nonisolated enum MeetingNemotronModelReadinessError: LocalizedError, Equatable {
switch self {
case let .modelNotInstalled(path):
return "The Nemotron diarization model is not installed at \(path). "
- + "Open Fluid Notes settings and load the supplied speaker separation model before recording."
+ + "Open Meet Assist settings and load the supplied speaker separation model before recording."
case let .invalidModelPackage(reason):
return "The Nemotron diarization model package is invalid (\(reason))."
case let .artifactChanged(path):
diff --git a/Sources/Fluid/Services/Meeting/Backend/MeetingPCMFormatContract.swift b/Sources/Fluid/Services/Meeting/Backend/MeetingPCMFormatContract.swift
index c020d4dc..f435c3e8 100644
--- a/Sources/Fluid/Services/Meeting/Backend/MeetingPCMFormatContract.swift
+++ b/Sources/Fluid/Services/Meeting/Backend/MeetingPCMFormatContract.swift
@@ -1,5 +1,5 @@
-@preconcurrency import AVFoundation
import AudioToolbox
+@preconcurrency import AVFoundation
import CoreMedia
import Foundation
@@ -19,12 +19,12 @@ nonisolated struct MeetingPCMFormatContract: Equatable, Sendable {
var description: String {
let layoutDescription: String
- switch layout {
+ switch self.layout {
case .mono: layoutDescription = "mono"
case .stereo: layoutDescription = "stereo"
case let .explicit(bytes): layoutDescription = "explicit(\(bytes.count) bytes)"
}
- return "lpcm-f32 rate=\(sampleRate) channels=\(channelCount) layout=\(layoutDescription)"
+ return "lpcm-f32 rate=\(self.sampleRate) channels=\(self.channelCount) layout=\(layoutDescription)"
}
init(audioFormat: AVAudioFormat) throws {
@@ -56,7 +56,8 @@ nonisolated struct MeetingPCMFormatContract: Equatable, Sendable {
} else {
let expectedBytes = UInt64(asbd.mChannelsPerFrame) * 4
guard UInt64(asbd.mBytesPerFrame) == expectedBytes,
- UInt64(asbd.mBytesPerPacket) == expectedBytes else {
+ UInt64(asbd.mBytesPerPacket) == expectedBytes
+ else {
throw MeetingPCMFormatContractError.unsupported("invalid interleaved Float32 byte layout")
}
}
@@ -73,14 +74,23 @@ nonisolated struct MeetingPCMFormatContract: Equatable, Sendable {
}
if channelCount == 1,
tag == nil || tag == kAudioChannelLayoutTag_Mono ||
- tag == (kAudioChannelLayoutTag_DiscreteInOrder | UInt32(channelCount)) {
+ tag == (kAudioChannelLayoutTag_DiscreteInOrder | UInt32(channelCount))
+ {
return .mono
}
if channelCount == 2,
- tag == nil || tag == kAudioChannelLayoutTag_Stereo {
+ tag == nil || tag == kAudioChannelLayoutTag_Stereo
+ {
return .stereo
}
- return .explicit(layoutData ?? Data())
+ if let layoutData { return .explicit(layoutData) }
+ // CoreAudio can expose a built-in microphone array as layout-less multichannel LPCM.
+ // Treat those channels as discrete-in-order so the capture description and the safe
+ // AVAudioFormat fallback below share one stable contract.
+ let discreteLayout = AVAudioChannelLayout(
+ layoutTag: kAudioChannelLayoutTag_DiscreteInOrder | UInt32(channelCount)
+ )
+ return .explicit(Self.layoutData(discreteLayout) ?? Data())
}
static func layoutData(_ layout: AVAudioChannelLayout?) -> Data? {
@@ -101,6 +111,36 @@ nonisolated struct MeetingPCMFormatContract: Equatable, Sendable {
}
}
+/// Builds an AVAudioFormat without trusting the imported CM initializer's nonoptional type.
+/// On macOS 27 it can return a null object for layout-less three-channel LPCM.
+nonisolated enum MeetingPCMFormatResolver {
+ static func resolve(_ description: CMFormatDescription) throws -> AVAudioFormat {
+ guard let streamDescription = CMAudioFormatDescriptionGetStreamBasicDescription(description),
+ streamDescription.pointee.mChannelsPerFrame > 0
+ else {
+ throw MeetingPCMFormatContractError.unsupported("missing LPCM stream description")
+ }
+
+ let describedFormat: AVAudioFormat? = AVAudioFormat(cmAudioFormatDescription: description)
+ if let describedFormat { return describedFormat }
+
+ let channels = streamDescription.pointee.mChannelsPerFrame
+ guard let layout = AVAudioChannelLayout(
+ layoutTag: kAudioChannelLayoutTag_DiscreteInOrder | channels
+ ),
+ let discreteFormat = AVAudioFormat(
+ streamDescription: streamDescription,
+ channelLayout: layout
+ )
+ else {
+ throw MeetingPCMFormatContractError.unsupported(
+ "cannot construct audio format for \(channels) layout-less channels"
+ )
+ }
+ return discreteFormat
+ }
+}
+
nonisolated enum MeetingPCMFormatContractError: Error, Equatable, Sendable {
case unsupported(String)
}
diff --git a/Sources/Fluid/Services/Meeting/LiveTranscription/MeetingLiveModels.swift b/Sources/Fluid/Services/Meeting/LiveTranscription/MeetingLiveModels.swift
index 25e7b3f8..4beb4e7c 100644
--- a/Sources/Fluid/Services/Meeting/LiveTranscription/MeetingLiveModels.swift
+++ b/Sources/Fluid/Services/Meeting/LiveTranscription/MeetingLiveModels.swift
@@ -122,7 +122,6 @@ nonisolated enum MeetingLiveBubbleComposer {
}
return rows
}
-
}
nonisolated enum MeetingLiveTimeConversion {
@@ -145,8 +144,9 @@ final nonisolated class MeetingLiveOriginBox: @unchecked Sendable {
self.lock.lock()
defer { self.lock.unlock() }
if let existing = self.origin {
- if pts < existing { self.origin = pts }
- return self.origin!
+ let earliest = min(pts, existing)
+ self.origin = earliest
+ return earliest
}
self.origin = pts
return pts
@@ -193,8 +193,7 @@ nonisolated enum MeetingLiveSampleCopy {
static func copy(_ sampleBuffer: CMSampleBuffer) -> Sample? {
guard CMSampleBufferIsValid(sampleBuffer), CMSampleBufferDataIsReady(sampleBuffer) else { return nil }
guard let formatDescription = CMSampleBufferGetFormatDescription(sampleBuffer),
- let streamDescription = CMAudioFormatDescriptionGetStreamBasicDescription(formatDescription),
- let sourceFormat = AVAudioFormat(streamDescription: streamDescription)
+ let sourceFormat = try? MeetingPCMFormatResolver.resolve(formatDescription)
else { return nil }
let frameCount = AVAudioFrameCount(CMSampleBufferGetNumSamples(sampleBuffer))
@@ -211,13 +210,70 @@ nonisolated enum MeetingLiveSampleCopy {
)
guard status == noErr else { return nil }
+ let copiedBuffer: AVAudioPCMBuffer
+ if sourceFormat.channelCount > 2,
+ MeetingPCMFormatContract.layoutData(formatDescription) == nil
+ {
+ guard let mono = self.downmixLayoutlessMultichannel(buffer) else { return nil }
+ copiedBuffer = mono
+ } else {
+ copiedBuffer = buffer
+ }
+
let pts = CMSampleBufferGetPresentationTimeStamp(sampleBuffer)
guard pts.isValid, pts.isNumeric else { return nil }
var duration = CMSampleBufferGetDuration(sampleBuffer)
if !duration.isValid || !duration.isNumeric || duration <= .zero {
- duration = CMTime(value: CMTimeValue(frameCount), timescale: CMTimeScale(sourceFormat.sampleRate.rounded()))
+ duration = CMTime(value: CMTimeValue(frameCount), timescale: CMTimeScale(copiedBuffer.format.sampleRate.rounded()))
+ }
+ return Sample(buffer: copiedBuffer, pts: pts, duration: duration)
+ }
+
+ private static func downmixLayoutlessMultichannel(_ source: AVAudioPCMBuffer) -> AVAudioPCMBuffer? {
+ let channelCount = Int(source.format.channelCount)
+ guard channelCount > 1,
+ source.format.commonFormat == .pcmFormatFloat32,
+ let monoFormat = AVAudioFormat(
+ commonFormat: .pcmFormatFloat32,
+ sampleRate: source.format.sampleRate,
+ channels: 1,
+ interleaved: false
+ ),
+ let mono = AVAudioPCMBuffer(pcmFormat: monoFormat, frameCapacity: source.frameLength),
+ let destination = mono.floatChannelData?[0]
+ else { return nil }
+
+ let frameCount = Int(source.frameLength)
+ let buffers = UnsafeMutableAudioBufferListPointer(source.mutableAudioBufferList)
+ if source.format.isInterleaved {
+ guard buffers.count == 1,
+ buffers[0].mNumberChannels == source.format.channelCount,
+ let data = buffers[0].mData?.assumingMemoryBound(to: Float.self)
+ else { return nil }
+ for frame in 0..<frameCount {
+ var sum: Double = 0
+ let offset = frame * channelCount
+ for channel in 0..<channelCount {
+ sum += Double(data[offset + channel])
+ }
+ destination[frame] = Float(sum / Double(channelCount))
+ }
+ } else {
+ guard buffers.count == channelCount,
+ buffers.allSatisfy({ $0.mNumberChannels == 1 && $0.mData != nil })
+ else { return nil }
+ let channelData = buffers.compactMap { $0.mData?.assumingMemoryBound(to: Float.self) }
+ guard channelData.count == channelCount else { return nil }
+ for frame in 0..<frameCount {
+ var sum: Double = 0
+ for channel in 0..<channelCount {
+ sum += Double(channelData[channel][frame])
+ }
+ destination[frame] = Float(sum / Double(channelCount))
+ }
}
- return Sample(buffer: buffer, pts: pts, duration: duration)
+ mono.frameLength = source.frameLength
+ return mono
}
}
diff --git a/Sources/Fluid/Services/Meeting/MeetingAudioChunkWriter.swift b/Sources/Fluid/Services/Meeting/MeetingAudioChunkWriter.swift
index e5e7fb9a..9fb59476 100644
--- a/Sources/Fluid/Services/Meeting/MeetingAudioChunkWriter.swift
+++ b/Sources/Fluid/Services/Meeting/MeetingAudioChunkWriter.swift
@@ -589,7 +589,7 @@ final nonisolated class MeetingAudioChunkWriter: @unchecked Sendable {
"layoutBytes=\(diagnosticLayoutSize) layoutTag=\(layout?.pointee.mChannelLayoutTag ?? 0) " +
"frames=\(CMSampleBufferGetNumSamples(sampleBuffer))")
}
- let clientFormat = AVAudioFormat(cmAudioFormatDescription: formatDescription)
+ let clientFormat = try MeetingPCMFormatResolver.resolve(formatDescription)
if DebugLogger.diagnosticsEnabled {
FileLogger.shared.appendSync(line: "[MeetingPCMProbe] after-format track=\(self.track.kind.rawValue) chunk=\(sequence)")
}
@@ -892,10 +892,16 @@ final nonisolated class MeetingAudioChunkWriter: @unchecked Sendable {
let delta = presentationTime - original
for index in timings.indices {
if timings[index].presentationTimeStamp.isValid {
- timings[index].presentationTimeStamp = timings[index].presentationTimeStamp + delta
+ timings[index].presentationTimeStamp = CMTimeAdd(
+ timings[index].presentationTimeStamp,
+ delta
+ )
}
if timings[index].decodeTimeStamp.isValid {
- timings[index].decodeTimeStamp = timings[index].decodeTimeStamp + delta
+ timings[index].decodeTimeStamp = CMTimeAdd(
+ timings[index].decodeTimeStamp,
+ delta
+ )
}
}
var copy: CMSampleBuffer?
diff --git a/Sources/Fluid/Services/MenuBarManager.swift b/Sources/Fluid/Services/MenuBarManager.swift
index ca497146..262869f7 100644
--- a/Sources/Fluid/Services/MenuBarManager.swift
+++ b/Sources/Fluid/Services/MenuBarManager.swift
@@ -925,7 +925,7 @@ final class MenuBarManager: NSObject, ObservableObject, NSMenuDelegate {
self.meetingStatusMenuItem = meetingStatusItem
let openMeetingItem = NSMenuItem(
- title: "Open Fluid Notes",
+ title: "Open Meet Assist",
action: #selector(openMeetingTranscription),
keyEquivalent: ""
)
@@ -1077,24 +1077,24 @@ final class MenuBarManager: NSObject, ObservableObject, NSMenuDelegate {
break
case .preparing:
self.meetingStatusMenuItem?.title = "Starting meeting recording…"
- self.openMeetingTranscriptionMenuItem?.title = "Open Fluid Notes"
+ self.openMeetingTranscriptionMenuItem?.title = "Open Meet Assist"
case .recording:
let source = self.meetingMenuPresentation.sourceName ?? "Meeting"
let elapsed = self.meetingMenuPresentation.startedAt.map { Self.elapsedText(now.timeIntervalSince($0)) } ?? "0:00"
self.meetingStatusMenuItem?.title = "Recording \(source) · \(elapsed)"
- self.openMeetingTranscriptionMenuItem?.title = "Open Fluid Notes"
+ self.openMeetingTranscriptionMenuItem?.title = "Open Meet Assist"
case .stopping:
self.meetingStatusMenuItem?.title = "Finalizing meeting audio…"
- self.openMeetingTranscriptionMenuItem?.title = "Open Fluid Notes"
+ self.openMeetingTranscriptionMenuItem?.title = "Open Meet Assist"
case .processing:
self.meetingStatusMenuItem?.title = "Transcribing meeting…"
- self.openMeetingTranscriptionMenuItem?.title = "Open Fluid Notes"
+ self.openMeetingTranscriptionMenuItem?.title = "Open Meet Assist"
case .interrupted:
self.meetingStatusMenuItem?.title = self.meetingMenuPresentation.attentionStatus ?? "Recording interrupted"
- self.openMeetingTranscriptionMenuItem?.title = "Open Fluid Notes"
+ self.openMeetingTranscriptionMenuItem?.title = "Open Meet Assist"
case .failed:
self.meetingStatusMenuItem?.title = self.meetingMenuPresentation.attentionStatus ?? "Meeting setup failed"
- self.openMeetingTranscriptionMenuItem?.title = "Open Fluid Notes"
+ self.openMeetingTranscriptionMenuItem?.title = "Open Meet Assist"
case .completed:
self.openMeetingTranscriptionMenuItem?.title = "Open Latest Meeting Transcript"
}
diff --git a/Sources/Fluid/UI/MeetingTranscriptionView.swift b/Sources/Fluid/UI/MeetingTranscriptionView.swift
index dd924c21..293d0d20 100644
--- a/Sources/Fluid/UI/MeetingTranscriptionView.swift
+++ b/Sources/Fluid/UI/MeetingTranscriptionView.swift
@@ -432,9 +432,9 @@ struct MeetingTranscriptionView: View {
let trackCount = MeetingPCMStoragePolicy.trackCount(for: self.setupDraft.mode)
blockingMessage = "Free at least \(MeetingPCMStoragePolicy.requiredFreeSpaceDescription(trackCount: trackCount)) of storage before recording."
} else if !CPUArchitecture.isAppleSilicon {
- blockingMessage = "Fluid Notes requires an Apple silicon Mac."
+ blockingMessage = "Meet Assist requires an Apple silicon Mac."
} else if !modelReady {
- blockingMessage = "Load the supplied speaker separation model in Fluid Notes settings before recording."
+ blockingMessage = "Load the supplied speaker separation model in Meet Assist settings before recording."
} else {
blockingMessage = nil
}
@@ -1299,12 +1299,12 @@ private struct MeetingTranscriptionHeader: View {
var body: some View {
HStack(spacing: self.theme.metrics.spacing.md) {
- Image(systemName: "note.text")
+ Image(systemName: "person.2.fill")
.font(self.theme.typography.titleIcon)
.foregroundStyle(self.theme.palette.accent)
VStack(alignment: .leading, spacing: self.theme.metrics.spacing.xs) {
- Text("Fluid Notes")
+ Text("Meet Assist")
.font(self.theme.typography.title)
.foregroundStyle(self.theme.palette.primaryText)
Text("Your conversations, kept close.")
@@ -1327,7 +1327,7 @@ private struct MeetingTranscriptionHeader: View {
MeetingHeaderIconButton(
systemImage: "gearshape",
- label: "Fluid Notes settings",
+ label: "Meet Assist settings",
action: self.onOpenMeetingSettings
)
.disabled(!self.canEditSetup)
@@ -1806,7 +1806,7 @@ private struct MeetingRecordingSettingsSheet: View {
.foregroundStyle(self.theme.palette.accent)
VStack(alignment: .leading, spacing: self.theme.metrics.spacing.xs) {
- Text(self.isFirstSetup ? "Set up Fluid Notes" : "Fluid Notes settings")
+ Text(self.isFirstSetup ? "Set up Meet Assist" : "Meet Assist settings")
.font(self.theme.typography.title)
Text("Set recording defaults and choose this meeting’s audio source.")
.font(self.theme.typography.bodySmall)
diff --git a/Tests/FluidDictationIntegrationTests/MeetingAudioChunkSinkTests.swift b/Tests/FluidDictationIntegrationTests/MeetingAudioChunkSinkTests.swift
index f2b5493f..f4c81dbc 100644
--- a/Tests/FluidDictationIntegrationTests/MeetingAudioChunkSinkTests.swift
+++ b/Tests/FluidDictationIntegrationTests/MeetingAudioChunkSinkTests.swift
@@ -16,6 +16,56 @@ private final class MeetingPCMFailureCounter: @unchecked Sendable {
/// P1a's sink fixtures intentionally use real ready CMSampleBuffers. These tests stay in the
/// integration target because the sink is an internal harness type, not a package product.
final class MeetingAudioChunkSinkTests: XCTestCase {
+ func testLayoutlessThreeChannelMicrophoneResolvesCopiesConvertsAndWrites() async throws {
+ let root = try self.makeDirectory()
+ defer { try? FileManager.default.removeItem(at: root) }
+ let sample = try self.makeRawSampleBuffer(channelCount: 3, layoutTag: nil, frameCount: 512, pts: 1.25)
+ let description = try XCTUnwrap(CMSampleBufferGetFormatDescription(sample))
+ XCTAssertNil(MeetingPCMFormatContract.layoutData(description))
+
+ let format = try MeetingPCMFormatResolver.resolve(description)
+ XCTAssertEqual(format.channelCount, 3)
+ XCTAssertNotNil(format.channelLayout)
+
+ let copied = try XCTUnwrap(MeetingLiveSampleCopy.copy(sample))
+ XCTAssertEqual(copied.buffer.format.channelCount, 1)
+ XCTAssertEqual(copied.buffer.frameLength, 512)
+ XCTAssertEqual(copied.pts.seconds, 1.25, accuracy: 0.000_001)
+ let copiedSamples = Array(UnsafeBufferPointer(
+ start: try XCTUnwrap(copied.buffer.floatChannelData?[0]),
+ count: Int(copied.buffer.frameLength)
+ ))
+ XCTAssertTrue(copiedSamples.allSatisfy { abs($0 - 0.25) < 0.000_001 })
+
+ let mono = try self.convertToMono(copied.buffer)
+ XCTAssertEqual(mono.format.channelCount, 1)
+ XCTAssertEqual(mono.format.sampleRate, 16_000)
+ XCTAssertGreaterThan(mono.frameLength, 0)
+
+ let track = MeetingAudioTrack(
+ id: UUID(), kind: .microphone, sourceIdentifier: "test", sourceDisplayName: "Test",
+ format: nil,
+ timebase: MeetingTimebaseMetadata(
+ startedHostTime: 0, machTimebaseNumerator: 1, machTimebaseDenominator: 1,
+ firstPresentationTime: nil
+ ),
+ health: .waiting, chunks: []
+ )
+ let failures = MeetingPCMFailureCounter()
+ let writer = try MeetingAudioChunkWriter(
+ track: track, sessionDirectory: root, chunkDuration: 60
+ ) { event in
+ if case .interrupted(.writerFailure, _, _) = event { failures.increment() }
+ }
+ writer.enqueue(sample)
+ let result = await writer.stop()
+ let chunk = try XCTUnwrap(result.chunks.first)
+ XCTAssertEqual(chunk.finalizationState, .finalized)
+ XCTAssertEqual(chunk.captureAnalysisAsset?.channelCount, 3)
+ XCTAssertEqual(chunk.captureAnalysisAsset?.frameCount, 512)
+ XCTAssertEqual(failures.value(), 0)
+ }
+
func testWriterAcceptsEquivalentRawMonoLayoutsWithoutRotatingOrFailing() async throws {
let root = try self.makeDirectory()
defer { try? FileManager.default.removeItem(at: root) }
@@ -248,6 +298,34 @@ final class MeetingAudioChunkSinkTests: XCTestCase {
XCTAssertTrue(partials.isEmpty)
}
+ private func convertToMono(_ source: AVAudioPCMBuffer) throws -> AVAudioPCMBuffer {
+ let monoFormat = try XCTUnwrap(AVAudioFormat(
+ commonFormat: .pcmFormatFloat32,
+ sampleRate: 16_000,
+ channels: 1,
+ interleaved: false
+ ))
+ let converter = try XCTUnwrap(AVAudioConverter(from: source.format, to: monoFormat))
+ let capacity = AVAudioFrameCount(
+ (Double(source.frameLength) * monoFormat.sampleRate / source.format.sampleRate).rounded(.up)
+ ) + 16
+ let output = try XCTUnwrap(AVAudioPCMBuffer(pcmFormat: monoFormat, frameCapacity: capacity))
+ var supplied = false
+ var conversionError: NSError?
+ let status = converter.convert(to: output, error: &conversionError) { _, inputStatus in
+ if supplied {
+ inputStatus.pointee = .noDataNow
+ return nil
+ }
+ supplied = true
+ inputStatus.pointee = .haveData
+ return source
+ }
+ if let conversionError { throw conversionError }
+ XCTAssertNotEqual(status, .error)
+ return output
+ }
+
private func makeDirectory() throws -> URL {
let url = FileManager.default.temporaryDirectory.appendingPathComponent("FluidVoice-P1a-\(UUID().uuidString)", isDirectory: true)
try FileManager.default.createDirectory(at: url, withIntermediateDirectories: false, attributes: [.posixPermissions: NSNumber(value: Int16(0o700))])