Download tests/test_benchmark.py from NabuxAi/buddi-asr-source-code: direct link, hf CLI and curl.
- Browser
- Download file 957 Bytes
-
https://huggingface.co/datasets/NabuxAi/buddi-asr-source-code/resolve/main/tests/test_benchmark.py
- Command line
-
hf download hf://datasets/NabuxAi/buddi-asr-source-code/tests/test_benchmark.py
-
curl -L -o test_benchmark.py https://huggingface.co/datasets/NabuxAi/buddi-asr-source-code/resolve/main/tests/test_benchmark.py
957 Bytes
| from __future__ import annotations | |
| import tempfile | |
| import unittest | |
| from pathlib import Path | |
| from buddi_asr.benchmark import _multipart, _percentile | |
| class BenchmarkTests(unittest.TestCase): | |
| def test_percentile(self) -> None: | |
| self.assertEqual(_percentile([1.0, 2.0, 3.0, 4.0], 0.50), 3.0) | |
| self.assertEqual(_percentile([], 0.95), 0.0) | |
| def test_multipart_contains_audio_and_language(self) -> None: | |
| with tempfile.TemporaryDirectory() as directory: | |
| audio = Path(directory) / "sensitive-original-name.wav" | |
| audio.write_bytes(b"RIFF-test") | |
| body, boundary = _multipart(audio, "ar") | |
| self.assertIn(b"RIFF-test", body) | |
| self.assertIn(b'name="language"', body) | |
| self.assertIn(b"\r\n\r\nar\r\n", body) | |
| self.assertNotIn(b"sensitive-original-name", body) | |
| self.assertIn(boundary.encode(), body) | |
| if __name__ == "__main__": | |
| unittest.main() | |