[Model] Accelerate Breeze-TTS-2 non-streaming inference (#7752)
This commit is contained in:
1 parent
d2aa07159c
commit
3f473a358b
84 files changed
+8191
-5622
No files matched your search
@@ -1,100 +1,108 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
"""
|
||||
E2E Online tests for Breeze-TTS-2 with text input and audio output.
|
||||
|
||||
These tests verify the /v1/audio/speech endpoint works correctly with
|
||||
actual model inference, not mocks. Breeze-TTS-2 plain mode needs only
|
||||
``input`` and a speaker tag (``voice`` defaults to ``S0``); reference
|
||||
cloning requires ``ref_audio`` + ``ref_text`` and is not exercised here.
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
os.environ["VLLM_WORKER_MULTIPROC_METHOD"] = "spawn"
|
||||
"""Breeze design, reference conditioning and CFG through the shared speech client."""
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.helpers.mark import hardware_test
|
||||
from tests.helpers.media import get_asset_path
|
||||
from tests.helpers.runtime import OmniServerParams
|
||||
from tests.helpers.stage_config import get_deploy_config_path
|
||||
|
||||
MODEL = "BreezeBlue/Breeze-TTS-2"
|
||||
DEFAULT_AUDIO_SPEECH_TIMEOUT_S = 300.0
|
||||
MAX_CONCURRENT = 4
|
||||
|
||||
# ~0.5 s of 24 kHz mono PCM_16 in WAV (~24k payload + header).
|
||||
_MIN_AUDIO_BYTES = 40_000
|
||||
|
||||
|
||||
def get_prompt(prompt_type="text"):
|
||||
"""English prompt for zero-shot TTS."""
|
||||
prompts = {
|
||||
"text": "The weather is nice today, perfect for a walk in the park.",
|
||||
}
|
||||
return prompts.get(prompt_type, prompts["text"])
|
||||
|
||||
|
||||
tts_server_params = [
|
||||
pytest.param(
|
||||
OmniServerParams(
|
||||
model=MODEL,
|
||||
stage_config_path=get_deploy_config_path("breeze_tts_2.yaml"),
|
||||
server_args=["--trust-remote-code", "--disable-log-stats"],
|
||||
),
|
||||
id="breeze_tts_2",
|
||||
)
|
||||
pytestmark = [
|
||||
pytest.mark.core_model,
|
||||
pytest.mark.advanced_model,
|
||||
pytest.mark.tts,
|
||||
pytest.mark.parametrize(
|
||||
"omni_server",
|
||||
[OmniServerParams(model=MODEL, stage_config_path=get_deploy_config_path("breeze_tts_2.yaml"))],
|
||||
indirect=True,
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.tts
|
||||
@hardware_test(res={"cuda": "L4"}, num_cards=1)
|
||||
@pytest.mark.parametrize("omni_server", tts_server_params, indirect=True)
|
||||
def test_text_to_audio_001(omni_server, online_client) -> None:
|
||||
"""
|
||||
Test plain text-to-audio via OpenAI API.
|
||||
Deploy Setting: breeze_tts_2.yaml
|
||||
Input Modal: text
|
||||
Output Modal: audio
|
||||
Input Setting: stream=False
|
||||
Datasets: few requests (max_num_seqs=8)
|
||||
"""
|
||||
request_config = {
|
||||
"model": omni_server.model,
|
||||
"input": get_prompt(),
|
||||
"stream": False,
|
||||
"timeout": DEFAULT_AUDIO_SPEECH_TIMEOUT_S,
|
||||
"response_format": "wav",
|
||||
"voice": "S0",
|
||||
"sample_rate": 24000,
|
||||
"min_audio_bytes": _MIN_AUDIO_BYTES,
|
||||
}
|
||||
online_client.send_audio_speech_request(request_config, request_num=MAX_CONCURRENT)
|
||||
def test_chinese_voice_design(omni_server, online_client, run_level) -> None:
|
||||
online_client.send_audio_speech_request(
|
||||
{
|
||||
"model": omni_server.model,
|
||||
"input": "你好,欢迎使用语音合成系统。今天的天气很好。",
|
||||
"instructions": "年轻女性,使用标准普通话,语速适中。",
|
||||
"extra_params": {"guidance_scale": 4.0},
|
||||
"transcript_language": "zh",
|
||||
# Whisper-small transcribes "合成" as "和程" on this fixed clip.
|
||||
# Use the stronger primary ASR without changing the expected text
|
||||
# or similarity threshold, or retrying after a failed assertion.
|
||||
"transcript_model": "large-v3",
|
||||
"response_format": "wav",
|
||||
"sample_rate": 24000,
|
||||
"min_audio_bytes": 24000,
|
||||
"seed": 42,
|
||||
"max_new_tokens": 8 if run_level == "core_model" else 250,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.tts
|
||||
@hardware_test(res={"cuda": "L4"}, num_cards=1)
|
||||
@pytest.mark.parametrize("omni_server", tts_server_params, indirect=True)
|
||||
def test_text_to_audio_002(omni_server, online_client) -> None:
|
||||
"""
|
||||
Test streaming text-to-audio via OpenAI API (async-chunk SSE deltas).
|
||||
Deploy Setting: breeze_tts_2.yaml
|
||||
Input Modal: text
|
||||
Output Modal: audio
|
||||
Input Setting: stream=True
|
||||
Datasets: single request
|
||||
"""
|
||||
request_config = {
|
||||
"model": omni_server.model,
|
||||
"input": get_prompt(),
|
||||
"stream": True,
|
||||
"stream_format": "audio",
|
||||
"timeout": DEFAULT_AUDIO_SPEECH_TIMEOUT_S,
|
||||
"response_format": "wav",
|
||||
"voice": "S0",
|
||||
"sample_rate": 24000,
|
||||
"min_audio_bytes": _MIN_AUDIO_BYTES,
|
||||
}
|
||||
online_client.send_audio_speech_request(request_config)
|
||||
def test_english_streaming(omni_server, online_client, run_level) -> None:
|
||||
online_client.send_audio_speech_request(
|
||||
{
|
||||
"model": omni_server.model,
|
||||
"input": "Hello, this is a demonstration of natural speech synthesis.",
|
||||
"instructions": "A warm, clear female voice speaking English at a moderate pace.",
|
||||
"transcript_language": "en",
|
||||
"response_format": "pcm",
|
||||
"sample_rate": 24000,
|
||||
"min_audio_bytes": 24000,
|
||||
"stream": True,
|
||||
"stream_format": "audio",
|
||||
# The reference eager runtime scores 0.56 dB on this same prompt
|
||||
# (seed 42, CFG=1); the shared 1 dB floor rejects it as well.
|
||||
"min_hnr_db": 0.0,
|
||||
"seed": 42,
|
||||
"max_new_tokens": 8 if run_level == "core_model" else 250,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@hardware_test(res={"cuda": "L4"}, num_cards=1)
|
||||
def test_two_concurrent_requests(omni_server, online_client, run_level) -> None:
|
||||
online_client.send_audio_speech_request(
|
||||
{
|
||||
"model": omni_server.model,
|
||||
"input": "Each request keeps its own audio generation state.",
|
||||
"instructions": "A clear English voice.",
|
||||
"extra_params": {"guidance_scale": 4.0},
|
||||
"transcript_language": "en",
|
||||
"response_format": "wav",
|
||||
"sample_rate": 24000,
|
||||
"min_audio_bytes": 24000,
|
||||
"seed": 123,
|
||||
"max_new_tokens": 8 if run_level == "core_model" else 250,
|
||||
},
|
||||
request_num=2,
|
||||
)
|
||||
|
||||
|
||||
@hardware_test(res={"cuda": "L4"}, num_cards=1)
|
||||
@pytest.mark.parametrize("guidance_scale", [1.0, 4.0])
|
||||
def test_reference_cloning_and_direction(omni_server, online_client, run_level, guidance_scale) -> None:
|
||||
online_client.send_audio_speech_request(
|
||||
{
|
||||
"model": omni_server.model,
|
||||
"input": "Please read this sentence clearly and naturally.",
|
||||
"instructions": "Keep the reference voice. Speak gently and calmly.",
|
||||
"ref_audio": get_asset_path("qwen3_tts/clone_2.wav", as_data_url=True),
|
||||
"ref_text": "Okay. Yeah. I resent you. I love you. I respect you. But you know what? You blew it! And thanks to you.",
|
||||
"task_type": "Base",
|
||||
"extra_params": {"guidance_scale": guidance_scale},
|
||||
"transcript_language": "en",
|
||||
"response_format": "wav",
|
||||
"sample_rate": 24000,
|
||||
"min_audio_bytes": 24000,
|
||||
"seed": 42,
|
||||
"max_new_tokens": 8 if run_level == "core_model" else 250,
|
||||
}
|
||||
)
|
||||
Reference in new issue
Block a user