tts: default language to auto, NULL lang selects auto, reject NULL text

This commit is contained in:
Pascal
2026-06-06 13:31:51 +02:00
parent f3cfa5cf47
commit ca0c779f49
7 changed files with 23 additions and 9 deletions
+1 -1
View File
@@ -498,7 +498,7 @@ Input:
Optional: Optional:
--format <fmt> WAV output format: wav16, wav24, wav32 (default: wav16) --format <fmt> WAV output format: wav16, wav24, wav32 (default: wav16)
--lang <name> Language label (default: english) --lang <name> Language label (default: auto)
--instruct <str> Style instruction. Required for VoiceDesign, optional for --instruct <str> Style instruction. Required for VoiceDesign, optional for
CustomVoice, rejected for Base CustomVoice, rejected for Base
--speaker <name> Speaker name (CustomVoice only) --speaker <name> Speaker name (CustomVoice only)
+1 -1
View File
@@ -4,4 +4,4 @@
./build/tts-server \ ./build/tts-server \
--model models/qwen-talker-1.7b-base-Q8_0.gguf \ --model models/qwen-talker-1.7b-base-Q8_0.gguf \
--codec models/qwen-tokenizer-12hz-Q8_0.gguf \ --codec models/qwen-tokenizer-12hz-Q8_0.gguf \
--host 127.0.0.1 --port 8080 --lang English --host 127.0.0.1 --port 8080 --lang auto
+5 -1
View File
@@ -439,8 +439,12 @@ qt_status pipeline_tts_synthesize(PipelineTTS * pt,
TtsPerf perf = {}; TtsPerf perf = {};
Timer t_total; Timer t_total;
// NULL lang selects automatic language: the prompt carries no
// language id and the model infers it from the text.
const char * lang = params->lang ? params->lang : "auto";
Timer t_build; Timer t_build;
if (!prompt_builder_build(pt, tok, params->text, params->lang, instruct, speaker, ref_spk_emb_ptr, ref_text, if (!prompt_builder_build(pt, tok, params->text, lang, instruct, speaker, ref_spk_emb_ptr, ref_text,
ref_codes_T > 0 ? ref_codes.data() : NULL, ref_codes_T, &prompt)) { ref_codes_T > 0 ? ref_codes.data() : NULL, ref_codes_T, &prompt)) {
return QT_STATUS_GENERATE_FAILED; return QT_STATUS_GENERATE_FAILED;
} }
+8
View File
@@ -313,6 +313,14 @@ enum qt_status qt_synthesize(struct qt_context * q, const struct qt_tts_params *
return QT_STATUS_INVALID_PARAMS; return QT_STATUS_INVALID_PARAMS;
} }
if (!params->text || !params->text[0]) {
qt_set_error("qt_synthesize: params->text is NULL or empty");
if (out) {
qt_audio_free(out);
}
return QT_STATUS_INVALID_PARAMS;
}
// Mode validation. Mirrors the upstream Python which raises // Mode validation. Mirrors the upstream Python which raises
// ValueError when generate_voice_design is called on a non // ValueError when generate_voice_design is called on a non
// voice_design model and the same shape applies to // voice_design model and the same shape applies to
+4 -2
View File
@@ -197,8 +197,10 @@ QT_API void qt_log_set(qt_log_cb cb, void * user_data);
struct qt_tts_params { struct qt_tts_params {
int abi_version; int abi_version;
// Input text and language hint. lang accepts the upstream // Input text and language hint. text is required and non empty.
// qwen3-tts language names ("english", "chinese", "auto", ...). // lang accepts the upstream qwen3-tts language names ("english",
// "chinese", "auto", ...). NULL selects "auto": the prompt carries
// no language id and the model infers it from the text.
// instruct is the style instruction string; required for // instruct is the style instruction string; required for
// voice_design, optional for custom_voice, rejected for base. // voice_design, optional for custom_voice, rejected for base.
// speaker is the named speaker for custom_voice models, rejected // speaker is the named speaker for custom_voice models, rejected
+2 -2
View File
@@ -34,7 +34,7 @@ static void print_usage(const char * prog) {
" stdin Target text to synthesise. Read fully then synthesised in one shot.\n\n" " stdin Target text to synthesise. Read fully then synthesised in one shot.\n\n"
"Optional:\n" "Optional:\n"
" --format <fmt> WAV output format: wav16, wav24, wav32 (default: wav16)\n" " --format <fmt> WAV output format: wav16, wav24, wav32 (default: wav16)\n"
" --lang <name> Language label (default: english)\n" " --lang <name> Language label (default: auto)\n"
" --instruct <str> Style instruction. Required for VoiceDesign, optional for\n" " --instruct <str> Style instruction. Required for VoiceDesign, optional for\n"
" CustomVoice, rejected for Base\n" " CustomVoice, rejected for Base\n"
" --speaker <name> Speaker name (CustomVoice only)\n" " --speaker <name> Speaker name (CustomVoice only)\n"
@@ -130,7 +130,7 @@ static bool read_text_file(const char * path, std::string & out) {
static bool parse_args(int argc, char ** argv, Args & a) { static bool parse_args(int argc, char ** argv, Args & a) {
a = {}; a = {};
a.lang = "english"; a.lang = "auto";
a.format = "wav16"; a.format = "wav16";
a.max_new_tokens = 2048; a.max_new_tokens = 2048;
a.seed = -1; a.seed = -1;
+2 -2
View File
@@ -21,7 +21,7 @@ static void print_usage(const char * prog) {
"Optional:\n" "Optional:\n"
" --host <ip> Listen address (default: 127.0.0.1)\n" " --host <ip> Listen address (default: 127.0.0.1)\n"
" --port <n> Listen port (default: 8080)\n" " --port <n> Listen port (default: 8080)\n"
" --lang <name> Language label (default: english)\n" " --lang <name> Language label (default: auto)\n"
" --no-fa Disable flash attention\n" " --no-fa Disable flash attention\n"
" --clamp-fp16 Clamp hidden states to FP16 range\n", " --clamp-fp16 Clamp hidden states to FP16 range\n",
prog); prog);
@@ -37,7 +37,7 @@ static std::string basename_of(const char * path) {
int main(int argc, char ** argv) { int main(int argc, char ** argv) {
const char * talker_path = NULL; const char * talker_path = NULL;
const char * codec_path = NULL; const char * codec_path = NULL;
std::string lang = "english"; std::string lang = "auto";
server_config cfg; server_config cfg;
bool use_fa = true; bool use_fa = true;
bool clamp_fp16 = false; bool clamp_fp16 = false;