Skip to content

speech: wav24, wav32f and FLAC replies, a sample_rate and stereo, each opt-in per request - #3138

Merged
ashhart merged 5 commits into
mainfrom
lead/tts-formats
Nov 22, 2026
Merged

ashhart merged 5 commits into
mainfrom
lead/tts-formats

Conversation

@ashhart

@ashhart ashhart commented Nov 13, 2026

Copy link
Copy Markdown
Owner

response_format on /v1/audio/speech adds wav24, wav32f and flac, with an optional sample_rate (one of 12 standard rates) and channels: 2. Default wav and pcm at the model's rate in mono go through the old code and stay byte-identical. mp3, opus and aac are refused by name.

  • FLAC is a new encoder in flac.zig, checked by a test decoder that verifies frame CRCs and the MD5, and by CoreAudio's afconvert, which decodes our FLAC (past 2,052 frames) to exactly the bytes of the 16-bit WAV reply.
  • sample_rate is limited to standard rates: an arbitrary rate such as 44101 would build a multi-GB resampling kernel.
  • The resampler moved to core/audio.zig with its function body unchanged, so drama3's error set and codes are unchanged.

Tests: test-server-cpu 1346 pass; drama host 41; Metal drama host 8 (+2 skip). On main, flac gets a 400.

Device check pending (an M5 Mac and a GB10): default wav/pcm sha256 equal to main's; the FLAC decodes to the same samples as the wav reply; a quantized wav32f reply equals wav; drama3-generate --encode codes equal between main and this branch; zig build native on a Mac with the Metal compiler. Conflicts with the speed and voices PRs in speech.zig and root.zig (unions).

…h opt-in per request

response_format takes wav24 (24-bit PCM WAV), wav32f (float WAV carrying the take's samples bit for
bit) and flac (16-bit FLAC with fixed-predictor subframes that decodes to the wav reply's samples);
mp3, opus and aac are refused by name. sample_rate (one of twelve standard rates, so the resampling
kernel stays small) resamples the take, and channels: 2 writes each sample on both channels. A
request without them, or with the model's own rate and one channel, gets the same wav and pcm bytes
as before through the same path; a stream stays 16-bit mono PCM at the model's rate.

Drama 3's torchaudio-style resampler moves unchanged into core/audio.zig so the speech route can use
it; drama3/wav.zig names it there, so reference clips resample as before.
@ashhart
ashhart merged commit e9b32a3 into main Nov 22, 2026
2 of 12 checks passed
@ashhart
ashhart deleted the lead/tts-formats branch November 22, 2026 10:57
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