pytest-audioeval 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. pytest_audioeval-0.1.0/.gitignore +207 -0
  2. pytest_audioeval-0.1.0/.python-version +1 -0
  3. pytest_audioeval-0.1.0/.vscode/settings.json +9 -0
  4. pytest_audioeval-0.1.0/LICENSE +21 -0
  5. pytest_audioeval-0.1.0/Makefile +68 -0
  6. pytest_audioeval-0.1.0/PKG-INFO +282 -0
  7. pytest_audioeval-0.1.0/README.md +250 -0
  8. pytest_audioeval-0.1.0/compose.integration.yml +59 -0
  9. pytest_audioeval-0.1.0/docs/changelog.md +18 -0
  10. pytest_audioeval-0.1.0/docs/gen_ref_pages.py +32 -0
  11. pytest_audioeval-0.1.0/docs/getting-started/installation.md +121 -0
  12. pytest_audioeval-0.1.0/docs/getting-started/quickstart.md +200 -0
  13. pytest_audioeval-0.1.0/docs/guides/advanced-usage.md +313 -0
  14. pytest_audioeval-0.1.0/docs/guides/configuration.md +140 -0
  15. pytest_audioeval-0.1.0/docs/index.md +75 -0
  16. pytest_audioeval-0.1.0/mkdocs.yml +89 -0
  17. pytest_audioeval-0.1.0/pyproject.toml +91 -0
  18. pytest_audioeval-0.1.0/scripts/generate_samples.py +70 -0
  19. pytest_audioeval-0.1.0/src/pytest_audioeval/client.py +27 -0
  20. pytest_audioeval-0.1.0/src/pytest_audioeval/metrics/audio.py +28 -0
  21. pytest_audioeval-0.1.0/src/pytest_audioeval/metrics/text.py +45 -0
  22. pytest_audioeval-0.1.0/src/pytest_audioeval/plugin.py +41 -0
  23. pytest_audioeval-0.1.0/src/pytest_audioeval/py.typed +0 -0
  24. pytest_audioeval-0.1.0/src/pytest_audioeval/samples/audio/en/counting.txt +1 -0
  25. pytest_audioeval-0.1.0/src/pytest_audioeval/samples/audio/en/counting.wav +0 -0
  26. pytest_audioeval-0.1.0/src/pytest_audioeval/samples/audio/en/hello_world.txt +1 -0
  27. pytest_audioeval-0.1.0/src/pytest_audioeval/samples/audio/en/hello_world.wav +0 -0
  28. pytest_audioeval-0.1.0/src/pytest_audioeval/samples/audio/en/quick_brown_fox.txt +1 -0
  29. pytest_audioeval-0.1.0/src/pytest_audioeval/samples/audio/en/quick_brown_fox.wav +0 -0
  30. pytest_audioeval-0.1.0/src/pytest_audioeval/samples/registry.py +114 -0
  31. pytest_audioeval-0.1.0/src/pytest_audioeval/stt.py +135 -0
  32. pytest_audioeval-0.1.0/src/pytest_audioeval/tts.py +61 -0
  33. pytest_audioeval-0.1.0/tests/conftest.py +38 -0
  34. pytest_audioeval-0.1.0/tests/integration/conftest.py +54 -0
  35. pytest_audioeval-0.1.0/tests/integration/test_plugin_usage.py +334 -0
  36. pytest_audioeval-0.1.0/tests/integration/test_roundtrip.py +128 -0
  37. pytest_audioeval-0.1.0/tests/integration/test_stt.py +117 -0
  38. pytest_audioeval-0.1.0/tests/integration/test_tts.py +101 -0
  39. pytest_audioeval-0.1.0/tests/unit/conftest.py +1 -0
  40. pytest_audioeval-0.1.0/tests/unit/pytest_audioeval/metrics/test_audio.py +43 -0
  41. pytest_audioeval-0.1.0/tests/unit/pytest_audioeval/metrics/test_text.py +78 -0
  42. pytest_audioeval-0.1.0/tests/unit/pytest_audioeval/samples/test_registry.py +107 -0
  43. pytest_audioeval-0.1.0/tests/unit/pytest_audioeval/test_client.py +59 -0
  44. pytest_audioeval-0.1.0/tests/unit/pytest_audioeval/test_plugin.py +18 -0
  45. pytest_audioeval-0.1.0/tests/unit/pytest_audioeval/test_stt.py +290 -0
  46. pytest_audioeval-0.1.0/tests/unit/pytest_audioeval/test_tts.py +127 -0
  47. pytest_audioeval-0.1.0/uv.lock +1116 -0
@@ -0,0 +1,207 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ #.idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,9 @@
1
+ {
2
+ "python.testing.pytestArgs": [
3
+ "tests",
4
+ "--stt-url=ws://localhost:45120",
5
+ "--tts-url=http://localhost:45130/v1/audio/speech"
6
+ ],
7
+ "python.testing.unittestEnabled": false,
8
+ "python.testing.pytestEnabled": true
9
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Damien Volkov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,68 @@
1
+ .PHONY: install sync lint test test-unit test-integration coverage generate-samples docs docs-serve docs-deploy build publish publish-test infra-up infra-down infra-logs infra-status
2
+
3
+ install:
4
+ @uv sync --dev
5
+
6
+ sync:
7
+ @uv sync --dev
8
+
9
+ lint:
10
+ @uv run ruff check --fix src/ tests/
11
+ @uv run ruff format src/ tests/
12
+
13
+ test:
14
+ @uv run pytest
15
+
16
+ test-unit:
17
+ @uv run pytest tests/unit/
18
+
19
+ test-integration:
20
+ @uv run pytest tests/integration/ --stt-url=ws://localhost:45120 --tts-url=http://localhost:45130/v1/audio/speech
21
+
22
+ coverage:
23
+ @uv run coverage run -m pytest tests/unit/ -q --no-header
24
+ @uv run coverage report
25
+
26
+ generate-samples:
27
+ @uv run python scripts/generate_samples.py
28
+
29
+ ##### DOCUMENTATION #####
30
+
31
+ docs:
32
+ @uv run mkdocs build --strict
33
+
34
+ docs-serve:
35
+ @uv run mkdocs serve
36
+
37
+ docs-deploy:
38
+ @uv run mkdocs gh-deploy --force
39
+
40
+ ##### PUBLISHING #####
41
+
42
+ build:
43
+ @rm -rf dist/
44
+ @uv build
45
+
46
+ publish-test: lint test-unit build
47
+ @test -n "$(PYPI_API_TOKEN)" || (echo "ERROR: PYPI_API_TOKEN not set" && exit 1)
48
+ @uv publish --publish-url https://test.pypi.org/legacy/ --token $(PYPI_API_TOKEN)
49
+
50
+ publish: lint test-unit build
51
+ @test -n "$(PYPI_API_TOKEN)" || (echo "ERROR: PYPI_API_TOKEN not set" && exit 1)
52
+ @uv publish --token $(PYPI_API_TOKEN)
53
+
54
+ ##### DOCKER — INTEGRATION SERVICES #####
55
+
56
+ infra-up:
57
+ @docker compose -f compose.integration.yml up -d
58
+ @echo "Waiting for services to become healthy..."
59
+ @docker compose -f compose.integration.yml ps
60
+
61
+ infra-down:
62
+ @docker compose -f compose.integration.yml down
63
+
64
+ infra-logs:
65
+ @docker compose -f compose.integration.yml logs -f
66
+
67
+ infra-status:
68
+ @docker compose -f compose.integration.yml ps
@@ -0,0 +1,282 @@
1
+ Metadata-Version: 2.4
2
+ Name: pytest-audioeval
3
+ Version: 0.1.0
4
+ Summary: Pytest plugin for STT/TTS integration testing with httpx, metrics, and embedded audio samples.
5
+ Project-URL: Homepage, https://damvolkov.github.io/pytest-audioeval
6
+ Project-URL: Documentation, https://damvolkov.github.io/pytest-audioeval
7
+ Project-URL: Repository, https://github.com/damvolkov/pytest-audioeval
8
+ Project-URL: Changelog, https://damvolkov.github.io/pytest-audioeval/changelog/
9
+ Author-email: damvolkov <damvolkovv@gmail.com>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: audio,evaluation,metrics,pesq,pytest,speech,stt,testing,tts,wer
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Framework :: Pytest
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
20
+ Classifier: Topic :: Software Development :: Testing
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.13
23
+ Requires-Dist: httpx-sse>=0.4.3
24
+ Requires-Dist: httpx-ws>=0.8.2
25
+ Requires-Dist: httpx>=0.27
26
+ Requires-Dist: jiwer>=3.0
27
+ Requires-Dist: numpy>=2.0
28
+ Requires-Dist: pesq>=0.0.4
29
+ Requires-Dist: pytest>=8.0
30
+ Requires-Dist: soundfile>=0.12
31
+ Description-Content-Type: text/markdown
32
+
33
+ # pytest-audioeval
34
+
35
+ Pytest plugin for STT/TTS integration testing. Built on the httpx ecosystem (`httpx`, `httpx-ws`, `httpx-sse`) with built-in metrics, embedded ground-truth audio samples, and chainable assertions.
36
+
37
+ ## Features
38
+
39
+ - **STT via WebSocket** — `audioeval.stt.ws()` streams audio, collects transcription
40
+ - **TTS via HTTP** — `audioeval.tts.post()` batch, `.stream()` chunked, `.sse()` Server-Sent Events
41
+ - **Text metrics** — WER, CER, substitutions, insertions, deletions (via `jiwer`)
42
+ - **Audio metrics** — PESQ MOS 1–5 scale (via `pesq`)
43
+ - **Embedded samples** — ground-truth audio + reference text pairs, multi-language ready
44
+ - **Chainable assertions** — `result.compute_metrics(ref).assert_quality(max_wer=0.2)`
45
+ - **CLI thresholds** — `--audioeval-wer`, `--audioeval-cer`, `--audioeval-mos`
46
+
47
+ ## Install
48
+
49
+ ```bash
50
+ uv add pytest-audioeval
51
+ ```
52
+
53
+ ## Quick Start
54
+
55
+ ### STT — WebSocket
56
+
57
+ ```python
58
+ import asyncio
59
+ import uuid
60
+ import orjson as json
61
+ from pytest_audioeval.client import AudioEval
62
+
63
+
64
+ async def test_user_stt_ws(audioeval: AudioEval) -> None:
65
+ sample = audioeval.samples.en_hello_world
66
+
67
+ async with audioeval.stt.ws(sample=sample) as session:
68
+ config = json.dumps(
69
+ {"uid": str(uuid.uuid4()), "language": "en", "task": "transcribe",
70
+ "model": "large-v3-turbo", "use_vad": True}
71
+ ).decode()
72
+ await session.send_text(config)
73
+
74
+ ready = await session.receive_text()
75
+ assert "SERVER_READY" in ready
76
+
77
+ await session.send_sample(sample, chunk_ms=200)
78
+ await asyncio.sleep(2)
79
+ await session.send_text("END_OF_AUDIO")
80
+
81
+ # Collect transcription segments...
82
+ ```
83
+
84
+ ### TTS — Batch POST
85
+
86
+ ```python
87
+ import io
88
+ import soundfile as sf
89
+ from pytest_audioeval.client import AudioEval
90
+
91
+
92
+ async def test_user_tts_batch(audioeval: AudioEval) -> None:
93
+ response = await audioeval.tts.post(
94
+ json={"input": "Hello world.", "model": "kokoro",
95
+ "voice": "af_heart", "response_format": "wav", "stream": False},
96
+ )
97
+ data, rate = sf.read(io.BytesIO(response.content), dtype="float32")
98
+ assert rate == 24_000
99
+ assert len(data) > 0
100
+ ```
101
+
102
+ ### TTS — Chunked Streaming
103
+
104
+ ```python
105
+ async def test_user_tts_streaming(audioeval: AudioEval) -> None:
106
+ chunks = []
107
+ async with audioeval.tts.stream(json={"input": "Hello.", ...}) as response:
108
+ async for chunk in response.aiter_bytes():
109
+ chunks.append(chunk)
110
+ assert len(chunks) > 0
111
+ ```
112
+
113
+ ### TTS — Server-Sent Events
114
+
115
+ ```python
116
+ async def test_user_tts_sse(audioeval: AudioEval) -> None:
117
+ async with audioeval.tts.sse(json={"input": "Hello.", ...}) as event_source:
118
+ async for sse in event_source.aiter_sse():
119
+ print(sse.data)
120
+ ```
121
+
122
+ ### Text Metrics
123
+
124
+ ```python
125
+ from pytest_audioeval.metrics.text import TextMetrics
126
+
127
+
128
+ async def test_user_metrics_text() -> None:
129
+ metrics = TextMetrics.compute(
130
+ reference="the quick brown fox jumps over the lazy dog",
131
+ hypothesis="the quick brown fox jumps over the lazy dock",
132
+ )
133
+ assert metrics.wer < 0.15
134
+ assert metrics.substitutions == 1
135
+ ```
136
+
137
+ ### STT Result — Chainable Assertions
138
+
139
+ ```python
140
+ from pytest_audioeval.stt import STTResult
141
+
142
+
143
+ async def test_user_stt_result() -> None:
144
+ result = STTResult(hypothesis_text="Hello world.")
145
+ result.compute_metrics("Hello world.")
146
+ result.assert_quality(max_wer=0.2, max_cer=0.15)
147
+ ```
148
+
149
+ ### Sample Registry
150
+
151
+ ```python
152
+ from pytest_audioeval.samples.registry import SampleLang
153
+
154
+
155
+ async def test_user_samples_browse(audioeval: AudioEval) -> None:
156
+ # All samples
157
+ assert len(audioeval.samples) >= 3
158
+
159
+ # Filter by language
160
+ en_samples = audioeval.samples.by_lang(SampleLang.EN)
161
+
162
+ # Attribute access: {lang}_{name}
163
+ sample = audioeval.samples.en_hello_world
164
+ assert sample.reference_text == "Hello world."
165
+
166
+ # Audio access
167
+ audio_f32 = sample.audio_numpy() # numpy float32 array
168
+ audio_raw = sample.audio_bytes() # raw bytes
169
+ chunks = sample.chunks(chunk_ms=200) # chunked for streaming
170
+ ```
171
+
172
+ ### CLI Thresholds
173
+
174
+ ```python
175
+ async def test_user_thresholds(audioeval_thresholds: dict[str, float]) -> None:
176
+ assert audioeval_thresholds["max_wer"] == 0.2
177
+ assert audioeval_thresholds["max_cer"] == 0.15
178
+ assert audioeval_thresholds["min_mos"] == 3.0
179
+ ```
180
+
181
+ ## CLI Options
182
+
183
+ ```bash
184
+ pytest --stt-url=ws://localhost:45120 --tts-url=http://localhost:45130/v1/audio/speech
185
+ pytest --audioeval-wer=0.15 --audioeval-cer=0.10 --audioeval-mos=3.5
186
+ ```
187
+
188
+ | Option | Default | Description |
189
+ |---|---|---|
190
+ | `--stt-url` | `None` | STT service WebSocket URL |
191
+ | `--tts-url` | `None` | TTS service HTTP URL |
192
+ | `--audioeval-wer` | `0.2` | Max WER threshold |
193
+ | `--audioeval-cer` | `0.15` | Max CER threshold |
194
+ | `--audioeval-mos` | `3.0` | Min PESQ MOS threshold |
195
+
196
+ ## Fixtures
197
+
198
+ | Fixture | Scope | Type | Description |
199
+ |---|---|---|---|
200
+ | `audioeval` | session | `AudioEval` | Main facade — `audioeval.stt`, `audioeval.tts`, `audioeval.samples` |
201
+ | `audioeval_thresholds` | function | `dict[str, float]` | CLI-driven threshold dict |
202
+
203
+ ## Architecture
204
+
205
+ ```
206
+ src/pytest_audioeval/
207
+ ├── plugin.py # pytest entry point (fixtures, CLI options)
208
+ ├── client.py # AudioEval facade
209
+ ├── stt.py # STTClient (httpx-ws), STTSession, STTResult
210
+ ├── tts.py # TTSClient (httpx + httpx-sse)
211
+ ├── metrics/
212
+ │ ├── text.py # TextMetrics — WER, CER via jiwer
213
+ │ └── audio.py # AudioMetrics — PESQ MOS via pesq
214
+ └── samples/
215
+ ├── registry.py # SampleRegistry + AudioSample + SampleLang
216
+ └── audio/en/ # Embedded ground-truth WAV + TXT pairs
217
+ ```
218
+
219
+ ### Clients
220
+
221
+ | Client | Transport | Methods |
222
+ |---|---|---|
223
+ | `STTClient` | `httpx-ws` | `.ws()` — WebSocket context manager yielding `STTSession` |
224
+ | `TTSClient` | `httpx` + `httpx-sse` | `.post()` batch, `.stream()` chunked, `.sse()` SSE |
225
+
226
+ ### Metrics
227
+
228
+ | Metric | Class | Source | Range |
229
+ |---|---|---|---|
230
+ | Word Error Rate (WER) | `TextMetrics` | `jiwer` | 0.0 – 1.0+ |
231
+ | Character Error Rate (CER) | `TextMetrics` | `jiwer` | 0.0 – 1.0+ |
232
+ | Substitutions / Insertions / Deletions | `TextMetrics` | `jiwer` | 0 – N |
233
+ | PESQ MOS | `AudioMetrics` | `pesq` | 1.0 – 5.0 |
234
+
235
+ ### Samples
236
+
237
+ Embedded ground-truth audio with reference transcriptions:
238
+
239
+ ```
240
+ samples/audio/
241
+ └── en/ # English (16kHz, float32)
242
+ ├── hello_world.wav # "Hello world."
243
+ ├── quick_brown_fox.wav
244
+ └── counting.wav # "One, two, three, four, five."
245
+ ```
246
+
247
+ Access: `audioeval.samples.en_hello_world`, `audioeval.samples.en_counting`, etc.
248
+
249
+ ## Infrastructure
250
+
251
+ Integration tests require GPU-accelerated TTS/STT services:
252
+
253
+ ```bash
254
+ make infra-up # Start TTS (Kokoro) + STT (WhisperLive)
255
+ make infra-status # Check health
256
+ make infra-logs # View logs
257
+ make infra-down # Stop services
258
+ ```
259
+
260
+ | Service | Image | Port | Protocol |
261
+ |---|---|---|---|
262
+ | TTS (Kokoro) | `ghcr.io/remsky/kokoro-fastapi-gpu` | `45130` | HTTP |
263
+ | STT (WhisperLive) | `ghcr.io/collabora/whisperlive-gpu` | `45120` | WebSocket |
264
+
265
+ ## Development
266
+
267
+ ```bash
268
+ make install # uv sync --dev
269
+ make lint # ruff check + format
270
+ make test-unit # unit tests (no services)
271
+ make test-integration # integration tests (requires services)
272
+ make coverage # coverage report (>90%)
273
+ ```
274
+
275
+ ## Requirements
276
+
277
+ - Python >= 3.13
278
+ - NVIDIA GPU + Docker with nvidia-container-toolkit (for integration tests)
279
+
280
+ ## License
281
+
282
+ MIT