Skip to content

Return voices for single-model servers when model param is omitted - #64

Merged
0xShug0 merged 2 commits into
0xShug0:mainfrom
kevin-ho:fix/single-model-voices-endpoint
Jul 15, 2026
Merged

Return voices for single-model servers when model param is omitted#64
0xShug0 merged 2 commits into
0xShug0:mainfrom
kevin-ho:fix/single-model-voices-endpoint

Conversation

@kevin-ho

Copy link
Copy Markdown

Problem

When the server has a single model configured, GET /v1/audio/voices without a ?model= query parameter returns {"voices":[]}. Clients that call this endpoint to populate a voice picker — without prior knowledge of model IDs — receive an empty list and cannot discover available voices.

Fix

When no ?model= param is provided and exactly one model is configured, fall back to that model's voices. When multiple models are configured, the existing behavior is unchanged (empty response, since voices cannot be attributed to a specific model without the param).

size_t model_idx = SIZE_MAX;
if (!model_id.empty()) {
    const auto it = model_index_.find(model_id);
    if (it != model_index_.end()) {
        model_idx = it->second;
    }
} else if (models_.size() == 1) {
    model_idx = 0;
}

Rationale

The change is purely additive — it only affects the models_.size() == 1 path that previously returned empty. The multi-model path and the explicit ?model= path are unchanged.

Voice presets are static config metadata parsed at startup, so this works regardless of lazy_load setting. No runtime state or model session is involved — handle_voices only reads the in-memory voice_presets map and the embeddings/ directory listing.

Tested

  • GET /v1/audio/voices (no param) → voices returned (was [])
  • GET /v1/audio/voices?model=<id> → unchanged
  • Backend: CUDA

kho and others added 2 commits July 15, 2026 14:22
GET /v1/audio/voices without ?model= returns {"voices":[]} even when
the server has a single model configured with voice presets. Clients
that call this endpoint to populate a voice picker receive an empty
list and cannot discover available voices.

When no model param is provided and exactly one model is configured,
fall back to that model. Multi-model servers are unchanged since voices
cannot be attributed without the param.
@0xShug0
0xShug0 merged commit a8603a4 into 0xShug0:main Jul 15, 2026
@0xShug0

0xShug0 commented Jul 15, 2026

Copy link
Copy Markdown
Owner

@kevin-ho Thank you! PR merged.

@kevin-ho
kevin-ho deleted the fix/single-model-voices-endpoint branch July 17, 2026 04:37
dleiferives pushed a commit to dleiferives/audio.cpp that referenced this pull request Jul 25, 2026
…ndpoint

Return voices for single-model servers when model param is omitted
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.

3 participants