diff --git a/examples/online_serving/text_to_speech/qwen3_tts/batch_speech_client.py b/examples/online_serving/text_to_speech/qwen3_tts/batch_speech_client.py index 47fdc3691..1b91905b7 100644 --- a/examples/online_serving/text_to_speech/qwen3_tts/batch_speech_client.py +++ b/examples/online_serving/text_to_speech/qwen3_tts/batch_speech_client.py @@ -1,3 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project + """Batch speech client for Qwen3-TTS via /v1/audio/speech/batch endpoint. This script demonstrates how to synthesize multiple texts in a single request. @@ -7,7 +10,7 @@ the reference for each item. Start the server (with batch-optimized stage settings for best throughput): - vllm serve Qwen/Qwen3-TTS-12Hz-1.7B-CustomVoice \ + vllm serve Qwen/Qwen3-TTS-12Hz-1.7B-Base \ --omni \ --trust-remote-code \ --stage-overrides '{"0":{"max_num_seqs":4,"gpu_memory_utilization":0.2}, diff --git a/examples/online_serving/text_to_speech/qwen3_tts/gradio_demo.py b/examples/online_serving/text_to_speech/qwen3_tts/gradio_demo.py index 3c99a82d3..105571f38 100644 --- a/examples/online_serving/text_to_speech/qwen3_tts/gradio_demo.py +++ b/examples/online_serving/text_to_speech/qwen3_tts/gradio_demo.py @@ -1,3 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project + """Gradio demo for Qwen3-TTS with gapless streaming audio playback. Uses a custom AudioWorklet-based player for gap-free streaming, @@ -351,7 +354,7 @@ def generate_speech( raise gr.Error(f"Failed to decode audio: {e}") -def create_app(api_base: str): +def create_app(api_base: str, task_type: str = "CustomVoice"): """Create the FastAPI app with streaming proxy + Gradio UI.""" fastapi_app = FastAPI() @@ -463,10 +466,11 @@ def create_app(api_base: str): lines=4, ) with gr.Row(): - task_type = gr.Radio( + task_type_input = gr.Radio( choices=TASK_TYPES, - value="CustomVoice", + value=task_type, label="Task Type", + interactive=False, scale=2, ) language = gr.Dropdown( @@ -479,17 +483,21 @@ def create_app(api_base: str): choices=voices, value=voices[0] if voices else None, label="speaker", - visible=True, + visible=task_type == "CustomVoice", allow_custom_value=True, ) instructions = gr.Textbox( label="Instructions", placeholder="e.g., Speak with excitement / A warm, friendly female voice", lines=2, - visible=True, - info="Optional style/emotion instructions", + visible=task_type != "Base", + info=( + "Required: describe the voice style" + if task_type == "VoiceDesign" + else "Optional style/emotion instructions" + ), ) - with gr.Column(visible=False) as ref_group: + with gr.Column(visible=task_type == "Base") as ref_group: ref_audio = gr.Audio( label="Reference Audio (upload for voice cloning)", type="numpy", @@ -563,7 +571,7 @@ def create_app(api_base: str): autoplay=True, visible=False, ) - with gr.Column(visible=True) as examples_cv: + with gr.Column(visible=task_type == "CustomVoice") as examples_cv: gr.Examples( examples=[ [ @@ -588,7 +596,7 @@ def create_app(api_base: str): inputs=[text_input, voice, language, instructions], label="examples", ) - with gr.Column(visible=False) as examples_vd: + with gr.Column(visible=task_type == "VoiceDesign") as examples_vd: gr.Examples( examples=[ [ @@ -605,7 +613,7 @@ def create_app(api_base: str): inputs=[text_input, language, instructions], label="examples", ) - with gr.Column(visible=False) as examples_base: + with gr.Column(visible=task_type == "Base") as examples_base: gr.Examples( examples=[ [ @@ -653,9 +661,9 @@ def create_app(api_base: str): gr.update(visible=is_base), # examples_base ) - task_type.change( + task_type_input.change( fn=on_task_change, - inputs=[task_type], + inputs=[task_type_input], outputs=[ voice, instructions, @@ -703,7 +711,7 @@ def create_app(api_base: str): all_inputs = [ text_input, - task_type, + task_type_input, voice, language, instructions, @@ -788,6 +796,9 @@ def parse_args(): description="Gradio demo for Qwen3-TTS with gapless AudioWorklet streaming.", ) add_common_args(parser) + parser.add_argument( + "--task-type", choices=TASK_TYPES, default="CustomVoice", help="Task matching the served checkpoint" + ) return parser.parse_args() @@ -796,7 +807,7 @@ def main(): logging.basicConfig(level=logging.INFO) print(f"Connecting to vLLM server at: {args.api_base}") - app = create_app(args.api_base) + app = create_app(args.api_base, task_type=args.task_type) import uvicorn diff --git a/examples/online_serving/text_to_speech/qwen3_tts/openai_speech_client.py b/examples/online_serving/text_to_speech/qwen3_tts/openai_speech_client.py index 7b2fecef5..a3f45bce8 100644 --- a/examples/online_serving/text_to_speech/qwen3_tts/openai_speech_client.py +++ b/examples/online_serving/text_to_speech/qwen3_tts/openai_speech_client.py @@ -8,25 +8,28 @@ to generate audio from text using Qwen3-TTS models. Examples: # CustomVoice task (predefined speaker) - python openai_speech_client.py --text "Hello, how are you?" --voice vivian + python openai_speech_client.py --text "Hello, how are you?" --speaker vivian # CustomVoice with emotion instruction - python openai_speech_client.py --text "I'm so happy!" --voice vivian \ + python openai_speech_client.py --text "I'm so happy!" --speaker vivian \ --instructions "Speak with excitement" # VoiceDesign task (voice from description) python openai_speech_client.py --text "Hello world" \ + --model Qwen/Qwen3-TTS-12Hz-1.7B-VoiceDesign \ --task-type VoiceDesign \ --instructions "A warm, friendly female voice" # Base task (voice cloning) python openai_speech_client.py --text "Hello world" \ + --model Qwen/Qwen3-TTS-12Hz-1.7B-Base \ --task-type Base \ --ref-audio "https://example.com/reference.wav" \ --ref-text "This is the reference transcript" # Base task with pre-computed speaker embedding python openai_speech_client.py --text "Hello world" \ + --model Qwen/Qwen3-TTS-12Hz-1.7B-Base \ --task-type Base \ --speaker-embedding embedding.json """ diff --git a/examples/online_serving/text_to_speech/qwen3_tts/run_gradio_demo.sh b/examples/online_serving/text_to_speech/qwen3_tts/run_gradio_demo.sh index d79be3c2a..650797beb 100644 --- a/examples/online_serving/text_to_speech/qwen3_tts/run_gradio_demo.sh +++ b/examples/online_serving/text_to_speech/qwen3_tts/run_gradio_demo.sh @@ -1,4 +1,7 @@ #!/bin/bash +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project + # Launch both vLLM server and Gradio demo for Qwen3-TTS # # Usage: @@ -179,7 +182,7 @@ fi echo "" echo "Starting Gradio demo..." cd "$SCRIPT_DIR" -GRADIO_CMD=("python" "gradio_demo.py" "--api-base" "$API_BASE" "--host" "$GRADIO_IP" "--port" "$GRADIO_PORT") +GRADIO_CMD=("python" "gradio_demo.py" "--api-base" "$API_BASE" "--host" "$GRADIO_IP" "--port" "$GRADIO_PORT" "--task-type" "$TASK_TYPE") if [ "$GRADIO_SHARE" = true ]; then GRADIO_CMD+=("--share") fi diff --git a/tests/dfx/reliability/invalid_param_test/test_invalid_audio_speech.py b/tests/dfx/reliability/invalid_param_test/test_invalid_audio_speech.py index 9861b609e..98b4184d9 100644 --- a/tests/dfx/reliability/invalid_param_test/test_invalid_audio_speech.py +++ b/tests/dfx/reliability/invalid_param_test/test_invalid_audio_speech.py @@ -157,14 +157,8 @@ def test_speech_missing_required_fields(omni_server: OmniServer, online_client: "ref_audio": None, "ref_text": None, }, - # NOTE: This is delegating down the TTS adapter, so the message is both specific - # to the Qwen3TTS adapter and dependent on whether or not the model has any speakers - # (as opposed to having valida speakers, but getting an invalid speaker). it would - # be more ideal to validate that this is landing on `.validate()` on the adapter - # and ensuring that the returned message matches what we would get from calling the - # adapter validate directly. - ("no speakers configured",), - id="customvoice_invalid_voice", + ("Base checkpoint does not support task_type='CustomVoice'",), + id="base_checkpoint_customvoice_task_mismatch", ), pytest.param( {"task_type": "InvalidEnum"}, ("task_type", "literal_error", "CustomVoice"), id="task_type_invalid"