silence-detector
Detect the initial “opening” low-energy section (pre-roll/title/setup) from energy data, with correct timestamp alignment when smoothing is enabled.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- silence-detector
- description
- Detect the initial “opening” low-energy section (pre-roll/title/setup) from energy data, with correct timestamp alignment when smoothing is enabled.
02 资源文件 1
- 脚本scripts/detect_silence.py3.2 KB
03 SKILL.md 正文
Steps
- Run the initial silence detector:
python3 /root/.claude/skills/silence-detector/scripts/detect_silence.py \ --energies /root/energies.json \ --output /root/silence_raw.json \ --threshold-multiplier 1.5 \ --initial-window 60 \ --smoothing-window 30 - Correct the timestamp alignment when
smoothing-window > 1:- The script smooths with
np.convolve(..., mode="valid"), sosmoothed[i]summarizesenergies[i : i + smoothing_window]. - Therefore, the first index
iwheresmoothed[i] > thresholdis aligned to the start of that smoothing window, not its center. - Use an adjusted opening boundary for the original per-second timeline:
opening_end = raw_end + (smoothing_window // 2)(center-align; clamp to[0, total_seconds]).
- Rewrite the output to
/root/silence.jsonusing this adjustedopening_endso downstream--start-timeis consistent and you don’t accidentally detect leftover opening as many small pauses. Example adjustment:
python3 - <<'PY' import json INP="/root/silence_raw.json" OUT="/root/silence.json" d=json.load(open(INP)) segs=d.get("segments", []) if not segs: json.dump(d, open(OUT, "w"), indent=2) print("No opening detected; copied through.") raise SystemExit(0) raw_end=int(segs[0]["end"]) w=int(d.get("parameters", {}).get("smoothing_window", 1)) offset = (w // 2) if w > 1 else 0 opening_end = raw_end + offset segs=[{"start": 0, "end": opening_end, "duration": opening_end}] d["segments"]=segs d["total_segments"]=1 if opening_end > 0 else 0 d["total_duration_seconds"]=opening_end if opening_end > 0 else 0 json.dump(d, open(OUT, "w"), indent=2) print(f"Adjusted opening end: {raw_end} -> {opening_end} (offset {offset}s)") PY - The script smooths with
- Parameter tuning (opening too long/short):
- Lower
threshold_multiplierends the opening earlier (removes less). - Higher
threshold_multiplierends the opening later (removes more). - Larger
smoothing_windowis steadier but increases alignment sensitivity; if you change it, keep the alignment adjustment consistent.
- Lower
Expected Result
A silence.json with a single opening segment [0, opening_end) whose end is correctly aligned for use as the pause detector’s --start-time and for later segment merging.
04 同仓库更多 Skills
video-frame-extraction
Extract frames from video files and save them as images using OpenCV
openai-vision
Analyze images and multi-frame sequences using OpenAI GPT vision models
image-ocr
Extract text content from images using Tesseract OCR via Python, including structured field extraction from receipts and forms
video-frame-extraction
Extract frames from video files and save them as images using OpenCV
openai-vision
Analyze images and multi-frame sequences using OpenAI GPT vision models
image-ocr
Extract text content from images using Tesseract OCR via Python, including structured field extraction from receipts and forms