Skip to content

Remove redundant audio decoding in CLI transcribe path#799

Open
hamzaq2000 wants to merge 1 commit into
FluidInference:mainfrom
hamzaq2000:main
Open

Remove redundant audio decoding in CLI transcribe path#799
hamzaq2000 wants to merge 1 commit into
FluidInference:mainfrom
hamzaq2000:main

Conversation

@hamzaq2000

@hamzaq2000 hamzaq2000 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Why is this change needed?

fluidaudiocli transcribe currently decodes batch audio three times: once into an unused buffer, once during unconditional resampling, and once inside AsrManager.transcribe.

try audioFileHandle.read(into: buffer)                           // Full decode #1
let samples = try AudioConverter().resampleAudioFile(...)        // Full decode #2
let result = try await asrManager.transcribe(audioFileURL, ...)  // Full decode #3

The decoded buffer was never used, so that read is removed. The second decode only supplied the sample-count log (removed) and custom-vocabulary samples. The CLI now passes normal files directly to AsrManager; with custom vocabulary, it decodes once and shares the samples between ASR and CTC.

An existing long-form duration bug was also fixed, alongside the above main patch. ChunkProcessor passed an empty sample array when building its result to avoid materializing disk-backed audio, which produced a zero duration. The result builder now accepts a sample count instead, allowing chunked paths to pass their existing totalSamples value.

Validation

Benchmarked Parakeet V3 on Apple M3 using a 1 hr mp3:

Upstream PR branch
Time 44.09 s 18.50 s
Peak memory 2,664 MiB 354 MiB

Yields a ~2.4x speedup with an 87% reduction in peak memory. The resulting transcript was byte-for-byte identical.

The equivalent WAV test showed no performance regression (15.29 s vs. 15.07 s) and also produced an identical transcript. A custom-vocabulary test likewise produced byte-identical output while improving from 2.50 s to 1.75 s.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant