Spaces:
Paused
Paused
v1.1 Ω FUSION + display name Tune-Whisperer; keeps owner-only library/guest isolation (fusion scoped), Demucs 120s, /data
e880b2b verified Download tests/test_fusion.py from 2Btainment/absolution-omega: direct link, hf CLI and curl.
- Browser
- Download file 4.26 kB
-
https://huggingface.co/spaces/2Btainment/absolution-omega/resolve/main/tests/test_fusion.py
- Command line
-
hf download hf://spaces/2Btainment/absolution-omega/tests/test_fusion.py
-
curl -L -o test_fusion.py https://huggingface.co/spaces/2Btainment/absolution-omega/resolve/main/tests/test_fusion.py
4.26 kB
| """Ω FUSION: one user job orchestrates available real components truthfully.""" | |
| import hashlib | |
| import io | |
| import time | |
| import numpy as np | |
| import soundfile as sf | |
| from fastapi.testclient import TestClient | |
| from app.server import create_app | |
| def make_input(sr=8000): | |
| t=np.arange(sr*2)/sr | |
| stereo=np.stack([ | |
| .09*np.sin(2*np.pi*97*t)+.03*np.sin(2*np.pi*540*t), | |
| .08*np.sin(2*np.pi*97*t)+.028*np.sin(2*np.pi*540*t), | |
| ],axis=1).astype("float32") | |
| stereo[3422,:]+=.64 | |
| out=io.BytesIO() | |
| sf.write(out,stereo,sr,format="WAV",subtype="FLOAT") | |
| return out.getvalue(),stereo | |
| def until_done(client, jid): | |
| for _ in range(380): | |
| resp=client.get("/api/v1/jobs/"+jid) | |
| assert resp.status_code==200 | |
| job=resp.json() | |
| if job["status"] in ("done", "failed"): | |
| return job | |
| time.sleep(.06) | |
| raise AssertionError("FUSION took too long") | |
| def upload(client, contents): | |
| project=client.post("/api/v1/projects",json={"name":"Ω FUSION Demo"}).json() | |
| pid=project["id"] | |
| response=client.post("/api/v1/assets",data={"project_id":pid}, | |
| files={"file":("input.wav",contents,"audio/wav")}) | |
| assert response.status_code==201,response.text | |
| return pid | |
| def test_fusion_integrated_dsp_flow_and_non_destructive_mix(tmp_path): | |
| data, samples=make_input() | |
| checksum=hashlib.sha256(data).hexdigest() | |
| with TestClient(create_app(tmp_path/"run")) as client: | |
| pid=upload(client,data) | |
| start=client.post("/api/v1/jobs/fusion",json={ | |
| "project_id":pid,"mode":"dsp","scan_noise":True, | |
| "include_event_proxies":True | |
| }) | |
| assert start.status_code==202,start.text | |
| job=until_done(client,start.json()["id"]) | |
| assert job["status"]=="done",job | |
| assert job["progress"]==100 | |
| manifest=client.get(f"/api/v1/projects/{pid}").json() | |
| fusion=manifest["fusion"] | |
| assert fusion["name"]=="Ω FUSION" | |
| assert fusion["method"]=="hpss" | |
| assert fusion["bass_parent"]=={"kick":"percussive","bassline":"harmonic"} | |
| assert fusion["source_sha256"]==checksum | |
| assert "vocals" not in fusion["stems"] | |
| assert "kick_core" in fusion["stems"] | |
| assert "bassline_core" in fusion["stems"] | |
| assert fusion["stems"]["kick_core"]["type"]=="dsp_estimate" | |
| assert "noise_difference" not in fusion["stems"] | |
| assert fusion["noise_removal_automatic"] is False | |
| assert any("Vocals" in w for w in fusion["warnings"]) | |
| assert manifest["noise"]["scan"] is not None | |
| assert manifest["noise"]["repair"] is None | |
| assert manifest["unified"]["mix_consistent"] | |
| assert manifest["asset"]["sha256"]==checksum | |
| assert client.get(f"/api/v1/projects/{pid}/audio/original").status_code==200 | |
| rendered=client.post("/api/v1/jobs/mix",json={"project_id":pid}) | |
| assert rendered.status_code==202,rendered.text | |
| assert until_done(client,rendered.json()["id"])["status"]=="done" | |
| mix=client.get(f"/api/v1/projects/{pid}/mixer/audio") | |
| assert mix.status_code==200 | |
| decoded,_=sf.read(io.BytesIO(mix.content),always_2d=True) | |
| assert np.max(np.abs(decoded-samples))<8e-5 | |
| def test_fusion_neural_mode_requires_checkpoints_and_does_not_fake_vocals(tmp_path): | |
| data,_=make_input() | |
| with TestClient(create_app(tmp_path/"neural")) as client: | |
| pid=upload(client,data) | |
| result=client.post("/api/v1/jobs/fusion", | |
| json={"project_id":pid,"mode":"neural"}) | |
| assert result.status_code==409 | |
| assert not client.get(f"/api/v1/projects/{pid}").json()["stems"] | |
| def test_fusion_ui_provides_single_button_and_provenance(tmp_path): | |
| with TestClient(create_app(tmp_path/"ui")) as client: | |
| page=client.get("/").text | |
| script=client.get("/static/studio.js").text | |
| assert 'data-action="fusion"' in page | |
| assert 'id="fusionMode"' in page | |
| assert 'id="fusionLineage"' in page | |
| assert 'data-action="bass"' in page # advanced tool remains real | |
| assert 'data-action="scan"' in page # approved scan available | |
| assert '"/jobs/fusion"' in script | |
| assert "renderFusionSummary" in script | |