MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / compare_separation_step

Function compare_separation_step

tests/warmbench.py:1606–1710  ·  view source on GitHub ↗
(cpp_step: dict[str, Any], py_step: dict[str, Any])

Source from the content-addressed store, hash-verified

1604 write_wave_pcm16_mono(warmup_path, sample_rate, frames[: warmup_frames * 2])
1605 return warmup_path, requests
1606
1607
1608def compare_float(a: float, b: float, tolerance: float) -> bool:
1609 return abs(a - b) <= tolerance
1610
1611
1612def compare_kokoro(cpp_summary: dict[str, Any], py_summary: dict[str, Any]) -> dict[str, Any]:
1613 mismatches: list[str] = []
1614 for key in ("sample_rate", "channels", "samples"):
1615 if cpp_summary.get(key) != py_summary.get(key):
1616 mismatches.append(key)
1617 for key in ("sum", "mean_abs", "rms", "min", "max"):
1618 if not compare_float(float(cpp_summary.get(key, 0.0)), float(py_summary.get(key, 0.0)), 1e-4):
1619 mismatches.append(key)
1620 return {"ok": not mismatches, "reason": "ok" if not mismatches else f"mismatch:{mismatches[0]}", "mismatches": mismatches}
1621
1622
1623def compare_pocket(cpp_summary: dict[str, Any], py_summary: dict[str, Any]) -> dict[str, Any]:
1624 mismatches: list[str] = []
1625 for key in (
1626 "sample_rate",
1627 "channels",
1628 "samples",
1629 "request_char_count",
1630 "generated_steps",
1631 "test_noise_mode",
1632 "test_noise_seed",
1633 "test_noise_steps",
1634 "test_noise_latent_dim",
1635 "test_noise_hash",
1636 "test_noise_file",
1637 ):
1638 if key in cpp_summary and key in py_summary and cpp_summary.get(key) != py_summary.get(key):
1639 mismatches.append(key)
1640 tolerances = {"sum": 1e-3, "mean_abs": 1e-4, "rms": 1e-4, "min": 1e-4, "max": 1e-4}
1641 for key, tolerance in tolerances.items():
1642 if key in cpp_summary and key in py_summary and not compare_float(float(cpp_summary.get(key, 0.0)), float(py_summary.get(key, 0.0)), tolerance):
1643 mismatches.append(key)
1644 return {"ok": not mismatches, "reason": "ok" if not mismatches else f"mismatch:{mismatches[0]}", "mismatches": mismatches}
1645
1646
1647def compare_moss_tts(
1648 cpp_summary: dict[str, Any],
1649 py_summary: dict[str, Any],
1650 cpp_audio_path: Path,
1651 py_audio_path: Path,
1652 log_mel_cosine_min: float,
1653 length_ratio_min: float,
1654) -> dict[str, Any]:
1655 import librosa
1656 import numpy as np
1657 import soundfile as sf
1658
1659 mismatches: list[str] = []
1660 for key in ("sample_rate", "channels", "request_char_count"):
1661 if key in cpp_summary and key in py_summary and cpp_summary.get(key) != py_summary.get(key):
1662 mismatches.append(key)
1663

Callers 1

run_scenarioFunction · 0.85

Calls 4

maxFunction · 0.85
readMethod · 0.80
resolve_repo_pathFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected