

fix: tests
@3580f89aacb57c8e4c5ce2abae35cc08bf4ac766
--- .github/workflows/lint.yaml
+++ .github/workflows/lint.yaml
... | ... | @@ -22,7 +22,7 @@ |
22 | 22 |
- uses: actions/checkout@v4 |
23 | 23 |
- uses: astral-sh/setup-uv@v5 |
24 | 24 |
with: |
25 |
- version: "0.4.11" |
|
25 |
+ version: "latest" |
|
26 | 26 |
enable-cache: true |
27 | 27 |
- run: uv python install 3.12 |
28 | 28 |
- run: uv sync --extra dev |
--- .github/workflows/publish-docs.yaml
+++ .github/workflows/publish-docs.yaml
... | ... | @@ -20,7 +20,7 @@ |
20 | 20 |
- uses: actions/checkout@v4 |
21 | 21 |
- uses: astral-sh/setup-uv@v5 |
22 | 22 |
with: |
23 |
- version: "0.4.11" |
|
23 |
+ version: "latest" |
|
24 | 24 |
enable-cache: true |
25 | 25 |
- run: uv python install 3.12 |
26 | 26 |
- run: uv sync --extra dev |
--- .github/workflows/test.yaml
+++ .github/workflows/test.yaml
... | ... | @@ -24,7 +24,7 @@ |
24 | 24 |
- uses: actions/checkout@v4 |
25 | 25 |
- uses: astral-sh/setup-uv@v5 |
26 | 26 |
with: |
27 |
- version: "0.4.11" |
|
27 |
+ version: "latest" |
|
28 | 28 |
enable-cache: true |
29 | 29 |
- run: uv python install 3.12 |
30 | 30 |
- run: uv sync --all-extras |
--- src/speaches/hf_utils.py
+++ src/speaches/hf_utils.py
... | ... | @@ -226,13 +226,14 @@ |
226 | 226 |
def download_kokoro_model() -> None: |
227 | 227 |
model_id = "hexgrad/Kokoro-82M" |
228 | 228 |
model_repo_path = Path( |
229 |
- huggingface_hub.snapshot_download(model_id, repo_type="model", allow_patterns="**/kokoro-v0_19.onnx") |
|
229 |
+ huggingface_hub.snapshot_download(model_id, repo_type="model", allow_patterns=["kokoro-v0_19.onnx"]) |
|
230 | 230 |
) |
231 | 231 |
# HACK |
232 | 232 |
res = httpx.get( |
233 | 233 |
"https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files/voices.json", follow_redirects=True |
234 | 234 |
).raise_for_status() |
235 | 235 |
voices_path = model_repo_path / "voices.json" |
236 |
+ voices_path.touch(exist_ok=True) |
|
236 | 237 |
voices_path.write_bytes(res.content) |
237 | 238 |
|
238 | 239 |
|
--- tests/conftest.py
+++ tests/conftest.py
... | ... | @@ -5,8 +5,8 @@ |
5 | 5 |
from typing import Protocol |
6 | 6 |
|
7 | 7 |
from fastapi.testclient import TestClient |
8 |
+import httpx |
|
8 | 9 |
from httpx import ASGITransport, AsyncClient |
9 |
-from huggingface_hub import snapshot_download |
|
10 | 10 |
from openai import AsyncOpenAI |
11 | 11 |
import pytest |
12 | 12 |
import pytest_asyncio |
... | ... | @@ -14,6 +14,7 @@ |
14 | 14 |
|
15 | 15 |
from speaches.config import Config, WhisperConfig |
16 | 16 |
from speaches.dependencies import get_config |
17 |
+from speaches.hf_utils import download_kokoro_model |
|
17 | 18 |
from speaches.main import create_app |
18 | 19 |
|
19 | 20 |
DISABLE_LOGGERS = ["multipart.multipart", "faster_whisper"] |
... | ... | @@ -26,6 +27,7 @@ |
26 | 27 |
# disable the UI as it slightly increases the app startup time due to the imports it's doing |
27 | 28 |
enable_ui=False, |
28 | 29 |
) |
30 |
+TIMEOUT = httpx.Timeout(15.0) |
|
29 | 31 |
|
30 | 32 |
|
31 | 33 |
def pytest_configure() -> None: |
... | ... | @@ -64,7 +66,7 @@ |
64 | 66 |
app = create_app() |
65 | 67 |
# https://fastapi.tiangolo.com/advanced/testing-dependencies/ |
66 | 68 |
app.dependency_overrides[get_config] = lambda: config |
67 |
- async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as aclient: |
|
69 |
+ async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test", timeout=TIMEOUT) as aclient: |
|
68 | 70 |
yield aclient |
69 | 71 |
|
70 | 72 |
return inner |
... | ... | @@ -91,7 +93,12 @@ |
91 | 93 |
|
92 | 94 |
# TODO: remove the download after running the tests |
93 | 95 |
# TODO: do not download when not needed |
96 |
+# @pytest.fixture(scope="session", autouse=True) |
|
97 |
+# def download_piper_voices() -> None: |
|
98 |
+# # Only download `voices.json` and the default voice |
|
99 |
+# snapshot_download("rhasspy/piper-voices", allow_patterns=["voices.json", "en/en_US/amy/**"]) |
|
100 |
+ |
|
101 |
+ |
|
94 | 102 |
@pytest.fixture(scope="session", autouse=True) |
95 |
-def download_piper_voices() -> None: |
|
96 |
- # Only download `voices.json` and the default voice |
|
97 |
- snapshot_download("rhasspy/piper-voices", allow_patterns=["voices.json", "en/en_US/amy/**"]) |
|
103 |
+def download_kokoro() -> None: |
|
104 |
+ download_kokoro_model() |
--- tests/speech_test.py
+++ tests/speech_test.py
... | ... | @@ -21,7 +21,6 @@ |
21 | 21 |
|
22 | 22 |
|
23 | 23 |
@pytest.mark.asyncio |
24 |
-@pytest.mark.skipif(platform_machine != "x86_64", reason="Only supported on x86_64") |
|
25 | 24 |
@pytest.mark.parametrize("response_format", SUPPORTED_RESPONSE_FORMATS) |
26 | 25 |
async def test_create_speech_formats(openai_client: AsyncOpenAI, response_format: ResponseFormat) -> None: |
27 | 26 |
await openai_client.audio.speech.create( |
... | ... | @@ -42,7 +41,6 @@ |
42 | 41 |
|
43 | 42 |
|
44 | 43 |
@pytest.mark.asyncio |
45 |
-@pytest.mark.skipif(platform_machine != "x86_64", reason="Only supported on x86_64") |
|
46 | 44 |
@pytest.mark.parametrize(("model", "voice"), GOOD_MODEL_VOICE_PAIRS) |
47 | 45 |
async def test_create_speech_good_model_voice_pair(openai_client: AsyncOpenAI, model: str, voice: str) -> None: |
48 | 46 |
await openai_client.audio.speech.create( |
... | ... | @@ -63,7 +61,6 @@ |
63 | 61 |
|
64 | 62 |
|
65 | 63 |
@pytest.mark.asyncio |
66 |
-@pytest.mark.skipif(platform_machine != "x86_64", reason="Only supported on x86_64") |
|
67 | 64 |
@pytest.mark.parametrize(("model", "voice"), BAD_MODEL_VOICE_PAIRS) |
68 | 65 |
async def test_create_speech_bad_model_voice_pair(openai_client: AsyncOpenAI, model: str, voice: str) -> None: |
69 | 66 |
# NOTE: not sure why `APIConnectionError` is sometimes raised |
... | ... | @@ -76,11 +73,10 @@ |
76 | 73 |
) |
77 | 74 |
|
78 | 75 |
|
79 |
-SUPPORTED_SPEEDS = [0.25, 0.5, 1.0, 2.0, 4.0] |
|
76 |
+SUPPORTED_SPEEDS = [0.5, 1.0, 2.0] |
|
80 | 77 |
|
81 | 78 |
|
82 | 79 |
@pytest.mark.asyncio |
83 |
-@pytest.mark.skipif(platform_machine != "x86_64", reason="Only supported on x86_64") |
|
84 | 80 |
async def test_create_speech_with_varying_speed(openai_client: AsyncOpenAI) -> None: |
85 | 81 |
previous_size: int | None = None |
86 | 82 |
for speed in SUPPORTED_SPEEDS: |
... | ... | @@ -101,7 +97,6 @@ |
101 | 97 |
|
102 | 98 |
|
103 | 99 |
@pytest.mark.asyncio |
104 |
-@pytest.mark.skipif(platform_machine != "x86_64", reason="Only supported on x86_64") |
|
105 | 100 |
@pytest.mark.parametrize("speed", UNSUPPORTED_SPEEDS) |
106 | 101 |
async def test_create_speech_with_unsupported_speed(openai_client: AsyncOpenAI, speed: float) -> None: |
107 | 102 |
with pytest.raises(UnprocessableEntityError): |
... | ... | @@ -118,7 +113,6 @@ |
118 | 113 |
|
119 | 114 |
|
120 | 115 |
@pytest.mark.asyncio |
121 |
-@pytest.mark.skipif(platform_machine != "x86_64", reason="Only supported on x86_64") |
|
122 | 116 |
@pytest.mark.parametrize("sample_rate", VALID_SAMPLE_RATES) |
123 | 117 |
async def test_speech_valid_resample(openai_client: AsyncOpenAI, sample_rate: int) -> None: |
124 | 118 |
res = await openai_client.audio.speech.create( |
... | ... | @@ -136,7 +130,6 @@ |
136 | 130 |
|
137 | 131 |
|
138 | 132 |
@pytest.mark.asyncio |
139 |
-@pytest.mark.skipif(platform_machine != "x86_64", reason="Only supported on x86_64") |
|
140 | 133 |
@pytest.mark.parametrize("sample_rate", INVALID_SAMPLE_RATES) |
141 | 134 |
async def test_speech_invalid_resample(openai_client: AsyncOpenAI, sample_rate: int) -> None: |
142 | 135 |
with pytest.raises(UnprocessableEntityError): |
... | ... | @@ -149,6 +142,8 @@ |
149 | 142 |
) |
150 | 143 |
|
151 | 144 |
|
145 |
+# TODO: add piper tests |
|
146 |
+ |
|
152 | 147 |
# TODO: implement the following test |
153 | 148 |
|
154 | 149 |
# NUMBER_OF_MODELS = 1 |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?