MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / handle_voices

Method handle_voices

app/server/runtime.cpp:705–738  ·  view source on GitHub ↗

Cached-voice discovery for the "voice"/cached_voice_id request field. Families that support voice presets (e.g. pocket_tts, see assets.cpp: model_root/embeddings/ .safetensors) keep them under an "embeddings" directory next to the model weights; other families simply have no such directory and report no voices. Used by clients (llama-swap's playground, and potentially Open WebUI) that call GET

Source from the content-addressed store, hash-verified

703 return model.default_voice_preset.has_value() ? &*model.default_voice_preset : nullptr;
704}
705
706engine::runtime::TaskRequest ServerState::build_speech_request(const LoadedModel & model, const Value & body) const {
707 engine::runtime::TaskRequest request;
708 request.text_input = engine::runtime::Transcript{
709 engine::io::json::require_string(body, "input"),
710 engine::io::json::optional_string(body, "language", ""),
711 };
712
713 request.options = options_from_object(body.find("options"));
714 add_option_from_json(request.options, body, "seed", "seed");
715 add_option_from_json(request.options, body, "temperature", "temperature");
716 add_option_from_json(request.options, body, "top_k", "top_k");
717 add_option_from_json(request.options, body, "top_p", "top_p");
718 add_option_from_json(request.options, body, "max_tokens", "max_tokens");
719 add_option_from_json(request.options, body, "max_steps", "max_steps");
720 add_option_from_json(request.options, body, "repetition_penalty", "repetition_penalty");
721 add_option_from_json(request.options, body, "guidance_scale", "guidance_scale");
722 add_option_from_json(request.options, body, "num_inference_steps", "num_inference_steps");
723 if (const auto * value = body.find("instructions")) {
724 request.options["instruct"] = value->as_string();
725 }
726
727 bool voice_field_is_preset = false;
728 const auto * preset = select_voice_preset(model, body, voice_field_is_preset);
729
730 engine::runtime::VoiceCondition voice;
731 bool has_voice = false;
732 if (preset != nullptr) {
733 if (preset->voice_id.has_value()) {
734 voice.speaker = engine::runtime::VoiceReference{};
735 voice.speaker->cached_voice_id = *preset->voice_id;
736 has_voice = true;
737 }
738 if (preset->audio.has_value()) {
739 if (!voice.speaker.has_value()) {
740 voice.speaker = engine::runtime::VoiceReference{};
741 }

Callers

nothing calls this directly

Calls 10

query_paramFunction · 0.85
json_responseFunction · 0.85
strMethod · 0.80
json_quoteFunction · 0.70
findMethod · 0.45
endMethod · 0.45
atMethod · 0.45
beginMethod · 0.45
eraseMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected