Skip to content

Commit

Permalink
handling transcribe exceptions. (#1682)
Browse files Browse the repository at this point in the history
* handling transcribe() exceptions.

* printing stacktrace

---------

Co-authored-by: invalid <invalid@email.com>
Co-authored-by: Jong Wook Kim <jongwook@nyu.edu>
Co-authored-by: Jong Wook Kim <jongwook@openai.com>
  • Loading branch information
4 people authored Nov 6, 2023
1 parent 6ed314f commit b7d277a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions whisper/transcribe.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import os
import traceback
import warnings
from typing import TYPE_CHECKING, Optional, Tuple, Union

Expand Down Expand Up @@ -468,8 +469,12 @@ def valid_model_name(name):
warnings.warn("--max_words_per_line has no effect with --max_line_width")
writer_args = {arg: args.pop(arg) for arg in word_options}
for audio_path in args.pop("audio"):
result = transcribe(model, audio_path, temperature=temperature, **args)
writer(result, audio_path, **writer_args)
try:
result = transcribe(model, audio_path, temperature=temperature, **args)
writer(result, audio_path, **writer_args)
except Exception as e:
traceback.print_exc()
print(f"Skipping {audio_path} due to {type(e).__name__}: {str(e)}")


if __name__ == "__main__":
Expand Down

0 comments on commit b7d277a

Please sign in to comment.