4 Commits

Author SHA1 Message Date
Hermes Agent 4590dc0fb9 Add 5 subcommands: normalize, silence-stats, threshold-tune, denoise, batch
Sermon-clean v0.2.0. Five new subcommands that round out the editor:

- normalize (norm): Apply EBU R128 two-pass loudness normalization.
  Default -16 LUFS (podcast/YouTube). Configurable target LUFS, true
  peak, and loudness range. Output reports measured input loudness
  and applied gain offset.

- silence-stats (ss): Quantitative summary of silence distribution —
  count, total/mean/median/longest silence, silence fraction, and
  silence runs per minute. Outputs JSON via --json. Useful for
  comparing recordings and picking the right threshold.

- threshold-tune (tt): Auto-pick the silence threshold for the audio.
  Scans a set of candidate thresholds (default -25..-50), scores each
  against the target silence-runs-per-minute (default 4.0), picks the
  closest match. Shows the full scoring table.

- denoise: Apply ffmpeg's afftdn filter for light FFT-based noise
  reduction. Configurable noise reduction dB (default 12) and noise
  floor dB (default -50). Output at 48kHz to match normalize.

- batch: Run any of the subcommands across many files via glob.
  Output goes to --output-dir with --suffix (default '-fixed') and
  optional --extension override. Failures are collected, not raised
  — one bad file doesn't kill the whole batch.

Implementation:
- sermon_clean/processing.py: normalize_loudness + SilenceStats
  dataclass + silence_stats + threshold_tune.
- sermon_clean/denoise.py: DenoiseResult + denoise.
- sermon_clean/batch.py: run_batch + _expand_globs + _make_output_path.
- sermon_clean/cli.py: 5 new cmd_* functions + 5 subparser registrations.

Tests:
- tests/test_processing.py (7 tests): silence-stats on silent vs loud,
  threshold-tune picks closest, normalize produces output + measures loud.
- tests/test_denoise_batch.py (11 tests): denoise roundtrip, batch
  helpers (glob expansion, output naming), batch run with normalize
  + denoise, unknown subcommand raises, one-bad-file-in-batch continues.

Total: 82/82 tests passing in 48s (was 64/64). Bumped version to 0.2.0.

README updated: step-by-step workflow adds 1d-1g; subcommand table
adds the 5 new commands; new 'Batch processing' section.
2026-07-27 13:31:18 -07:00
Hermes Agent e5420589f9 Add silence-index (si) subcommand + tests + README
The uncommitted code from the last session was a working silence-index
subcommand wired through cli.py — but it never landed on main. This
commit:

- Adds render_silence_index() to waveform.py (was already on disk but
  uncommitted) — tabular view of silence runs with start/end/duration
  and a position bar showing where each run falls in the audio.
- Wires it through cli.py as 'silence-index' (alias: 'si') with
  --silence-threshold and --silence-min-duration args.
- Adds 2 tests: test_render_silence_index_empty_audio (silent file
  produces 1 run with bar) and test_render_silence_index_no_silences_message
  (loud sine at -100dB threshold → 'no silence runs' message).
- Updates README: 'si' added to step-by-step workflow and the
  subcommand table, alongside the previously-uncommitted 'mb' (multiband).

64/64 tests passing in 14.6s.

Use case: when picking natural splice points to bracket a bad word,
you want a tabular list of silence runs you can eyeball, not a
waveform. si is the right tool for that — also faster than mb on long
files since it doesn't need to render bars per band.
2026-07-27 12:55:16 -07:00
sami7777 fa0628f0e2 Add slices + speech_regions modules
- slices.py: extract overlapping audio chunks for manual review (filename
  embeds start/end timestamps for easy reference)
- speech_regions.py: find/extract only the speech regions (silence stripping),
  useful as a faster-whisper pre-processing step
- waveform.py: fix silencedetect verbosity (info, not error) + regex parser
  to handle '[silencedetect @ 0x...] silence_start: 0' prefix
- cli.py: new 'slices' subcommand
- tests: 12 new tests (slices, speech_regions, regex); 61 total all passing
- README: updated with subcommand table + step-by-step workflow
2026-07-27 04:00:45 -07:00
sami7777 0cd16e6dc2 Initial commit 2026-07-27 09:38:31 +00:00