spectralaudit 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- spectralaudit/__init__.py +44 -0
- spectralaudit/__main__.py +3 -0
- spectralaudit/audio.py +51 -0
- spectralaudit/cli.py +73 -0
- spectralaudit/comb.py +53 -0
- spectralaudit/confounders.py +24 -0
- spectralaudit/mastering.py +105 -0
- spectralaudit/models.py +92 -0
- spectralaudit/plotting.py +38 -0
- spectralaudit/spectrum.py +79 -0
- spectralaudit/temporal.py +34 -0
- spectralaudit-0.1.0.dist-info/METADATA +115 -0
- spectralaudit-0.1.0.dist-info/RECORD +18 -0
- spectralaudit-0.1.0.dist-info/WHEEL +5 -0
- spectralaudit-0.1.0.dist-info/entry_points.txt +2 -0
- spectralaudit-0.1.0.dist-info/licenses/LICENSE +202 -0
- spectralaudit-0.1.0.dist-info/licenses/NOTICE +12 -0
- spectralaudit-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""SpectralAudit: reproducible, offline spectral diagnostics for music and audio."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from .audio import load_audio
|
|
7
|
+
from .comb import detect_comb
|
|
8
|
+
from .confounders import inspect_confounders
|
|
9
|
+
from .mastering import audit_pipeline, compare_masters
|
|
10
|
+
from .models import AuditReport
|
|
11
|
+
from .spectrum import analyze_frequencies
|
|
12
|
+
from .temporal import analyze_temporal
|
|
13
|
+
|
|
14
|
+
__version__ = "0.1.0"
|
|
15
|
+
__all__ = ["analyze", "analyze_frequencies", "detect_comb", "analyze_temporal",
|
|
16
|
+
"load_audio", "compare_masters", "audit_pipeline", "AuditReport"]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def analyze(path: str | Path, *, modules: tuple[str, ...] | list[str] = (
|
|
20
|
+
"high_frequency", "spectral_comb", "temporal", "confounders"
|
|
21
|
+
)) -> AuditReport:
|
|
22
|
+
"""Analyze audio with explicitly requested DSP modules, never determine AI origin."""
|
|
23
|
+
audio = load_audio(path)
|
|
24
|
+
valid = {"high_frequency", "spectral_comb", "temporal", "confounders"}
|
|
25
|
+
if unknown := set(modules) - valid:
|
|
26
|
+
raise ValueError(f"Unknown analysis modules: {sorted(unknown)}")
|
|
27
|
+
findings: dict = {}
|
|
28
|
+
freq = analyze_frequencies(audio.mono, audio.rate) if "high_frequency" in modules or "confounders" in modules else None
|
|
29
|
+
comb = detect_comb(audio.mono, audio.rate) if "spectral_comb" in modules or "confounders" in modules else None
|
|
30
|
+
if "high_frequency" in modules:
|
|
31
|
+
findings["high_frequency"] = freq
|
|
32
|
+
if "spectral_comb" in modules:
|
|
33
|
+
findings["spectral_comb"] = comb
|
|
34
|
+
if "temporal" in modules:
|
|
35
|
+
findings["temporal"] = analyze_temporal(audio.mono, audio.rate)
|
|
36
|
+
if "confounders" in modules:
|
|
37
|
+
findings["confounders"] = inspect_confounders(audio.metadata, freq, comb)
|
|
38
|
+
return AuditReport(
|
|
39
|
+
metadata=audio.metadata, findings=findings,
|
|
40
|
+
limitations=["Frequency-domain heuristics are not verified AI provenance indicators.",
|
|
41
|
+
"Lossy encoding, mastering, harmonic instruments, and source bandwidth can confound measurements.",
|
|
42
|
+
"Whole-file read may require substantial RAM; no streaming interface in v0.1.",
|
|
43
|
+
"Cutoff and periodicity thresholds are experimental and not calibrated on real-world corpora."],
|
|
44
|
+
)
|
spectralaudit/audio.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Local audio ingestion and baseline measurements."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
from hashlib import sha256
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
import numpy as np
|
|
9
|
+
import soundfile as sf
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass
|
|
13
|
+
class Audio:
|
|
14
|
+
samples: np.ndarray # (frames, channels), float64
|
|
15
|
+
rate: int
|
|
16
|
+
path: str
|
|
17
|
+
metadata: dict
|
|
18
|
+
|
|
19
|
+
@property
|
|
20
|
+
def mono(self) -> np.ndarray:
|
|
21
|
+
return np.mean(self.samples, axis=1)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def load_audio(path: str | Path, *, max_seconds: float | None = None) -> Audio:
|
|
25
|
+
"""Read audio without normalization; full-file load, optionally bounded by duration."""
|
|
26
|
+
source = Path(path)
|
|
27
|
+
if not source.is_file():
|
|
28
|
+
raise FileNotFoundError(source)
|
|
29
|
+
info = sf.info(str(source))
|
|
30
|
+
if info.samplerate <= 0 or info.frames < 1:
|
|
31
|
+
raise ValueError("Empty or invalid audio file")
|
|
32
|
+
if max_seconds is not None and info.frames / info.samplerate > max_seconds:
|
|
33
|
+
raise ValueError(f"Audio exceeds max_seconds={max_seconds}; no implicit truncation")
|
|
34
|
+
samples, rate = sf.read(str(source), dtype="float64", always_2d=True)
|
|
35
|
+
if samples.size == 0 or not np.all(np.isfinite(samples)):
|
|
36
|
+
raise ValueError("Audio has no samples or contains non-finite values")
|
|
37
|
+
h = sha256()
|
|
38
|
+
with source.open("rb") as stream:
|
|
39
|
+
for chunk in iter(lambda: stream.read(1024 * 1024), b""):
|
|
40
|
+
h.update(chunk)
|
|
41
|
+
peak = float(np.max(np.abs(samples)))
|
|
42
|
+
rms = float(np.sqrt(np.mean(np.square(samples))))
|
|
43
|
+
metadata = {
|
|
44
|
+
"path": str(source), "sha256": h.hexdigest(), "samplerate_hz": int(rate),
|
|
45
|
+
"duration_s": float(len(samples) / rate), "frames": int(len(samples)),
|
|
46
|
+
"channels": int(samples.shape[1]), "subtype": info.subtype,
|
|
47
|
+
"peak_amplitude": peak, "rms_amplitude": rms,
|
|
48
|
+
"clipped_sample_fraction": float(np.mean(np.abs(samples) >= 0.9999)),
|
|
49
|
+
"sample_peak_only": True,
|
|
50
|
+
}
|
|
51
|
+
return Audio(samples, rate, str(source), metadata)
|
spectralaudit/cli.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""Command-line interface with explicit file outputs."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import argparse
|
|
5
|
+
import json
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
from . import __version__, analyze, compare_masters
|
|
10
|
+
from .models import _json_default
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def make_parser() -> argparse.ArgumentParser:
|
|
14
|
+
parser = argparse.ArgumentParser(prog="spectralaudit", description="Offline audio spectral forensics (NOT an AI-origin classifier)")
|
|
15
|
+
parser.add_argument("--version", action="version", version=f"%(prog)s {__version__}")
|
|
16
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
17
|
+
for command in ("analyze", "spectrum"):
|
|
18
|
+
p = sub.add_parser(command)
|
|
19
|
+
p.add_argument("file")
|
|
20
|
+
p.add_argument("--json", dest="json_output")
|
|
21
|
+
p.add_argument("--html")
|
|
22
|
+
p = sub.add_parser("compare")
|
|
23
|
+
p.add_argument("original")
|
|
24
|
+
p.add_argument("master")
|
|
25
|
+
p.add_argument("--json", dest="json_output")
|
|
26
|
+
p.add_argument("--html")
|
|
27
|
+
p = sub.add_parser("batch")
|
|
28
|
+
p.add_argument("directory")
|
|
29
|
+
p.add_argument("--json", dest="json_output")
|
|
30
|
+
return parser
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def main(argv: list[str] | None = None) -> int:
|
|
34
|
+
args = make_parser().parse_args(argv)
|
|
35
|
+
try:
|
|
36
|
+
if args.command == "compare":
|
|
37
|
+
report = compare_masters(args.original, args.master)
|
|
38
|
+
elif args.command == "batch":
|
|
39
|
+
root = Path(args.directory)
|
|
40
|
+
if not root.is_dir():
|
|
41
|
+
raise ValueError(f"Batch input is not a directory: {root}")
|
|
42
|
+
paths = sorted(p for p in root.rglob("*") if p.is_file() and p.suffix.lower() in {".wav", ".flac"})
|
|
43
|
+
data = []
|
|
44
|
+
for path in paths:
|
|
45
|
+
try:
|
|
46
|
+
data.append({"path": str(path), "report": analyze(path).as_dict()})
|
|
47
|
+
except (OSError, ValueError, RuntimeError) as ex:
|
|
48
|
+
data.append({"path": str(path), "error": str(ex)})
|
|
49
|
+
output = json.dumps({"results": data}, indent=2, default=_json_default, allow_nan=False)
|
|
50
|
+
if args.json_output:
|
|
51
|
+
Path(args.json_output).write_text(output, encoding="utf-8")
|
|
52
|
+
else:
|
|
53
|
+
print(output)
|
|
54
|
+
return 1 if any("error" in item for item in data) else 0
|
|
55
|
+
else:
|
|
56
|
+
modules = ["high_frequency"] if args.command == "spectrum" else [
|
|
57
|
+
"high_frequency", "spectral_comb", "temporal", "confounders"]
|
|
58
|
+
report = analyze(args.file, modules=modules)
|
|
59
|
+
if args.json_output:
|
|
60
|
+
report.to_json(args.json_output)
|
|
61
|
+
if getattr(args, "html", None):
|
|
62
|
+
report.to_html(args.html)
|
|
63
|
+
if not args.json_output:
|
|
64
|
+
print(json.dumps(report.as_dict() if hasattr(report, "as_dict") else vars(report),
|
|
65
|
+
indent=2, default=_json_default, allow_nan=False))
|
|
66
|
+
return 0
|
|
67
|
+
except (OSError, ValueError, RuntimeError) as exc:
|
|
68
|
+
print(f"spectralaudit: {exc}", file=sys.stderr)
|
|
69
|
+
return 2
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
if __name__ == "__main__":
|
|
73
|
+
raise SystemExit(main())
|
spectralaudit/comb.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""Independent heuristic for approximately periodic narrow peaks in PSD residuals."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
from scipy import signal
|
|
6
|
+
from scipy.ndimage import gaussian_filter1d
|
|
7
|
+
|
|
8
|
+
from .spectrum import compute_psd
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def detect_comb(samples: np.ndarray, rate: int, *, low_hz: float = 5000,
|
|
12
|
+
high_hz: float = 16000, nperseg: int = 16384,
|
|
13
|
+
prominence_db: float = 5.0, min_peaks: int = 5) -> dict:
|
|
14
|
+
"""Diagnostic spectral periodicity, not proof of synthetic origin.
|
|
15
|
+
|
|
16
|
+
Computes residuals after spectral-envelope subtraction and inspects the
|
|
17
|
+
distances between local peaks. A stationary harmonic instrument can also
|
|
18
|
+
generate a regular comb: this is not an origin classifier.
|
|
19
|
+
"""
|
|
20
|
+
if low_hz < 0 or low_hz >= high_hz:
|
|
21
|
+
raise ValueError("Invalid frequency bounds")
|
|
22
|
+
f, p = compute_psd(samples, rate, nperseg=nperseg)
|
|
23
|
+
max_hz = min(high_hz, f[-1])
|
|
24
|
+
mask = (f >= low_hz) & (f <= max_hz)
|
|
25
|
+
if np.count_nonzero(mask) < 40:
|
|
26
|
+
return {"available": False, "reason": "Insufficient spectral bandwidth or resolution",
|
|
27
|
+
"peak_frequencies_hz": [], "estimated_spacing_hz": None, "regularity": None}
|
|
28
|
+
ff, pp = f[mask], p[mask]
|
|
29
|
+
db = 10 * np.log10(np.maximum(pp, 1e-20))
|
|
30
|
+
bin_hz = float(np.median(np.diff(ff)))
|
|
31
|
+
baseline = gaussian_filter1d(db, sigma=max(2.0, 180.0 / bin_hz))
|
|
32
|
+
residual = db - baseline
|
|
33
|
+
peaks, properties = signal.find_peaks(residual, prominence=prominence_db,
|
|
34
|
+
distance=max(1, int(30 / bin_hz)))
|
|
35
|
+
freqs = ff[peaks]
|
|
36
|
+
if len(freqs) < min_peaks:
|
|
37
|
+
return {"available": True, "peak_frequencies_hz": freqs.tolist(),
|
|
38
|
+
"peak_count": int(len(freqs)), "estimated_spacing_hz": None,
|
|
39
|
+
"regularity": None, "candidate_periodicity": False,
|
|
40
|
+
"reason": "Too few prominent peaks for periodicity estimation"}
|
|
41
|
+
# Peak sequences can have missing members. Report consecutive spacing as a
|
|
42
|
+
# descriptive statistic, not a validated synthetic-audio signature.
|
|
43
|
+
spacings = np.diff(freqs)
|
|
44
|
+
spacing = float(np.median(spacings))
|
|
45
|
+
dispersion = float(np.median(np.abs(spacings - spacing)) / max(spacing, 1e-10))
|
|
46
|
+
regularity = float(1 / (1 + dispersion))
|
|
47
|
+
# Conservative upper bound: consistency alone is not an AI indicator.
|
|
48
|
+
return {"available": True, "peak_frequencies_hz": freqs.tolist(),
|
|
49
|
+
"peak_count": int(len(freqs)), "estimated_spacing_hz": spacing,
|
|
50
|
+
"relative_spacing_mad": dispersion, "regularity": regularity,
|
|
51
|
+
"mean_prominence_db": float(np.mean(properties["prominences"])),
|
|
52
|
+
"candidate_periodicity": bool(len(freqs) >= min_peaks and dispersion < .20),
|
|
53
|
+
"reason": "Regular tonal/harmonic peaks are an alternative explanation; origin unknown"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Cautious alternative explanations grounded in observable signal properties."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def inspect_confounders(metadata: dict, frequency: dict, comb: dict) -> list[dict]:
|
|
6
|
+
result: list[dict] = []
|
|
7
|
+
nyquist = frequency["nyquist_hz"]
|
|
8
|
+
if nyquist < 21000:
|
|
9
|
+
result.append({"type": "limited_bandwidth", "observation": f"Nyquist is {nyquist:g} Hz",
|
|
10
|
+
"explanation": "High-frequency bands above Nyquist cannot be measured."})
|
|
11
|
+
cutoff = frequency["candidate_cutoff"].get("candidate_hz")
|
|
12
|
+
if cutoff is not None:
|
|
13
|
+
result.append({"type": "spectral_cutoff", "observation": f"Candidate knee at {cutoff:g} Hz",
|
|
14
|
+
"explanation": "EQ, low-pass filtering, prior encoding or content may explain the drop. Codec and origin unknown."})
|
|
15
|
+
if metadata["clipped_sample_fraction"] > 0.001:
|
|
16
|
+
result.append({"type": "sample_clipping", "observation": "Sample values approach full scale",
|
|
17
|
+
"explanation": "Clipping and limiting may change the spectrum."})
|
|
18
|
+
if comb.get("candidate_periodicity"):
|
|
19
|
+
result.append({"type": "tonal_confounder", "observation": "Regularly spaced spectral peaks",
|
|
20
|
+
"explanation": "Harmonic instruments and oscillators can create similar structures."})
|
|
21
|
+
if not result:
|
|
22
|
+
result.append({"type": "none_detected", "observation": "No configured flags raised",
|
|
23
|
+
"explanation": "Absence of flags is not evidence of human origin."})
|
|
24
|
+
return result
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"""Alignment and stage comparisons; causal attribution is intentionally excluded."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from math import gcd
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
from scipy import signal
|
|
9
|
+
|
|
10
|
+
from .audio import Audio, load_audio
|
|
11
|
+
from .comb import detect_comb
|
|
12
|
+
from .models import MasterComparison
|
|
13
|
+
from .spectrum import analyze_frequencies, compute_psd
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _resample(x: np.ndarray, from_rate: int, to_rate: int) -> np.ndarray:
|
|
17
|
+
if from_rate == to_rate:
|
|
18
|
+
return x
|
|
19
|
+
common = gcd(from_rate, to_rate)
|
|
20
|
+
return signal.resample_poly(x, to_rate // common, from_rate // common, axis=0)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _lag(a: np.ndarray, b: np.ndarray, sr: int) -> int:
|
|
24
|
+
"""Cross-correlate representative decimated mono snippets, returning shift in frames."""
|
|
25
|
+
max_len = int(sr * 8)
|
|
26
|
+
decimation = max(1, sr // 4000)
|
|
27
|
+
aa, bb = a[:max_len:decimation], b[:max_len:decimation]
|
|
28
|
+
aa = aa - np.mean(aa)
|
|
29
|
+
bb = bb - np.mean(bb)
|
|
30
|
+
if len(aa) < 16 or len(bb) < 16 or np.std(aa) < 1e-12 or np.std(bb) < 1e-12:
|
|
31
|
+
return 0
|
|
32
|
+
corr = signal.correlate(bb, aa, mode="full", method="fft")
|
|
33
|
+
lags = signal.correlation_lags(len(bb), len(aa), mode="full")
|
|
34
|
+
return int(lags[np.argmax(corr)] * decimation)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _align(a: np.ndarray, b: np.ndarray, shift: int) -> tuple[np.ndarray, np.ndarray]:
|
|
38
|
+
# positive lag: b is delayed relative to a
|
|
39
|
+
if shift > 0:
|
|
40
|
+
b = b[shift:]
|
|
41
|
+
elif shift < 0:
|
|
42
|
+
a = a[-shift:]
|
|
43
|
+
n = min(len(a), len(b))
|
|
44
|
+
if n < 32:
|
|
45
|
+
raise ValueError("Signals have insufficient overlapping samples after alignment")
|
|
46
|
+
return a[:n], b[:n]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def compare_masters(original: str | Path, master: str | Path) -> MasterComparison:
|
|
50
|
+
"""Compare two signals after time alignment and robust gain estimation."""
|
|
51
|
+
a: Audio = load_audio(original)
|
|
52
|
+
b: Audio = load_audio(master)
|
|
53
|
+
aa = a.mono
|
|
54
|
+
bb = _resample(b.mono, b.rate, a.rate)
|
|
55
|
+
lag = _lag(aa, bb, a.rate)
|
|
56
|
+
x, y = _align(aa, bb, lag)
|
|
57
|
+
energy = float(np.dot(x, x))
|
|
58
|
+
gain = float(np.dot(x, y) / energy) if energy > 1e-20 else None
|
|
59
|
+
# Equalize predicted linear gain before residual measurement.
|
|
60
|
+
residual = y - (gain or 0) * x
|
|
61
|
+
rms_residual = float(np.sqrt(np.mean(residual ** 2)))
|
|
62
|
+
f1, p1 = compute_psd(x, a.rate)
|
|
63
|
+
f2, p2 = compute_psd(y, a.rate)
|
|
64
|
+
assert np.allclose(f1, f2)
|
|
65
|
+
# PSD dB ratio (reported as measurement only, not causal diagnosis).
|
|
66
|
+
ratio_db = 10 * np.log10((p2 + 1e-20) / (p1 + 1e-20))
|
|
67
|
+
bins = [(0, 200), (200, 2000), (2000, 8000), (8000, min(16000, a.rate / 2))]
|
|
68
|
+
band_changes = []
|
|
69
|
+
for lo, hi in bins:
|
|
70
|
+
mask = (f1 >= lo) & (f1 <= hi)
|
|
71
|
+
if hi <= lo or np.count_nonzero(mask) < 2:
|
|
72
|
+
continue
|
|
73
|
+
band_changes.append({"band_hz": [lo, hi], "median_delta_db": float(np.median(ratio_db[mask]))})
|
|
74
|
+
c1, c2 = detect_comb(x, a.rate), detect_comb(y, a.rate)
|
|
75
|
+
detected_new = bool(c2.get("candidate_periodicity") and not c1.get("candidate_periodicity"))
|
|
76
|
+
new = ([{"type": "periodic_peaks_candidate", "description":
|
|
77
|
+
"Periodic peak heuristic crossed threshold in the master but not original."}]
|
|
78
|
+
if detected_new else [])
|
|
79
|
+
return MasterComparison(
|
|
80
|
+
metadata={"original": a.metadata, "master": b.metadata,
|
|
81
|
+
"aligned_frames": len(x), "analysis_rate_hz": a.rate,
|
|
82
|
+
"estimated_shift_samples": lag, "estimated_gain": gain},
|
|
83
|
+
spectral_changes={"median_band_delta_db": band_changes,
|
|
84
|
+
"gain_compensated_residual_rms": rms_residual,
|
|
85
|
+
"original_cutoff": analyze_frequencies(x, a.rate)["candidate_cutoff"],
|
|
86
|
+
"master_cutoff": analyze_frequencies(y, a.rate)["candidate_cutoff"]},
|
|
87
|
+
new_artifacts=new,
|
|
88
|
+
limitations=["Cross-correlation estimates offset on a short early snippet; complex edits can invalidate alignment.",
|
|
89
|
+
"A new detected pattern is not proof that mastering created it: content and signal nonlinearities matter.",
|
|
90
|
+
"No provenance or AI-generation classification is performed."],
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def audit_pipeline(stages: dict[str, str | Path]) -> dict:
|
|
95
|
+
"""Compare consecutive stages in insertion order; all stages are supplied explicitly."""
|
|
96
|
+
if len(stages) < 2:
|
|
97
|
+
raise ValueError("Expected at least two named stages")
|
|
98
|
+
names = list(stages)
|
|
99
|
+
results = []
|
|
100
|
+
for previous, current in zip(names, names[1:]):
|
|
101
|
+
report = compare_masters(stages[previous], stages[current])
|
|
102
|
+
results.append({"from": previous, "to": current,
|
|
103
|
+
"findings": report.spectral_changes, "new_artifacts": report.new_artifacts,
|
|
104
|
+
"limitations": report.limitations})
|
|
105
|
+
return {"stage_comparisons": results, "caveat": "Sequence of measured differences, not proof of causation"}
|
spectralaudit/models.py
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""Typed results with JSON and standalone HTML export."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from dataclasses import asdict, dataclass, field, is_dataclass
|
|
5
|
+
from html import escape
|
|
6
|
+
import json
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
import numpy as np
|
|
11
|
+
|
|
12
|
+
DISCLAIMER = (
|
|
13
|
+
"SpectralAudit performs signal-based forensic analysis. Its findings do not "
|
|
14
|
+
"constitute proof that a recording was generated by artificial intelligence."
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _json_default(value: Any) -> Any:
|
|
19
|
+
if is_dataclass(value) and not isinstance(value, type):
|
|
20
|
+
return asdict(value)
|
|
21
|
+
if isinstance(value, np.ndarray):
|
|
22
|
+
return value.tolist()
|
|
23
|
+
if isinstance(value, np.generic):
|
|
24
|
+
return value.item()
|
|
25
|
+
if isinstance(value, Path):
|
|
26
|
+
return str(value)
|
|
27
|
+
raise TypeError(f"Cannot serialize {type(value).__name__}")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@dataclass
|
|
31
|
+
class AuditReport:
|
|
32
|
+
"""Conservative observations, without an inferred AI origin probability."""
|
|
33
|
+
|
|
34
|
+
metadata: dict[str, Any]
|
|
35
|
+
findings: dict[str, Any]
|
|
36
|
+
limitations: list[str] = field(default_factory=list)
|
|
37
|
+
interpretation: str = "Origin inconclusive: spectral characteristics do not establish provenance."
|
|
38
|
+
version: str = "0.1.0"
|
|
39
|
+
|
|
40
|
+
def as_dict(self) -> dict[str, Any]:
|
|
41
|
+
return asdict(self)
|
|
42
|
+
|
|
43
|
+
def to_json(self, path: str | Path) -> Path:
|
|
44
|
+
target = Path(path)
|
|
45
|
+
target.write_text(json.dumps(self.as_dict(), indent=2, default=_json_default, allow_nan=False), encoding="utf-8")
|
|
46
|
+
return target
|
|
47
|
+
|
|
48
|
+
def to_html(self, path: str | Path) -> Path:
|
|
49
|
+
"""Write a portable HTML report with readable structured measurements."""
|
|
50
|
+
target = Path(path)
|
|
51
|
+
pretty = json.dumps(self.as_dict(), indent=2, default=_json_default, allow_nan=False)
|
|
52
|
+
payload = escape(pretty)
|
|
53
|
+
figure = ""
|
|
54
|
+
# Drawing is optional and never mutates the analyzed audio.
|
|
55
|
+
try:
|
|
56
|
+
if "sha256" in self.metadata and Path(self.metadata["path"]).is_file():
|
|
57
|
+
from .audio import load_audio
|
|
58
|
+
from .plotting import spectral_svg
|
|
59
|
+
wave = load_audio(self.metadata["path"])
|
|
60
|
+
if wave.metadata["sha256"] == self.metadata["sha256"]:
|
|
61
|
+
figure = spectral_svg(wave.mono, wave.rate)
|
|
62
|
+
except (OSError, ValueError, KeyError):
|
|
63
|
+
figure = ""
|
|
64
|
+
target.write_text(
|
|
65
|
+
"<!doctype html><html lang='en'><meta charset='utf-8'>"
|
|
66
|
+
"<meta name='viewport' content='width=device-width,initial-scale=1'>"
|
|
67
|
+
"<title>SpectralAudit report</title><style>body{max-width:960px;"
|
|
68
|
+
"margin:3rem auto;padding:0 1rem;font:16px system-ui;line-height:1.5}"
|
|
69
|
+
"pre{overflow:auto;background:#101923;color:#e4f3ef;padding:1.2rem;border-radius:9px}"
|
|
70
|
+
"small{color:#666}</style><h1>SpectralAudit report</h1>"
|
|
71
|
+
f"<p>{escape(self.interpretation)}</p><p><strong>{escape(DISCLAIMER)}</strong></p>"
|
|
72
|
+
f"{figure}<pre>{payload}</pre><small>Reproducible measurements; no origin classification.</small></html>",
|
|
73
|
+
encoding="utf-8",
|
|
74
|
+
)
|
|
75
|
+
return target
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
@dataclass
|
|
79
|
+
class MasterComparison:
|
|
80
|
+
metadata: dict[str, Any]
|
|
81
|
+
spectral_changes: dict[str, Any]
|
|
82
|
+
new_artifacts: list[dict[str, Any]]
|
|
83
|
+
limitations: list[str]
|
|
84
|
+
interpretation: str = "Differences observed; no causal or generative-origin attribution."
|
|
85
|
+
|
|
86
|
+
def to_json(self, path: str | Path) -> Path:
|
|
87
|
+
target = Path(path)
|
|
88
|
+
target.write_text(json.dumps(asdict(self), indent=2, default=_json_default, allow_nan=False), encoding="utf-8")
|
|
89
|
+
return target
|
|
90
|
+
|
|
91
|
+
def to_html(self, path: str | Path) -> Path:
|
|
92
|
+
return AuditReport(self.metadata, {"comparison": asdict(self)}, self.limitations, self.interpretation).to_html(path)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""Stand-alone inline SVG PSD plot, no JavaScript or network dependencies."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
|
|
6
|
+
from .spectrum import compute_psd
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def spectral_svg(samples: np.ndarray, sample_rate: int, *, max_points: int = 640) -> str:
|
|
10
|
+
freq, psd = compute_psd(samples, sample_rate)
|
|
11
|
+
db = 10 * np.log10(np.maximum(psd, 1e-20))
|
|
12
|
+
lo = float(np.percentile(db, 5))
|
|
13
|
+
hi = float(np.percentile(db, 99))
|
|
14
|
+
if hi - lo < 1:
|
|
15
|
+
hi = lo + 1
|
|
16
|
+
indices = np.unique(np.linspace(0, len(freq)-1, min(len(freq), max_points)).astype(int))
|
|
17
|
+
width, height = 860, 260
|
|
18
|
+
points = []
|
|
19
|
+
for idx in indices:
|
|
20
|
+
x = 45 + 790 * float(freq[idx] / max(freq[-1], 1))
|
|
21
|
+
y = 225 - 190 * np.clip((db[idx]-lo)/(hi-lo), 0, 1)
|
|
22
|
+
points.append(f"{x:.1f},{y:.1f}")
|
|
23
|
+
labels = "".join(
|
|
24
|
+
f'<text x="{45+790*f/max(freq[-1],1):.0f}" y="245" font-size="11" '
|
|
25
|
+
f'fill="#bac9cd" text-anchor="middle">{f/1000:.0f}k</text>'
|
|
26
|
+
for f in [0, 5000, 10000, 15000, 20000] if f <= freq[-1]
|
|
27
|
+
)
|
|
28
|
+
return (
|
|
29
|
+
'<figure><figcaption><strong>Power spectral density (dB/Hz)</strong>'
|
|
30
|
+
' — logarithmic power scale; visualization only</figcaption>'
|
|
31
|
+
f'<svg viewBox="0 0 {width} {height}" role="img" '
|
|
32
|
+
'aria-label="Spectral power density vs frequency" '
|
|
33
|
+
'style="width:100%;background:#101923;border-radius:9px">'
|
|
34
|
+
'<path d="M45 20 V225 H835" fill="none" stroke="#81939a"/>'
|
|
35
|
+
f'<polyline points="{" ".join(points)}" fill="none" '
|
|
36
|
+
'stroke="#32c0b4" stroke-width="1.6"/>'
|
|
37
|
+
f'{labels}</svg></figure>'
|
|
38
|
+
)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"""Power spectral density, band energy, and candidate low-pass knees."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
from scipy import signal
|
|
6
|
+
|
|
7
|
+
DEFAULT_BANDS = [(5000, 10000), (10000, 12000), (12000, 16000),
|
|
8
|
+
(16000, 17000), (17000, 19000), (19000, 21000)]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def compute_psd(samples: np.ndarray, rate: int, *, nperseg: int = 8192) -> tuple[np.ndarray, np.ndarray]:
|
|
12
|
+
x = np.asarray(samples, dtype=np.float64)
|
|
13
|
+
if x.ndim != 1 or not x.size or rate <= 0:
|
|
14
|
+
raise ValueError("Expected nonempty 1D samples and positive sample rate")
|
|
15
|
+
f, p = signal.welch(x, fs=rate, nperseg=min(nperseg, x.size),
|
|
16
|
+
window="hann", detrend="constant", scaling="density")
|
|
17
|
+
return f, p
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _power(f: np.ndarray, p: np.ndarray, lo: float, hi: float) -> float:
|
|
21
|
+
mask = (f >= lo) & (f <= hi)
|
|
22
|
+
if np.count_nonzero(mask) < 2:
|
|
23
|
+
return 0.0
|
|
24
|
+
return float(np.trapezoid(p[mask], f[mask]))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def estimate_cutoff(f: np.ndarray, p: np.ndarray, *, min_hz: float = 3000) -> dict:
|
|
28
|
+
"""Find steep high-frequency drops via smoothing and log-power derivative.
|
|
29
|
+
|
|
30
|
+
Heuristic, not a proven codec detector or generative-origin classifier.
|
|
31
|
+
"""
|
|
32
|
+
valid = (f >= min_hz) & (f <= f[-1] * .98)
|
|
33
|
+
if np.count_nonzero(valid) < 30:
|
|
34
|
+
return {"candidate_hz": None, "steepness_db_per_khz": None, "method": "insufficient_band"}
|
|
35
|
+
ff, pp = f[valid], p[valid]
|
|
36
|
+
# Aggregate into 150 Hz bins to avoid narrow tonal peaks.
|
|
37
|
+
bw = 150.0
|
|
38
|
+
bin_ids = np.floor((ff - ff[0]) / bw).astype(int)
|
|
39
|
+
centers, db = [], []
|
|
40
|
+
for idx in np.unique(bin_ids):
|
|
41
|
+
vals = pp[bin_ids == idx]
|
|
42
|
+
centers.append(float(np.median(ff[bin_ids == idx])))
|
|
43
|
+
db.append(float(10 * np.log10(max(float(np.median(vals)), 1e-20))))
|
|
44
|
+
centers, db = np.asarray(centers), np.asarray(db)
|
|
45
|
+
if len(db) < 9:
|
|
46
|
+
return {"candidate_hz": None, "steepness_db_per_khz": None, "method": "insufficient_bins"}
|
|
47
|
+
from scipy.ndimage import median_filter
|
|
48
|
+
smooth = median_filter(db, size=5, mode="nearest")
|
|
49
|
+
slopes = np.gradient(smooth, centers) * 1000
|
|
50
|
+
# Sharp knee must exceed an intentionally conservative heuristic threshold.
|
|
51
|
+
i = int(np.argmin(slopes))
|
|
52
|
+
return {"candidate_hz": round(float(centers[i]), 1) if slopes[i] < -35 else None,
|
|
53
|
+
"steepness_db_per_khz": round(float(slopes[i]), 2),
|
|
54
|
+
"heuristic_threshold_db_per_khz": -35.0, "method": "median_binned_log_psd_slope"}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def analyze_frequencies(samples: np.ndarray, rate: int, *, bands=None) -> dict:
|
|
58
|
+
f, p = compute_psd(samples, rate)
|
|
59
|
+
bands = DEFAULT_BANDS if bands is None else bands
|
|
60
|
+
nyquist = rate / 2
|
|
61
|
+
total = _power(f, p, 0, nyquist)
|
|
62
|
+
output = []
|
|
63
|
+
for lo, hi in bands:
|
|
64
|
+
if lo < 0 or hi <= lo:
|
|
65
|
+
raise ValueError("Band limits must satisfy 0 <= lower < upper")
|
|
66
|
+
if hi > nyquist:
|
|
67
|
+
output.append({"band_hz": [lo, hi], "available": False,
|
|
68
|
+
"power": None, "relative_power": None})
|
|
69
|
+
else:
|
|
70
|
+
power = _power(f, p, lo, hi)
|
|
71
|
+
output.append({"band_hz": [lo, hi], "available": True,
|
|
72
|
+
"power": power, "relative_power": power / total if total > 0 else None})
|
|
73
|
+
mask = (f >= 1000) & (f <= nyquist)
|
|
74
|
+
flatness = None
|
|
75
|
+
if np.count_nonzero(mask) > 2:
|
|
76
|
+
pp = p[mask]
|
|
77
|
+
flatness = float(np.exp(np.mean(np.log(pp + 1e-20))) / (np.mean(pp) + 1e-20))
|
|
78
|
+
return {"nyquist_hz": nyquist, "bands": output, "spectral_flatness_above_1khz": flatness,
|
|
79
|
+
"candidate_cutoff": estimate_cutoff(f, p), "method": "Welch PSD; Hann window"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""Window-level spectral measurements and persistence summaries."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
|
|
6
|
+
from .comb import detect_comb
|
|
7
|
+
from .spectrum import analyze_frequencies
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def analyze_temporal(samples: np.ndarray, rate: int, *, window_seconds: float = 5.0,
|
|
11
|
+
max_windows: int = 48) -> dict:
|
|
12
|
+
if window_seconds <= 0 or max_windows < 1:
|
|
13
|
+
raise ValueError("window_seconds and max_windows must be positive")
|
|
14
|
+
size = max(1, int(rate * window_seconds))
|
|
15
|
+
n = len(samples) // size
|
|
16
|
+
if n == 0:
|
|
17
|
+
return {"available": False, "reason": "Audio is shorter than analysis window", "windows": []}
|
|
18
|
+
# Deterministic representative window positions for long recordings.
|
|
19
|
+
indices = np.unique(np.linspace(0, n - 1, min(n, max_windows)).astype(int))
|
|
20
|
+
windows = []
|
|
21
|
+
for idx in indices:
|
|
22
|
+
start = int(idx * size)
|
|
23
|
+
part = samples[start:start + size]
|
|
24
|
+
combo = detect_comb(part, rate)
|
|
25
|
+
spectrum = analyze_frequencies(part, rate)
|
|
26
|
+
windows.append({"start_s": float(start / rate),
|
|
27
|
+
"end_s": float((start + size) / rate),
|
|
28
|
+
"periodicity_candidate": bool(combo.get("candidate_periodicity", False)),
|
|
29
|
+
"cutoff_candidate_hz": spectrum["candidate_cutoff"].get("candidate_hz")})
|
|
30
|
+
return {"available": True, "windows": windows,
|
|
31
|
+
"periodicity_candidate_fraction": float(np.mean([w["periodicity_candidate"] for w in windows])),
|
|
32
|
+
"analyzed_window_count": len(windows),
|
|
33
|
+
"total_full_windows": n,
|
|
34
|
+
"method": "nonoverlapping_window_subsample"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: spectralaudit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Explainable, offline DSP for spectral audio forensics and mastering comparisons
|
|
5
|
+
Author: Eduardo J. Barrios
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/edujbarrios/spectralaudit
|
|
8
|
+
Project-URL: Source, https://github.com/edujbarrios/spectralaudit
|
|
9
|
+
Project-URL: Issues, https://github.com/edujbarrios/spectralaudit/issues
|
|
10
|
+
Keywords: audio,music,spectral-analysis,forensics,dsp,mastering
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Analysis
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
License-File: NOTICE
|
|
24
|
+
Requires-Dist: numpy>=1.26
|
|
25
|
+
Requires-Dist: scipy>=1.11
|
|
26
|
+
Requires-Dist: soundfile>=0.12
|
|
27
|
+
Provides-Extra: plot
|
|
28
|
+
Requires-Dist: matplotlib>=3.8; extra == "plot"
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
31
|
+
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
32
|
+
Requires-Dist: build>=1.2; extra == "dev"
|
|
33
|
+
Requires-Dist: twine>=5; extra == "dev"
|
|
34
|
+
Requires-Dist: cffconvert>=2.0; extra == "dev"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# SpectralAudit
|
|
38
|
+
|
|
39
|
+
**Offline spectral analysis for music and final masters.** A Python library by **Eduardo J. Barrios**.
|
|
40
|
+
|
|
41
|
+
[](https://github.com/edujbarrios/spectralaudit/actions/workflows/ci.yml)
|
|
42
|
+
[](LICENSE)
|
|
43
|
+
|
|
44
|
+
SpectralAudit measures **high-frequency energy, spectral cutoffs and regularly spaced spectral peaks** in WAV/FLAC audio. It also compares a premaster and final master to reveal measurable differences between versions. Processing runs **locally** with NumPy and SciPy: no LLMs, AI models or external APIs.
|
|
45
|
+
|
|
46
|
+
**Important:** SpectralAudit is **not a validated detector of AI-generated music**. Frequencies above 17 kHz, low-pass cutoffs and periodic peaks do **not** prove AI origin. Results are measurements with stated limitations.
|
|
47
|
+
|
|
48
|
+
## Install
|
|
49
|
+
|
|
50
|
+
Requires Python 3.11+.
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install spectralaudit
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Before the first PyPI release, install from the repository:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install git+https://github.com/edujbarrios/spectralaudit.git
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Quick start
|
|
63
|
+
|
|
64
|
+
Analyze a master and export an HTML and JSON report:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
spectralaudit analyze final_master.wav --html report.html --json report.json
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Inspect frequency bands, compare two versions, or analyze a folder:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
spectralaudit spectrum final_master.wav
|
|
74
|
+
spectralaudit compare premaster.wav final_master.wav --html comparison.html
|
|
75
|
+
spectralaudit batch ./music --json batch.json
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Python API:
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from spectralaudit import analyze, compare_masters
|
|
82
|
+
|
|
83
|
+
report = analyze("final_master.wav")
|
|
84
|
+
print(report.findings["high_frequency"]["candidate_cutoff"])
|
|
85
|
+
print(report.findings["spectral_comb"]["candidate_periodicity"])
|
|
86
|
+
print(report.interpretation) # Origin inconclusive: ...
|
|
87
|
+
report.to_html("report.html")
|
|
88
|
+
|
|
89
|
+
comparison = compare_masters("premaster.wav", "final_master.wav")
|
|
90
|
+
print(comparison.spectral_changes)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## What it measures
|
|
94
|
+
|
|
95
|
+
- **Frequency bands:** Welch power spectrum, relative band energy and candidate high-frequency cutoff, respecting the file's Nyquist limit.
|
|
96
|
+
- **Periodic peaks:** spacing of narrow spectral peaks; also possible in conventional harmonic music.
|
|
97
|
+
- **Time:** persistence of candidate patterns in successive audio windows.
|
|
98
|
+
- **Alternative explanations:** flags for sample-rate and processing-related ambiguities.
|
|
99
|
+
- **Master comparison:** estimated time offset, gain and band-level spectral differences.
|
|
100
|
+
|
|
101
|
+
The same inputs and settings produce deterministic analyses. Detection thresholds are **exploratory heuristics**, not calibrated AI-origin probabilities. Large files are read into memory; input audio is never modified. See [Methods](docs/algorithms.md) and [Limitations](docs/limitations.md).
|
|
102
|
+
|
|
103
|
+
## Research, citation and license
|
|
104
|
+
|
|
105
|
+
If you use SpectralAudit in research, **please cite Eduardo J. Barrios and the version used**. See [CITATION.cff](CITATION.cff) and [how to cite](CITING.md).
|
|
106
|
+
|
|
107
|
+
Selected scientific references:
|
|
108
|
+
|
|
109
|
+
- Afchar et al. (2025), *A Fourier Explanation of AI-music Artifacts* ([paper](https://arxiv.org/abs/2506.19108)).
|
|
110
|
+
- Cros Vila et al. (2025), *The AI Music Arms Race* ([DOI](https://doi.org/10.5334/tismir.254)).
|
|
111
|
+
- Welch (1967), *The Use of Fast Fourier Transform for the Estimation of Power Spectra* ([DOI](https://doi.org/10.1109/TAU.1967.1161901)).
|
|
112
|
+
|
|
113
|
+
Full bibliography and implementation distinctions: [REFERENCES.md](REFERENCES.md).
|
|
114
|
+
|
|
115
|
+
**Copyright © 2026 Eduardo J. Barrios.** Open source under the [Apache License 2.0](LICENSE); see [NOTICE](NOTICE). Redistribution must preserve applicable notices. Academic citation is requested, not an additional legal condition of the license.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
spectralaudit/__init__.py,sha256=4vZ358mdmkdgvJnmyULi_XrkY9SPH4HAq6umP0hLCCc,2218
|
|
2
|
+
spectralaudit/__main__.py,sha256=k1ocEWawweo1qCJWNFAAvyxz3tcY13dzvCenHszij30,48
|
|
3
|
+
spectralaudit/audio.py,sha256=JafLlOLUxrCTZZr38n8nwENn68CtcOEVbi0AKA5rpHg,1951
|
|
4
|
+
spectralaudit/cli.py,sha256=i-9p6eZ34zLZXuyxR7pBdzI9S7xFXfQdIqjuZVK5Z8Y,3002
|
|
5
|
+
spectralaudit/comb.py,sha256=mGN5AHx8CC7hw2qaR2hU3F-L5tQ2hdT0aUGdrOegcgw,2833
|
|
6
|
+
spectralaudit/confounders.py,sha256=KI6yfqsLoXF-YVJcFi0-_2lI2Wu27U_zK25_iL4UXck,1536
|
|
7
|
+
spectralaudit/mastering.py,sha256=MUx6xAwAY7fDbGieoVJk53OW-r2z9ALkMu9-RnrkT_0,4806
|
|
8
|
+
spectralaudit/models.py,sha256=dXz_djav3gQ5y6LWfhIKiNqJN-p4Vsp8HwsYPho2iRg,3753
|
|
9
|
+
spectralaudit/plotting.py,sha256=pAsiW4NY97Q8BEHp_l0geK8osFGLphHwAXLeFS1j2Jo,1600
|
|
10
|
+
spectralaudit/spectrum.py,sha256=8-2LWg_PuEgnOqWFIQKj0eAROqpx2V_ppnBPKz86Oq8,3591
|
|
11
|
+
spectralaudit/temporal.py,sha256=FtXIiHwhJ_uo5t752YL8fY77rtYJiLfFBxeZL5kcBNI,1631
|
|
12
|
+
spectralaudit-0.1.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
13
|
+
spectralaudit-0.1.0.dist-info/licenses/NOTICE,sha256=zlB89ipByyRLQgkMpTINrR4NLwRtlXQRcI16xBT6CuY,573
|
|
14
|
+
spectralaudit-0.1.0.dist-info/METADATA,sha256=MIl6jovk_H6LYelZeI11v5CFgwyLTRsA7pJ6-JWgw-o,5136
|
|
15
|
+
spectralaudit-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
16
|
+
spectralaudit-0.1.0.dist-info/entry_points.txt,sha256=eHAUlLhGoVTxyYkB7zbBiT1cifgOcnbRdj6OjJK8tyM,57
|
|
17
|
+
spectralaudit-0.1.0.dist-info/top_level.txt,sha256=yREtsi6lbicZfCLjH8H3OZ5aO9xvIqL6siqiEJS57Hw,14
|
|
18
|
+
spectralaudit-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
SpectralAudit
|
|
2
|
+
Copyright 2026 Eduardo J. Barrios
|
|
3
|
+
https://github.com/edujbarrios/spectralaudit
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0. See LICENSE.
|
|
6
|
+
When distributing the software or derivative distributions, retain the
|
|
7
|
+
applicable copyright, attribution, and NOTICE material as required by the license.
|
|
8
|
+
|
|
9
|
+
Academic citation request (not an additional license restriction):
|
|
10
|
+
If SpectralAudit informs a research paper, thesis, dataset, or scientific report,
|
|
11
|
+
please cite Eduardo J. Barrios and identify the used software version as described
|
|
12
|
+
in CITATION.cff and CITING.md.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
spectralaudit
|