From 40121d832591d743cd360482e4f19e21a353310a Mon Sep 17 00:00:00 2001 From: marius-kilocode Date: Fri, 7 Aug 2026 11:51:34 +0200 Subject: [PATCH] fix(vscode): compress speech-to-text audio to AAC to prevent payload errors --- .changeset/compressed-speech-to-text-audio.md | 5 ++ .../kilo-vscode/src/speech-to-text/capture.ts | 72 ++++++++++--------- .../tests/unit/speech-to-text-capture.test.ts | 71 ++++++++++++++++-- 3 files changed, 109 insertions(+), 39 deletions(-) create mode 100644 .changeset/compressed-speech-to-text-audio.md diff --git a/.changeset/compressed-speech-to-text-audio.md b/.changeset/compressed-speech-to-text-audio.md new file mode 100644 index 00000000000..fee2a9166d1 --- /dev/null +++ b/.changeset/compressed-speech-to-text-audio.md @@ -0,0 +1,5 @@ +--- +"kilo-code": patch +--- + +Compress speech-to-text audio input to AAC format across macOS, Linux, and Windows to prevent payload size errors on long recordings. diff --git a/packages/kilo-vscode/src/speech-to-text/capture.ts b/packages/kilo-vscode/src/speech-to-text/capture.ts index cbf5c54848a..e8b61251072 100644 --- a/packages/kilo-vscode/src/speech-to-text/capture.ts +++ b/packages/kilo-vscode/src/speech-to-text/capture.ts @@ -24,7 +24,7 @@ type Recording = Input & { type Audio = { data: string - format: "wav" + format: "m4a" model: string language?: string } @@ -39,12 +39,10 @@ ObjC.import("AVFoundation") ObjC.import("Foundation") function run(args) { const settings = $.NSMutableDictionary.alloc.init - settings.setObjectForKey($.NSNumber.numberWithUnsignedInt(1819304813), $.AVFormatIDKey) + settings.setObjectForKey($.NSNumber.numberWithUnsignedInt(1633772320), $.AVFormatIDKey) settings.setObjectForKey($.NSNumber.numberWithDouble(16000), $.AVSampleRateKey) settings.setObjectForKey($.NSNumber.numberWithInt(1), $.AVNumberOfChannelsKey) - settings.setObjectForKey($.NSNumber.numberWithInt(16), $.AVLinearPCMBitDepthKey) - settings.setObjectForKey($.NSNumber.numberWithBool(false), $.AVLinearPCMIsFloatKey) - settings.setObjectForKey($.NSNumber.numberWithBool(false), $.AVLinearPCMIsBigEndianKey) + settings.setObjectForKey($.NSNumber.numberWithInt(24000), $.AVEncoderBitRateKey) const error = Ref() const url = $.NSURL.fileURLWithPath(args[0]) const recorder = $.AVAudioRecorder.alloc.initWithURLSettingsError(url, settings, error) @@ -68,7 +66,7 @@ export async function startSpeechCapture(input: Input): Promise { starting = input.requestId try { - const file = path.join(os.tmpdir(), `kilo-stt-${process.pid}-${Date.now()}.wav`) + const file = path.join(os.tmpdir(), `kilo-stt-${process.pid}-${Date.now()}.m4a`) if (useMacCapture(process.platform, process.env)) { const result = await startMac(file, input).catch((err: unknown) => { console.warn("[Kilo New] Native macOS speech capture failed, falling back to FFmpeg", err) @@ -105,7 +103,7 @@ export async function stopSpeechCapture(requestId: string): Promise