Spaces:
Running
Running
Download backend/tests/test_audio.py from thebickersteth/voxpreference: direct link, hf CLI and curl.
- Browser
- Download file 772 Bytes
-
https://huggingface.co/spaces/thebickersteth/voxpreference/resolve/main/backend/tests/test_audio.py
- Command line
-
hf download hf://spaces/thebickersteth/voxpreference/backend/tests/test_audio.py
-
curl -L -o test_audio.py https://huggingface.co/spaces/thebickersteth/voxpreference/resolve/main/backend/tests/test_audio.py
772 Bytes
| import shutil | |
| import subprocess | |
| from pathlib import Path | |
| import pytest | |
| from pg.audio import load | |
| CLIP = Path(__file__).parent / "fixtures" / "slr70" / "ngf_05223_00109235066.wav" | |
| def test_m4a_uploaded_as_bytes_decodes_fully(tmp_path): | |
| # an M4A with its index at the end, as phones and ffmpeg write it by default | |
| m4a = tmp_path / "clip.m4a" | |
| subprocess.run(["ffmpeg", "-nostdin", "-loglevel", "error", "-i", str(CLIP), "-c:a", "aac", str(m4a)], check=True) | |
| from_path, from_bytes = load(m4a), load(m4a.read_bytes()) | |
| assert abs(len(from_bytes) - len(from_path)) < 1600 and len(from_bytes) > 16000 | |
| def test_wav_bytes_decode(): | |
| assert len(load(CLIP.read_bytes())) > 16000 | |