Repository navigation
Description
Part of #363
Problem / Background
The OpenAI audio endpoints (epic #363) need a server foundation that does not exist yet in mlxcel: no /v1/audio/* routes, no multipart/form-data upload parsing, no binary audio responses, and no audio-OUTPUT encoder (only a WAV reader exists). This sub-issue builds that foundation so the STT and TTS model work plug in without reworking the server surface. No model is added here.
Proposed Solution
Routes: register in src/server/app.rs (create_app), both the unversioned and /v1 forms:
/audio/speech+/v1/audio/speech/audio/transcriptions+/v1/audio/transcriptions/audio/translations+/v1/audio/translations
New handler module src/server/routes/audio.rs, exported via src/server/routes/mod.rs.
Request/response types in src/server/types/ (mirror the OpenAI audio API):
AudioSpeechRequest:model,input,voice,response_format,speed.AudioTranscriptionRequest:model,file,language,response_format,temperature.
Multipart upload (new; no existing pattern in the codebase): parse multipart/form-data for the STT upload via axum::extract::Multipart, extracting the audio file part plus the form fields.
Binary audio response (new) for TTS: Content-Type: audio/{mpeg,wav}, Content-Disposition: attachment; filename=speech.<fmt>, body via axum::body::Body.
Audio OUTPUT encoding (new) in src/audio/: at minimum a WAV writer (the counterpart to the existing load_wav_* reader). mp3/opus are an optional follow-up.
Audio-model interface: define a model-provider-facing trait/enum for audio model kinds so the STT (#365) and TTS (#366) work plugs in, with an in-process request/admission path. Reuse state.can_accept_request(), the existing metrics, and ErrorResponse.
Until the models land, the endpoints return a clear structured "audio model kind not loaded" error (e.g. HTTP 501).
Acceptance Criteria (integrated, not build-only)
- All six routes registered in
create_appand reachable. - Multipart (STT) and JSON (TTS) requests parse and return structured responses/errors through the real server flow.
- WAV encode round-trips against the existing reader (unit test).
- Endpoints return a structured "audio model kind not loaded" error until the STT/TTS sub-issues land.
-
cargo test,cargo clippy --all-targets -- -D warnings, andcargo fmt --checkclean. - Docs note the new endpoints.
Technical Considerations
- This is the Phase 1 plumbing the rest of the epic depends on; keep the audio-model interface generic enough for both ASR (audio-in to text) and TTS (text to audio-out).
- Reuse the existing WAV reader and mel front-end rather than duplicating them.
Activity
[-]feat(server): audio endpoint plumbing — multipart upload, binary response, WAV output[/-][+]feat(server): audio endpoint plumbing (multipart upload, binary response, WAV output)[/+]feat(models): Kokoro-82M TTS with iSTFTNet vocoder for /v1/audio/spee…
feat(server): audio endpoint plumbing for /v1/audio/* (lablup#368)
feat(server): audio endpoint plumbing for /v1/audio/* (lablup#368)
feat(models): Kokoro-82M TTS with iSTFTNet vocoder for /v1/audio/spee…