metricsubs-segmenter / ass_extract.py
metricv's picture
New segmenter data
dd26679
import ass
import os
import sys
SUB_NAME = sys.argv[1]
sub_basename = os.path.basename(SUB_NAME)
en_name = os.path.splitext(sub_basename)[0] + ".txt"
with open(SUB_NAME, "r", encoding='utf-8-sig') as f:
doc = ass.parse(f)
en_file = open(en_name, "w")
for e in doc.events:
if isinstance(e, ass.line.Dialogue) and (e.style == '英' or e.style == '英 - Tipped'):
en_file.write(e.text.strip())
en_file.write("\n")
en_file.close()