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
| 703 | return model.default_voice_preset.has_value() ? &*model.default_voice_preset : nullptr; |
| 704 | } |
| 705 | |
| 706 | engine::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 | } |
nothing calls this directly
no test coverage detected