speech_data_recordings / check-longer-transcript.py
BaniGuru
Initial commit
911e360
Raw History Blame
1.51 kB
import json
from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent
MAX_DURATION = 20.0
total = 0
files_with_long_sections = 0
for path in sorted(BASE_DIR.rglob("*.json")):
try:
data = json.loads(path.read_text(encoding="utf-8"))
except Exception as e:
print(f"ERROR: {path.relative_to(BASE_DIR)}: {e}")
continue
# ONLY process the "sections" array
if not isinstance(data, dict):
continue
sections = data.get("sections")
if not isinstance(sections, list):
continue
file_count = 0
for section in sections:
if not isinstance(section, dict):
continue
try:
start = float(section["start_time"])
end = float(section["end_time"])
except (KeyError, TypeError, ValueError):
continue
duration = end - start
if duration > MAX_DURATION:
total += 1
file_count += 1
print(f"\n{path.relative_to(BASE_DIR)}")
print(f" section_id: {section.get('section_id', '?')}")
print(f" duration: {duration:.3f}s")
print(f" start: {start}")
print(f" end: {end}")
print(f" transcript: {section.get('transcript', '')}")
if file_count:
files_with_long_sections += 1
print(f"\n{'=' * 60}")
print(f"Files with sections > {MAX_DURATION:g}s: {files_with_long_sections}")
print(f"Sections over {MAX_DURATION:g}s: {total}")