Spaces:
Running
Running
2B-Studio: DAW-Studio, neue Modelle (YuE2, TangoFlux, AudioGen, AudioLDM2), Lizenz-Badges, HF-Login, Einswarm Schwarz/Gold
c600f78 verified Download tests/test_daw.py from 2Btainment/2b-studio: direct link, hf CLI and curl.
- Browser
- Download file 1.68 kB
-
https://huggingface.co/spaces/2Btainment/2b-studio/resolve/main/tests/test_daw.py
- Command line
-
hf download hf://spaces/2Btainment/2b-studio/tests/test_daw.py
-
curl -L -o test_daw.py https://huggingface.co/spaces/2Btainment/2b-studio/resolve/main/tests/test_daw.py
1.68 kB
| import json | |
| import numpy as np | |
| import pytest | |
| from studio.daw import api, engine | |
| SR = 48000 | |
| def _tone(seconds=2.0): | |
| t = np.arange(int(SR * seconds)) / SR | |
| x = (0.3 * np.sin(2 * np.pi * 220 * t)).astype(np.float32) | |
| return np.vstack([x, x]) | |
| def test_effects_produce_audio(effect): | |
| out, eng = engine.apply_effect(_tone(), SR, effect, {}) | |
| assert out.shape[0] == 2 and out.shape[1] > SR and np.isfinite(out).all() and eng | |
| def test_lufs_target(): | |
| out, _ = engine.apply_effect(_tone(3), SR, "lufs", {"target": -16}) | |
| assert abs(engine.lufs(out, SR) + 16) < 0.6 | |
| def test_generate_procedural_and_project_roundtrip(tmp_path): | |
| res = json.loads(api.daw_generate("sfx", "procedural", "impact", "", "", 2, 120, "", 0, None)) | |
| assert res["duration_s"] == 2.0 and res["badge"] == "free" | |
| proj = {"tracks": [], "clips": [], "assets": [{"id": "a1", "name": "x", "path": res["path"]}]} | |
| saved = json.loads(api.daw_save(json.dumps(proj), "Test", None, None)) | |
| loaded = json.loads(api.daw_load(saved["path"])) | |
| assert loaded["assets"][0]["url"].startswith("/gradio_api/file=") | |
| def test_path_guard(): | |
| with pytest.raises(Exception): | |
| api.daw_fx("/etc/passwd", "gain", "{}", 0, 0) | |
| def test_catalog_lists_license_badges(): | |
| cat = json.loads(api.daw_catalog()) | |
| ids = {e["id"] for e in cat["elements"]} | |
| assert {"full_song", "voice", "drums", "bass", "instrument", "instrumental_song", "melody_solo", | |
| "melody_ensemble", "sfx", "transition"} <= ids | |
| badges = {m["badge"] for e in cat["elements"] for m in e["models"]} | |
| assert {"free", "nc"} <= badges | |