Skip to content

feat(server): audio endpoint plumbing (multipart upload, binary response, WAV output) #364

Closed

Description

@inureyes

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_app and 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, and cargo fmt --check clean.
  • 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

  1. added
    status:ready
    type:enhancement
    priority:medium
    area:inference
    on Jun 19, 2026
  2. changed the title [-]feat(server): audio endpoint plumbing — multipart upload, binary response, WAV output[/-] [+]feat(server): audio endpoint plumbing (multipart upload, binary response, WAV output)[/+] on Jun 19, 2026
  3. added
    status:in-progress
    status:review
    status:done
    and removed
    status:ready
    status:in-progress
    status:review
    on Jun 19, 2026
  4. added this to the 0.3 milestone on Jun 21, 2026
  5. self-assigned this
    on Jun 21, 2026
  6. added a commit that references this issue on Jun 23, 2026
    e4ec44a
  7. added 2 commits that reference this issue on Oct 27, 2026
    fc7da5f
    66ee3ee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:inferencepriority:mediumstatus:donetype:enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions