Spaces:
Running
Running
Download tests/test_studio_room.py from 2Btainment/2b-studio: direct link, hf CLI and curl.
- Browser
- Download file 2.37 kB
-
https://huggingface.co/spaces/2Btainment/2b-studio/resolve/main/tests/test_studio_room.py
- Command line
-
hf download hf://spaces/2Btainment/2b-studio/tests/test_studio_room.py
-
curl -L -o test_studio_room.py https://huggingface.co/spaces/2Btainment/2b-studio/resolve/main/tests/test_studio_room.py
2.37 kB
| """Tests für STUDIO-Raum MVP (Katalog, Fallback-Agent, DSP).""" | |
| from __future__ import annotations | |
| from pathlib import Path | |
| import numpy as np | |
| from studio.mastering import write_wav | |
| from studio.studio_room.agent_3b import keyword_parse | |
| from studio.studio_room.catalog import make_board_wabe, validate_wabe_dict | |
| from studio.studio_room.dsp import approx_metrics, export_audio, render_chain | |
| def _tone(path: Path, freq: float = 220.0, seconds: float = 2.0, sr: int = 44100) -> Path: | |
| t = np.linspace(0, seconds, int(sr * seconds), endpoint=False) | |
| wave = (0.2 * np.sin(2 * np.pi * freq * t)).astype(np.float32) | |
| write_wav(path, np.stack([wave, wave], axis=1), sr) | |
| return path | |
| def test_keyword_spotify_board(): | |
| action = keyword_parse("mach es lauter für Spotify", analysis={"approx_lufs": -18.0}) | |
| assert action.kind == "add_board" | |
| assert action.board_id == "streaming_14" | |
| assert action.wabe is not None | |
| validate_wabe_dict(action.wabe.model_dump()) | |
| def test_keyword_export_flow(): | |
| ask = keyword_parse("fertig") | |
| assert ask.kind == "ask_export" | |
| done = keyword_parse("ja wav", awaiting_export=True) | |
| assert done.kind == "export" | |
| assert done.export_format == "wav" | |
| def test_cut_with_selection(): | |
| action = keyword_parse( | |
| "schneid raus und überblende weich", | |
| selection={"start_s": 0.5, "end_s": 1.2}, | |
| duration_s=3.0, | |
| ) | |
| assert action.kind == "add_wabe" | |
| assert action.wabe.primitives[0].id == "cut_crossfade" | |
| def test_transition_needs_two_tracks(): | |
| none = keyword_parse("Übergang wie DJ", n_tracks=1) | |
| assert none.kind == "message" | |
| ok = keyword_parse("Übergang wie DJ", n_tracks=2) | |
| assert ok.kind == "add_wabe" | |
| assert ok.wabe.primitives[0].id == "transition" | |
| def test_render_streaming_board(tmp_path: Path): | |
| src = _tone(tmp_path / "in.wav") | |
| data = np.stack([np.zeros(1000, np.float32), np.zeros(1000, np.float32)], 1) | |
| # use real file metrics | |
| from studio.mastering import read_wav | |
| audio, sr = read_wav(src) | |
| metrics = approx_metrics(audio, sr) | |
| wabe = make_board_wabe("streaming_14", metrics) | |
| out = tmp_path / "out.wav" | |
| render_chain([src], [wabe], out) | |
| assert out.is_file() and out.stat().st_size > 1000 | |
| exported = export_audio(out, "wav", tmp_path) | |
| assert exported.suffix == ".wav" and exported.is_file() | |