server: sampling overrides on the speech endpoint

The speech body accepts seed, max_new_tokens, temperature, top_k,
top_p, and repetition_penalty. Unset fields keep the engine defaults,
a temperature of zero selects greedy decoding, and the subtalker
mirrors the talker knobs. A fixed seed makes a request reproducible.
This commit is contained in:
Pascal
2026-07-05 15:01:37 +02:00
parent 1a680e8816
commit 73fe0c67bb
4 changed files with 100 additions and 2 deletions
+30
View File
@@ -9,6 +9,7 @@
#include "rvq-file.h"
#include "version.h"
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
@@ -227,6 +228,35 @@ int main(int argc, char ** argv) {
p.instruct = req.instructions.c_str();
}
// Sampling overrides ride straight into the ABI; the subtalker
// mirrors the talker knobs so the HTTP surface stays a single
// coherent set. A temperature of zero selects greedy decoding
// on both.
p.seed = req.seed;
if (req.max_new_tokens != -1) {
p.max_new_tokens = req.max_new_tokens;
}
if (req.top_k != -1) {
p.top_k = req.top_k;
p.subtalker_top_k = req.top_k;
}
if (!std::isnan(req.temperature)) {
if (req.temperature == 0.0f) {
p.do_sample = false;
p.subtalker_do_sample = false;
} else {
p.temperature = req.temperature;
p.subtalker_temperature = req.temperature;
}
}
if (!std::isnan(req.top_p)) {
p.top_p = req.top_p;
p.subtalker_top_p = req.top_p;
}
if (!std::isnan(req.repetition_penalty)) {
p.repetition_penalty = req.repetition_penalty;
}
// Trampoline : the C ABI on_chunk forwards to the C++ sink.
const tts_sink * sink_ptr = &sink;
p.on_chunk = [](const float * s, int ns, void * u) -> bool {