Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions assets/samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@
# - `Fort-Zeelandia.png` — LoadImage / image-conditioned GenerateVideo
# - `automation_cc7.mid` — LoadMIDI / MIDIToFloat / MIDINoteGate Help examples
#
# Cold/hero Whisper gates use tracked `tests/golden/fixtures/dialogue_48k.wav`
# (not this folder — `*.wav` is gitignored here except allowlisted demos).
#
# `archived/` is local-only (gitignored).
29 changes: 17 additions & 12 deletions tests/test_cold_machine_hero.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
import shutil
from pathlib import Path

import numpy as np
import pytest
import soundfile as sf
from groovy.executor import Executor
from groovy.nodes.ai import register_all as register_ai
from groovy.nodes.ai.inference_env import whisper_available
Expand All @@ -26,7 +24,9 @@
from template_fixtures import require_template
PODCAST = require_template("podcast-denoise")
DIALOGUE = require_template("transcribe-dialogue")
DIALOGUE_FIXTURE = ROOT / "assets" / "samples" / "dialogue_48k.wav"
# Tracked golden — assets/samples/*.wav is gitignored except allowlisted demos.
DIALOGUE_FIXTURE = ROOT / "tests" / "golden" / "fixtures" / "dialogue_48k.wav"
PODCAST_SHIPPED = ROOT / "assets" / "samples" / "podcast_denoise_demo.wav"


pytestmark = pytest.mark.integration
Expand All @@ -39,13 +39,19 @@ def project_dir(tmp_path: Path) -> Path:
if not shutil.which("uv"):
pytest.skip("uv is required for Model Browser python_deps install")

assert DIALOGUE_FIXTURE.is_file(), (
"Missing tests/golden/fixtures/dialogue_48k.wav — fail closed "
"(Whisper cold gate must not skip)"
)
assert PODCAST_SHIPPED.is_file(), (
"Missing assets/samples/podcast_denoise_demo.wav — cold podcast gate "
"must use shipped demo WAV"
)

assets = tmp_path / "assets" / "samples"
assets.mkdir(parents=True)
sr = 48_000
t = np.linspace(0, 1.0, int(sr), endpoint=False)
sf.write(assets / "podcast_denoise_demo.wav", 0.25 * np.sin(2 * np.pi * 440 * t), sr)
if DIALOGUE_FIXTURE.is_file():
shutil.copy(DIALOGUE_FIXTURE, assets / "dialogue_48k.wav")
shutil.copy(PODCAST_SHIPPED, assets / "podcast_denoise_demo.wav")
shutil.copy(DIALOGUE_FIXTURE, assets / "dialogue_48k.wav")
return tmp_path


Expand Down Expand Up @@ -99,14 +105,13 @@ def test_whisper_install_from_model_browser(project_dir: Path) -> None:


def test_transcribe_dialogue_cold_machine_gate(project_dir: Path) -> None:
if not (project_dir / "assets" / "samples" / "dialogue_48k.wav").is_file():
pytest.skip("dialogue_48k.wav fixture missing from assets/samples")
dialogue = project_dir / "assets" / "samples" / "dialogue_48k.wav"
assert dialogue.is_file(), "dialogue_48k.wav must be staged from golden fixtures"

registry = ModelRegistry(project_dir)
install = registry.installer.install("whisper-large-v3-turbo")
assert install.status == "ready", install.error
if not whisper_available():
pytest.skip("faster_whisper unavailable after install")
assert whisper_available(), "faster_whisper unavailable after Model Browser install"

workflow = Workflow.model_validate(json.loads(DIALOGUE.read_text()))
for node in workflow.nodes:
Expand Down
25 changes: 25 additions & 0 deletions tests/test_dialogue_fixture_gate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Fail-closed gate: dialogue fixture must be present for cold/hero Whisper paths."""

from __future__ import annotations

from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
DIALOGUE_GOLDEN = ROOT / "tests" / "golden" / "fixtures" / "dialogue_48k.wav"
PODCAST_SHIPPED = ROOT / "assets" / "samples" / "podcast_denoise_demo.wav"


def test_dialogue_golden_fixture_present() -> None:
assert DIALOGUE_GOLDEN.is_file(), (
"Missing tests/golden/fixtures/dialogue_48k.wav — cold/hero Whisper gates "
"must fail closed (do not skip). Restore the tracked golden fixture."
)
assert DIALOGUE_GOLDEN.stat().st_size > 1_000


def test_podcast_denoise_demo_shipped() -> None:
assert PODCAST_SHIPPED.is_file(), (
"Missing assets/samples/podcast_denoise_demo.wav — cold podcast gate "
"must use the shipped demo WAV (git allowlisted), not a synthetic tone."
)
assert PODCAST_SHIPPED.stat().st_size > 1_000
15 changes: 9 additions & 6 deletions tests/test_featured_real_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

ROOT = Path(__file__).resolve().parents[1]
from template_fixtures import require_template
DIALOGUE_FIXTURE = ROOT / "assets" / "samples" / "dialogue_48k.wav"
DIALOGUE_FIXTURE = ROOT / "tests" / "golden" / "fixtures" / "dialogue_48k.wav"

FEATURED = [
"podcast-denoise",
Expand Down Expand Up @@ -87,8 +87,11 @@ def project_dir(tmp_path: Path) -> Path:
noise = 0.02 * np.random.default_rng(0).standard_normal(t.size)
sf.write(assets / "podcast_denoise_demo.wav", tone + noise, sr)
sf.write(assets / "Knockout_41k_mono.wav", tone + noise, sr)
if DIALOGUE_FIXTURE.is_file():
shutil.copy(DIALOGUE_FIXTURE, assets / "dialogue_48k.wav")
assert DIALOGUE_FIXTURE.is_file(), (
"Missing tests/golden/fixtures/dialogue_48k.wav — fail closed "
"(featured Whisper templates must not fall back silently)"
)
shutil.copy(DIALOGUE_FIXTURE, assets / "dialogue_48k.wav")
return tmp_path


Expand Down Expand Up @@ -120,9 +123,9 @@ def test_featured_template_real_inference(project_dir: Path, template_id: str) -
sample = "assets/samples/podcast_denoise_demo.wav"
if template_id == "stem-separation":
sample = "assets/samples/Knockout_41k_mono.wav"
if template_id in {"transcribe-dialogue", "transcribe-and-diarize"} and (
project_dir / "assets" / "samples" / "dialogue_48k.wav"
).is_file():
if template_id in {"transcribe-dialogue", "transcribe-and-diarize"}:
dialogue = project_dir / "assets" / "samples" / "dialogue_48k.wav"
assert dialogue.is_file(), "dialogue_48k.wav must be staged from golden fixtures"
sample = "assets/samples/dialogue_48k.wav"
if template_id in {"text-to-music", "hello-groovy"}:
sample = None
Expand Down
16 changes: 9 additions & 7 deletions tests/test_hero_real_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
PODCAST = require_template("podcast-denoise")
STEMS = require_template("stem-separation")
DIALOGUE = require_template("transcribe-dialogue")
DIALOGUE_FIXTURE = ROOT / "assets" / "samples" / "dialogue_48k.wav"
DIALOGUE_FIXTURE = ROOT / "tests" / "golden" / "fixtures" / "dialogue_48k.wav"

# EXECUTOR_SPEC: Demucs verify SNR ≥ 40 dB. Short synthetic tones are looser.
DEMUCS_RECONSTRUCTION_SNR_DB = 20.0
Expand Down Expand Up @@ -74,8 +74,11 @@ def project_dir(tmp_path: Path) -> Path:
noise = 0.02 * np.random.default_rng(0).standard_normal(t.size)
sf.write(assets / "podcast_denoise_demo.wav", tone + noise, sr)
sf.write(assets / "Knockout_41k_mono.wav", tone + noise, sr)
if DIALOGUE_FIXTURE.is_file():
shutil.copy(DIALOGUE_FIXTURE, assets / "dialogue_48k.wav")
assert DIALOGUE_FIXTURE.is_file(), (
"Missing tests/golden/fixtures/dialogue_48k.wav — fail closed "
"(Whisper hero gate must not skip)"
)
shutil.copy(DIALOGUE_FIXTURE, assets / "dialogue_48k.wav")
return tmp_path


Expand Down Expand Up @@ -216,12 +219,11 @@ def test_stem_split_vocals_real_inference_tolerance(project_dir: Path) -> None:


def test_transcribe_dialogue_real_inference_tolerance(project_dir: Path) -> None:
if not (project_dir / "assets" / "samples" / "dialogue_48k.wav").is_file():
pytest.skip("dialogue_48k.wav fixture missing from assets/samples")
dialogue = project_dir / "assets" / "samples" / "dialogue_48k.wav"
assert dialogue.is_file(), "dialogue_48k.wav must be staged from golden fixtures"

_ensure_model(project_dir, "whisper-large-v3-turbo")
if not whisper_available():
pytest.skip("faster_whisper unavailable after install")
assert whisper_available(), "faster_whisper unavailable after Model Browser install"

workflow = _load_template(DIALOGUE, sample="assets/samples/dialogue_48k.wav")
executor = Executor(project_dir)
Expand Down
Loading