From 90f5b3c3a10b8c6032bfb82d6e112ec6d70b761a Mon Sep 17 00:00:00 2001 From: Jie Liu <33612777+keeper-jie@users.noreply.github.com> Date: Fri, 15 May 2026 11:43:05 +0800 Subject: [PATCH] Update streaming_speech_client.py to solve Qwen/Qwen3-TTS-12Hz-0.6B-CustomVoice voice problem (#3380) Signed-off-by: Jie Liu <33612777+keeper-jie@users.noreply.github.com> Signed-off-by: Yueqian Lin Co-authored-by: Yueqian Lin --- .../qwen3_tts/streaming_speech_client.py | 10 +++++++++- vllm_omni/entrypoints/openai/protocol/audio.py | 6 +++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/examples/online_serving/text_to_speech/qwen3_tts/streaming_speech_client.py b/examples/online_serving/text_to_speech/qwen3_tts/streaming_speech_client.py index 8f09409ce..76c348bbb 100644 --- a/examples/online_serving/text_to_speech/qwen3_tts/streaming_speech_client.py +++ b/examples/online_serving/text_to_speech/qwen3_tts/streaming_speech_client.py @@ -7,6 +7,12 @@ Usage: # Send full text at once python streaming_speech_client.py --text "Hello world. How are you? I am fine." + # Pick a built-in speaker for CustomVoice models + python streaming_speech_client.py \ + --text "打开电子枪,关闭扫描,切换到低倍模式。" \ + --speaker "Serena" \ + --language "Chinese" + # Simulate STT: send text word-by-word with delay python streaming_speech_client.py \ --text "Hello world. How are you? I am fine." \ @@ -211,7 +217,9 @@ def main(): args = parser.parse_args() - # Build session config (only include non-None values) + # Build session config (only include non-None values). + # Server canonical field is `voice`; `speaker` is accepted as an alias + # (see StreamingSpeechSessionConfig.voice in protocol/audio.py). config = {} for key in [ "model", diff --git a/vllm_omni/entrypoints/openai/protocol/audio.py b/vllm_omni/entrypoints/openai/protocol/audio.py index df0b5f218..3ec2424c0 100644 --- a/vllm_omni/entrypoints/openai/protocol/audio.py +++ b/vllm_omni/entrypoints/openai/protocol/audio.py @@ -196,7 +196,7 @@ class SpeechBatchItem(BaseModel): all other fields override the batch-level defaults when set.""" input: str - voice: str | None = None + voice: str | None = Field(default=None, validation_alias=AliasChoices("voice", "speaker")) instructions: str | None = None response_format: Literal["wav", "pcm", "flac", "mp3", "aac", "opus"] | None = None speed: float | None = Field(default=None, ge=0.25, le=4.0) @@ -215,7 +215,7 @@ class BatchSpeechRequest(BaseModel): model: str | None = None items: list[SpeechBatchItem] = Field(..., min_length=1) - voice: str | None = None + voice: str | None = Field(default=None, validation_alias=AliasChoices("voice", "speaker")) instructions: str | None = None response_format: Literal["wav", "pcm", "flac", "mp3", "aac", "opus"] = "wav" speed: float | None = Field(default=1.0, ge=0.25, le=4.0) @@ -248,7 +248,7 @@ class StreamingSpeechSessionConfig(BaseModel): """Configuration sent as the first WebSocket message for streaming TTS.""" model: str | None = None - voice: str | None = None + voice: str | None = Field(default=None, validation_alias=AliasChoices("voice", "speaker")) task_type: Literal["CustomVoice", "VoiceDesign", "Base"] | None = None language: str | None = None instructions: str | None = None