From 4de997d674458de51bb84f2d45cb5f5059bcc344 Mon Sep 17 00:00:00 2001 From: haden Date: Mon, 6 Nov 2023 14:00:40 -0800 Subject: [PATCH] Improve --model argument handling and help message --- whisper/transcribe.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/whisper/transcribe.py b/whisper/transcribe.py index e80bede..68b4a3d 100644 --- a/whisper/transcribe.py +++ b/whisper/transcribe.py @@ -387,14 +387,14 @@ def cli(): def valid_model_name(name): if name in available_models() or os.path.exists(name): return name - raise ValueError( + raise argparse.ArgumentTypeError( f"model should be one of {available_models()} or path to a model checkpoint" ) # fmt: off parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("audio", nargs="+", type=str, help="audio file(s) to transcribe") - parser.add_argument("--model", default="small", type=valid_model_name, help="name of the Whisper model to use") + parser.add_argument("--model", default="small", type=valid_model_name, help=f"name of the Whisper model to use. Available models are: {', '.join(available_models())}. You can also specify a path to a model checkpoint.") parser.add_argument("--model_dir", type=str, default=None, help="the path to save model files; uses ~/.cache/whisper by default") parser.add_argument("--device", default="cuda" if torch.cuda.is_available() else "cpu", help="device to use for PyTorch inference") parser.add_argument("--output_dir", "-o", type=str, default=".", help="directory to save the outputs")