forked from sul-dlss/whisper-pilot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·48 lines (39 loc) · 1.41 KB
/
run
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3
import argparse
import datetime
import logging
import os
import sys
from transcribe import whisper
parser = argparse.ArgumentParser(
prog="run", description="Run transcription generation for sample data"
)
parser.add_argument("--output-dir", help="Path to a directory to write results")
parser.add_argument("--manifest", default="uhec-data.csv", help="Path to data manifest CSV")
parser.add_argument("--threads", help="'--threads' parameter to pass to whisper.cpp")
parser.add_argument("--verbose", help="Print transcript lines as they are generated", action="store_true")
parser.add_argument(
"--only",
choices=["whisper", "preprocessing"],
help="Only run one transcription type",
)
args = parser.parse_args()
# determine where to write results
output_dir = args.output_dir
if output_dir is None:
output_dir = datetime.date.today().strftime("output-%Y-%m-%d")
if not os.path.isdir(output_dir):
os.makedirs(output_dir)
# ensure manifest CSV exists
if not os.path.isfile(args.manifest):
sys.exit(f"manifest file {args.manifest} doesn't exist")
logging.basicConfig(
filename=os.path.join(output_dir, "transcribe.log"),
filemode="a",
format="%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s",
datefmt="%H:%M:%S",
level=logging.INFO,
)
whisper.run(output_dir, args.manifest, args.threads, args.verbose)
print()
whisper.run_preprocessing(output_dir, args.manifest)