Wrap transcription attempt in a try/except

If the audio file is empty or has no discernable human voices, the
transcription may fail with an exception.  Record that when it happens
and move continue to the next file, rather than failing.
This commit is contained in:
Elf M. Sternberg 2022-11-08 10:58:41 -08:00
parent 34a0b1b639
commit 674819baeb
1 changed files with 16 additions and 4 deletions

20
tcd.py
View File

@ -188,11 +188,23 @@ def main():
print("NOTICE: No new entries found to transcribe.")
sys.exit(0)
eprint("Transcribing: {}".format(", ".join(files_to_transcribe)))
eprint(
"Transcribing {} files: {}".format(
str(len(files_to_transcribe)), ", ".join(files_to_transcribe)
)
)
for index, f in enumerate(files_to_transcribe):
transcribe_with_timestamp(os.path.join(tcd_path, f))
if index != len(files):
print("\n\n")
eprint(
"Transcribing file {}: {} ({})".format(
index + 1, f, converttcdfilename(f)
)
)
try:
transcribe_with_timestamp(os.path.join(tcd_path, f))
if index != len(files):
print("\n\n")
except:
eprint("Transcription failed!")
writelast(files_to_transcribe[-1])
sys.exit(0)