- add align_text_to_audio(): forced alignment without ASR, fast - add _StableTSModels cache; detect language via stable-ts when language=None - LRC stage: use existing text.txt, copy it if already LRC, fall back to ASR only - filter junk lyrics from tags and ASR hallucinations (promo phrases, tics) - mark empty ASR results with metadata.empty_text and skip them on resume - warn in GUI when LRC is run with transcription disabled - add mark_no_speech.py one-shot script for existing tracks
40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Mark tracks with metadata.empty_text=true if their text is missing or hallucinated."""
|
|
import json, sys
|
|
from pathlib import Path
|
|
|
|
HALLUCINATION = (
|
|
"продолжение следует", "субтитры сделан", "субтитры создава",
|
|
"created with", "russian-area.de", "музыка музыка",
|
|
)
|
|
|
|
|
|
def main(root: Path) -> int:
|
|
count = 0
|
|
for meta in root.rglob("metadata.json"):
|
|
track = meta.parent
|
|
txt = track / "text.txt"
|
|
if txt.is_file():
|
|
body = txt.read_text(encoding="utf-8", errors="ignore").strip().lower()
|
|
# If the text is real (not hallucination) and not empty, skip marking.
|
|
if body and not any(h in body for h in HALLUCINATION):
|
|
continue
|
|
# Remove the text.txt so the next run will re-process it.
|
|
txt.unlink()
|
|
# Set empty_text=True in metadata.
|
|
try:
|
|
data = json.loads(meta.read_text(encoding="utf-8"))
|
|
except (OSError, ValueError):
|
|
data = {}
|
|
data["empty_text"] = True
|
|
meta.write_text(
|
|
json.dumps(data, indent=2, ensure_ascii=False), encoding="utf-8",
|
|
)
|
|
print(f"marked: {track}")
|
|
count += 1
|
|
print(f"\nmarked {count} tracks")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main(Path(sys.argv[1] if len(sys.argv) > 1 else "."))) |