From c450cd68e0846b8b4d652ee014540841757fbd72 Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Tue, 18 Aug 2026 11:55:43 +0200 Subject: [PATCH] expose seed to api --- tools/server/README.md | 2 ++ tools/server/server-context.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tools/server/README.md b/tools/server/README.md index 20d577bde6..ed8d7625fe 100644 --- a/tools/server/README.md +++ b/tools/server/README.md @@ -802,6 +802,8 @@ Returns raw audio bytes (`audio/wav` by default) rather than JSON. For more info `repeat_penalty`: Repetition penalty applied to the backbone sampler over the whole generation (default `1.05`). Without this, the backbone can loop and re-generate the same utterance. +`seed`: RNG seed for both the backbone sampler and the codec/vocoder (`-1` = random, the default). Set to a fixed value for reproducible output. + `n_predict`: Max number of audio frames to generate. Defaults to `512`; generation normally stops earlier once the model emits an end-of-speech token. `response_format`: `wav` (default) or `pcm` (raw `float32` samples, no header). diff --git a/tools/server/server-context.cpp b/tools/server/server-context.cpp index 29bb8d87b0..fa0b330bce 100644 --- a/tools/server/server-context.cpp +++ b/tools/server/server-context.cpp @@ -5241,6 +5241,8 @@ void server_routes::init_routes() { task.params.sampling = params.sampling; // baseline defaults, then apply overrides below task.params.sampling.penalty_repeat = json_value(body, "repeat_penalty", 1.05f); task.params.sampling.penalty_last_n = -1; + task.params.sampling.seed = json_value(body, "seed", params.sampling.seed); + task.tts_inp.data.seed = task.params.sampling.seed; // same seed for the codec/vocoder RNG if (task.tts_inp.data.top_k > 0) { task.params.sampling.top_k = task.tts_inp.data.top_k; }