-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimport_srt
More file actions
executable file
·34 lines (24 loc) · 783 Bytes
/
Copy pathimport_srt
File metadata and controls
executable file
·34 lines (24 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
# take an existing SRT subtitle file and
# convert it into Annotation File format
import argparse
from dropout_srt import dropout_parse_srt
from annotation_file import (
AnnotationFile,
DialogueLine,
Annotation,
PlainAnnotation,
annotation_save,
)
def main():
ap = argparse.ArgumentParser()
ap.add_argument('sub_file', type=argparse.FileType('r'))
ap.add_argument('--annotation-file', '-o', type=argparse.FileType('w'), required=True)
args = ap.parse_args()
af = AnnotationFile()
for line in dropout_parse_srt(args.sub_file.read()):
af.lines.append(DialogueLine([Annotation(PlainAnnotation(line), unfinished=True)]))
af.validate()
args.annotation_file.write(annotation_save(af))
args.annotation_file.write('\n')
main()