From 6cb2ae649e9c6eef950e807068f35f0db9cb0201 Mon Sep 17 00:00:00 2001 From: SuperDooper86 Date: Tue, 25 Aug 2026 12:35:54 +0200 Subject: [PATCH] fix: record transcription audio as wav --- Meetingnotes.xcodeproj/project.pbxproj | 8 ++++---- meetingnotes/Managers/AudioManager.swift | 11 +++++++---- meetingnotes/Services/CoderAPIClient.swift | 7 +++++++ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Meetingnotes.xcodeproj/project.pbxproj b/Meetingnotes.xcodeproj/project.pbxproj index 63726fc..6f8af84 100644 --- a/Meetingnotes.xcodeproj/project.pbxproj +++ b/Meetingnotes.xcodeproj/project.pbxproj @@ -276,7 +276,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 32; + CURRENT_PROJECT_VERSION = 33; DEVELOPMENT_ASSET_PATHS = "\"meetingnotes/Preview Content\""; DEVELOPMENT_TEAM = G9LVHZAJNX; ENABLE_HARDENED_RUNTIME = YES; @@ -290,7 +290,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 15.0; - MARKETING_VERSION = 1.1.20; + MARKETING_VERSION = 1.1.21; ONLY_ACTIVE_ARCH = NO; OTHER_SWIFT_FLAGS = "$(inherited) -D ENABLE_TCC_SPI"; PRODUCT_BUNDLE_IDENTIFIER = net.jamesbone.meetingnotes; @@ -312,7 +312,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 32; + CURRENT_PROJECT_VERSION = 33; DEVELOPMENT_ASSET_PATHS = "\"meetingnotes/Preview Content\""; DEVELOPMENT_TEAM = G9LVHZAJNX; ENABLE_HARDENED_RUNTIME = YES; @@ -326,7 +326,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 15.0; - MARKETING_VERSION = 1.1.20; + MARKETING_VERSION = 1.1.21; ONLY_ACTIVE_ARCH = YES; OTHER_SWIFT_FLAGS = "$(inherited) -D ENABLE_TCC_SPI"; PRODUCT_BUNDLE_IDENTIFIER = net.jamesbone.meetingnotes; diff --git a/meetingnotes/Managers/AudioManager.swift b/meetingnotes/Managers/AudioManager.swift index bb965dc..264a595 100644 --- a/meetingnotes/Managers/AudioManager.swift +++ b/meetingnotes/Managers/AudioManager.swift @@ -209,15 +209,18 @@ final class AudioManager: NSObject, ObservableObject { private func prepareAudioFiles() throws { let settings: [String: Any] = [ - AVFormatIDKey: kAudioFormatMPEG4AAC, + AVFormatIDKey: kAudioFormatLinearPCM, AVSampleRateKey: 16_000, AVNumberOfChannelsKey: 1, - AVEncoderBitRateKey: 48_000 + AVLinearPCMBitDepthKey: 16, + AVLinearPCMIsFloatKey: false, + AVLinearPCMIsBigEndianKey: false, + AVLinearPCMIsNonInterleaved: false ] let base = FileManager.default.temporaryDirectory let id = sessionID.uuidString - let micURL = base.appendingPathComponent("meetingnotes-\(id)-mic.m4a") - let systemURL = base.appendingPathComponent("meetingnotes-\(id)-system.m4a") + let micURL = base.appendingPathComponent("meetingnotes-\(id)-mic.wav") + let systemURL = base.appendingPathComponent("meetingnotes-\(id)-system.wav") let newMicAudioFile = try AVAudioFile( forWriting: micURL, settings: settings, diff --git a/meetingnotes/Services/CoderAPIClient.swift b/meetingnotes/Services/CoderAPIClient.swift index ac76191..975c817 100644 --- a/meetingnotes/Services/CoderAPIClient.swift +++ b/meetingnotes/Services/CoderAPIClient.swift @@ -275,6 +275,13 @@ final class CoderAPIClient { let framesPerChunk = preserveSpeakerIdentity ? max(1, input.length) : AVAudioFramePosition(format.sampleRate * transcriptionChunkDuration) + + if fileURL.pathExtension.caseInsensitiveCompare("wav") == .orderedSame, + input.fileFormat.streamDescription.pointee.mFormatID == kAudioFormatLinearPCM, + input.length <= framesPerChunk { + return [AudioChunk(url: fileURL, offset: 0, isTemporary: false)] + } + var chunks: [AudioChunk] = [] var frameOffset: AVAudioFramePosition = 0