cpu-tts / tests /test_models.py
grimshaw's picture
Add Kitten TTS and resumable jobs
d552b93 verified
Raw
History Blame Contribute Delete
1.8 kB
from fastapi.testclient import TestClient
from app.main import app
def test_models_is_public_by_default() -> None:
with TestClient(app) as client:
response = client.get("/v1/models")
assert response.status_code == 200
def test_models_success() -> None:
with TestClient(app) as client:
response = client.get(
"/v1/models", headers={"Authorization": "Bearer changeme"}
)
assert response.status_code == 200
ids = [item["id"] for item in response.json()["data"]]
assert "supertonic-2" in ids
assert "kitten-tts-micro-0.8" in ids
assert "kokoro" in ids
def test_voices_success() -> None:
with TestClient(app) as client:
response = client.get(
"/v1/voices", headers={"Authorization": "Bearer changeme"}
)
assert response.status_code == 200
aliases = {item["alias"] for item in response.json()["data"]}
assert "alloy" in aliases
assert "atlas" in aliases
assert "grace" in aliases
def test_kitten_voices_success() -> None:
with TestClient(app) as client:
response = client.get(
"/v1/voices?model=kitten-tts-micro-0.8",
headers={"Authorization": "Bearer changeme"},
)
assert response.status_code == 200
rows = response.json()["data"]
assert {item["alias"] for item in rows} >= {"bella", "jasper", "luna"}
def test_kokoro_voices_success() -> None:
with TestClient(app) as client:
response = client.get(
"/v1/voices?model=kokoro", headers={"Authorization": "Bearer changeme"}
)
assert response.status_code == 200
rows = response.json()["data"]
assert any(item["model"] == "kokoro" for item in rows)
assert all(item["alias"].startswith(("af", "am", "bf", "bm")) for item in rows)