PropmtEditor / edit /analyze.py
Prompt48's picture
Upload edit/analyze.py with huggingface_hub
70266e4 verified
Raw
History Blame Contribute Delete
1.87 kB
import json, sys
d = json.load(open(sys.argv[1], encoding="utf-8"))
words = [w for w in d["words"] if w.get("type") == "word"]
def fmt(t):
m = int(t // 60); s = t - m*60
return f"{m}:{s:05.2f}"
# 1) silence gaps between consecutive words
print("=== SILENCE GAPS >= 0.35s ===")
GAP = 0.35
gaps = []
for i in range(1, len(words)):
g = words[i]["start"] - words[i-1]["end"]
if g >= GAP:
gaps.append((words[i-1]["end"], words[i]["start"], g, words[i-1]["text"], words[i]["text"]))
for end, start, g, prev, nxt in gaps:
print(f" {fmt(end)} -> {fmt(start)} gap={g:4.2f}s ...{prev!r} | {nxt!r}...")
print(f" total gaps >= {GAP}s: {len(gaps)}")
# 2) anchor keywords -> first occurrence timestamp(s)
print("\n=== KEYWORD ANCHORS (all occurrences) ===")
anchors = [
"MTP", "multi-token", "autoregression", "draft", "verify", "verified",
"acceptance", "VRAM", "install", "Studio", "Windows", "beta", "stable",
"update", "04.13", "04.14", "download", "model search", "unsloth",
"speculative", "eject", "tokens per second", "capital", "essay",
"RunPod", "Hostinger", "subscribe", "without MTP", "with MTP",
]
# rebuild a stream of (word, start, end) plus simple lowercased text join for phrase search
seq = [(w["text"].strip(), w["start"], w["end"]) for w in words]
lc = [t.lower() for t,_,_ in seq]
for kw in anchors:
parts = kw.lower().split()
hits = []
for i in range(len(lc)-len(parts)+1):
if lc[i:i+len(parts)] == parts:
hits.append(seq[i][1])
if hits:
print(f" {kw:18s}: " + ", ".join(fmt(h) for h in hits[:8]) + ("" if len(hits)<=8 else f" (+{len(hits)-8} more)"))
# 3) filler / disfluency quick scan
print("\n=== FILLER WORDS (uh/um) ===")
for w in words:
if w["text"].strip().lower().rstrip(",.") in ("uh","um"):
print(f" {fmt(w['start'])} {w['text']!r}")