Merge branch 'main' into qwen-image-2.1

Signed-off-by: Isotr0py <Isotr0py@outlook.com>
This commit is contained in:
Isotr0py authored and GitHub committed 2026-09-22 10:11:12 +08:00
commit 8e0695f362
51 files changed
+2189 -70

No files matched your search

@@ -505,6 +505,75 @@ class TestSpeechAPI:
assert voice_info["file_size"] == len(audio_content)
response = client.delete("/v1/audio/voices/test_voice")
def test_upload_voice_rejects_builtin_name(self, client):
"""A name colliding with a built-in or precomputed voice is rejected."""
handler = client.app.state.openai_serving_speech
handler._adapter.capabilities.supported_speakers = {"vivian"}
handler._adapter.capabilities.precomputed_speakers = {"ono_anna": {}}
files = {"audio_sample": ("test.wav", b"fake audio content" * 1000, "audio/wav")}
for reserved in ("Vivian", "ono_anna"):
response = client.post("/v1/audio/voices", files=files, data={"consent": "c1", "name": reserved})
assert response.status_code == 400
assert "reserved" in response.json()["detail"]
assert not handler.uploaded_speakers
def test_upload_voice_overwrites_same_name_by_default(self, client):
"""Default policy: re-registering an uploaded name replaces it in place."""
files = {"audio_sample": ("test.wav", b"first take", "audio/wav")}
data = {"consent": "c1", "name": "test_voice_ow"}
assert client.post("/v1/audio/voices", files=files, data=data).status_code == 200
files = {"audio_sample": ("test.wav", b"second take, longer content", "audio/wav")}
response = client.post("/v1/audio/voices", files=files, data=data)
assert response.status_code == 200
assert response.json()["voice"]["file_size"] == len(b"second take, longer content")
client.delete("/v1/audio/voices/test_voice_ow")
def test_upload_voice_immutable_policy_requires_delete(self, client):
"""VLLM_OMNI_SPEAKER_REGISTRATION_POLICY=immutable rejects duplicates until deleted."""
handler = client.app.state.openai_serving_speech
handler._registration_policy = "immutable"
try:
files = {"audio_sample": ("test.wav", b"fake audio content" * 1000, "audio/wav")}
data = {"consent": "c1", "name": "test_voice_imm"}
assert client.post("/v1/audio/voices", files=files, data=data).status_code == 200
response = client.post("/v1/audio/voices", files=files, data=data)
assert response.status_code == 400
assert "immutable" in response.json()["detail"]
assert client.delete("/v1/audio/voices/test_voice_imm").status_code == 200
assert client.post("/v1/audio/voices", files=files, data=data).status_code == 200
finally:
handler._registration_policy = "overwrite"
client.delete("/v1/audio/voices/test_voice_imm")
def test_invalid_registration_policy_fails_startup(self, mocker, monkeypatch, tmp_path):
"""An unknown VLLM_OMNI_SPEAKER_REGISTRATION_POLICY is a configuration error, not a silent fallback."""
monkeypatch.setenv("SPEAKER_SAMPLES_DIR", str(tmp_path))
monkeypatch.setenv("VLLM_OMNI_SPEAKER_REGISTRATION_POLICY", "append")
engine_client = mocker.MagicMock()
engine_client.default_sampling_params_list = [{}]
with pytest.raises(ValueError, match="VLLM_OMNI_SPEAKER_REGISTRATION_POLICY"):
OmniOpenAIServingSpeech(
engine_client=engine_client, models=mocker.MagicMock(), request_logger=mocker.MagicMock()
)
def test_restored_upload_shadowing_builtin_is_dropped(self, client):
"""A pre-guard upload restored under a built-in name must not keep shadowing it."""
handler = client.app.state.openai_serving_speech
handler._adapter.capabilities.supported_speakers = {"vivian"}
handler._adapter.capabilities.precomputed_speakers = {}
handler.uploaded_speakers["vivian"] = {"name": "vivian", "file_path": "/tmp/vivian.safetensors"}
handler.uploaded_speakers["keep_me"] = {"name": "keep_me", "file_path": "/tmp/keep_me.safetensors"}
handler._drop_shadowing_uploads()
assert "vivian" not in handler.uploaded_speakers
assert "keep_me" in handler.uploaded_speakers
handler.uploaded_speakers.pop("keep_me")
def test_upload_voice_with_ref_text(self, client, tmp_path):
"""Test voice upload with ref_text enables in-context cloning."""
audio_content = b"fake audio content" * 1000