[BUG FIX]: prevent EngineCore crash when Qwen TTS Base task is missing ref_text (#2203)
Signed-off-by: Yueqian Lin <70319226+linyueqian@users.noreply.github.com> Co-authored-by: Yueqian Lin <70319226+linyueqian@users.noreply.github.com>
This commit is contained in:
1 parent
a41174e083
commit
001f2e32e2
3 files changed
+37
-5
No files matched your search
@@ -919,6 +919,13 @@ class OmniOpenAIServingSpeech(OpenAIServing, AudioMixin):
|
||||
fmt_err = self._validate_ref_audio_format(request.ref_audio)
|
||||
if fmt_err:
|
||||
return fmt_err
|
||||
if not getattr(request, "x_vector_only_mode", False) and (
|
||||
not request.ref_text or not request.ref_text.strip()
|
||||
):
|
||||
return (
|
||||
"Base task requires non-empty 'ref_text' (transcript of "
|
||||
"the reference audio) unless 'x_vector_only_mode' is enabled"
|
||||
)
|
||||
|
||||
# Validate cross-parameter dependencies
|
||||
if task_type != "Base":
|
||||
|
||||
@@ -1439,11 +1439,16 @@ class Qwen3TTSTalkerForConditionalGeneration(nn.Module):
|
||||
)
|
||||
if ref_ids is None:
|
||||
ref_text = _as_singleton(info_dict.get("ref_text"))
|
||||
if not isinstance(ref_text, str) or not ref_text.strip():
|
||||
raise ValueError("Base in-context voice cloning requires `ref_text` or tokenized `ref_ids`.")
|
||||
ref_ids = tok(self._build_ref_text(ref_text), return_tensors="pt", padding=False)["input_ids"].to(
|
||||
device=input_ids.device
|
||||
)
|
||||
if isinstance(ref_text, str) and ref_text.strip():
|
||||
ref_ids = tok(
|
||||
self._build_ref_text(ref_text),
|
||||
return_tensors="pt",
|
||||
padding=False,
|
||||
)["input_ids"].to(device=input_ids.device)
|
||||
else:
|
||||
logger.warning("Base ICL: ref_text/ref_ids missing, falling back to x-vector-only mode.")
|
||||
in_context_mode = False
|
||||
if in_context_mode:
|
||||
icl_input_embed, trailing_text_hidden = self._generate_icl_prompt(
|
||||
text_id=input_ids[:, 3:-5],
|
||||
ref_id=ref_ids[:, 3:-2],
|
||||
|
||||
Reference in new issue
Block a user