in projects/speech2srt/speech2srt.py [0:0]
def break_sentences(args, subs, alternative):
firstword = True
charcount = 0
idx = len(subs) + 1
content = ""
start = 0
for w in alternative.words:
if firstword:
# first word in sentence, record start time
start = w.start_time
charcount += len(w.word)
content += " " + w.word.strip()
if ("." in w.word or "!" in w.word or "?" in w.word or
charcount > args.max_chars or
("," in w.word and not firstword)):
# break sentence at: . ! ? or line length exceeded
# also break if , and not first word
subs.append(srt.Subtitle(index=idx,
start=start,
end=w.end_time,
content=srt.make_legal_content(content)))
firstword = True
idx += 1
content = ""
charcount = 0
else:
firstword = False
return subs