server : add POST /tts endpoint for TTS models (#26603)

* mtmd: add audio out stream api

* add /tts endpoint

* add docs

* wire up mtmd_helper_model_can_chat

* upload speaker_ref via form-data

* expose seed to api

* fix header for pcm

* wip

* fix penalty_last_n

* fix server_output_limits

* fix pocket-tts stream

* wip

* add server_schema for tts

* add server routing

* server: coerce seed and stream from multipart form fields

Form fields arrive as strings, so -F seed=42 and -F stream=true were
rejected by the schema. seed joins the integer fields, parsed as a long
long so a full uint32 seed fits, and stream is read as a boolean when
it comes as a string.

---------

Co-authored-by: Pascal <admin@serveurperso.com>
This commit is contained in:
Xuan-Son NguyenandPascal authored and GitHub committed 2026-10-21 01:19:42 +02:00
1 parent 1242be66f6
commit 5c0b49a23b
21 files changed
+724 -68

No files matched your search

+20 -5
View File
@@ -202,7 +202,8 @@ const char * get_media_marker() {
// model output modalities
//
std::vector<std::string> server_model_output_modalities(common_decision_type decision_type) {
std::vector<std::string> server_model_output_modalities(common_decision_type decision_type, bool has_cap_chat, bool has_cap_tts) {
std::vector<std::string> out;
switch (decision_type) {
case COMMON_DECISION_TYPE_OPENJEV:
case COMMON_DECISION_TYPE_LEV:
@@ -216,13 +217,27 @@ std::vector<std::string> server_model_output_modalities(common_decision_type dec
case COMMON_DECISION_TYPE_LFM2_D1:
case COMMON_DECISION_TYPE_LFM2_D1_OMNI:
case COMMON_DECISION_TYPE_H2O_LIGHTNING:
return {"decisions"};
out = {"decisions"};
break;
case COMMON_DECISION_TYPE_GRANITE_SWITCH:
return {"text", "decisions"};
out = {"text", "decisions"};
break;
default:
// fallback when there is no decision type or the metadata is bad
return {"text"};
// a tts-only model cannot generate text
if (has_cap_chat || !has_cap_tts) {
// fallback when there is no decision type or the metadata is bad
out = {"text"};
}
break;
}
if (has_cap_tts) {
out.push_back("audio");
}
return out;
}
std::vector<std::string> server_model_output_modalities(const llama_model * model, bool has_cap_chat, bool has_cap_tts) {
return server_model_output_modalities(common_get_decision_type(model), has_cap_chat, has_cap_tts);
}
json server_model_architecture_json(