{"record":{"id":"90d75744d3695dea","repo":"openai/whisper","slug":"model-should-be-one-of-available-models-or-pat","errorCode":null,"errorMessage":"model should be one of {available_models()} or path to a model checkpoint","messagePattern":"model should be one of (.+?) or path to a model checkpoint","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"whisper/transcribe.py","lineNumber":523,"sourceCode":"                prompt_reset_since = len(all_tokens)\n\n            # update progress bar\n            pbar.update(min(content_frames, seek) - previous_seek)\n\n    return dict(\n        text=tokenizer.decode(all_tokens[len(initial_prompt_tokens) :]),\n        segments=all_segments,\n        language=language,\n    )\n\n\ndef cli():\n    from . import available_models\n\n    def valid_model_name(name):\n        if name in available_models() or os.path.exists(name):\n            return name\n        raise ValueError(\n            f\"model should be one of {available_models()} or path to a model checkpoint\"\n        )\n\n    # fmt: off\n    parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)\n    parser.add_argument(\"audio\", nargs=\"+\", type=str, help=\"audio file(s) to transcribe\")\n    parser.add_argument(\"--model\", default=\"turbo\", type=valid_model_name, help=\"name of the Whisper model to use\")\n    parser.add_argument(\"--model_dir\", type=str, default=None, help=\"the path to save model files; uses ~/.cache/whisper by default\")\n    parser.add_argument(\"--device\", default=\"cuda\" if torch.cuda.is_available() else \"cpu\", help=\"device to use for PyTorch inference\")\n    parser.add_argument(\"--output_dir\", \"-o\", type=str, default=\".\", help=\"directory to save the outputs\")\n    parser.add_argument(\"--output_format\", \"-f\", type=str, default=\"all\", choices=[\"txt\", \"vtt\", \"srt\", \"tsv\", \"json\", \"jsonl\", \"all\"], help=\"format of the output file; if not specified, all available formats will be produced\")\n    parser.add_argument(\"--verbose\", type=str2bool, default=True, help=\"whether to print out the progress and debug messages\")\n\n    parser.add_argument(\"--task\", type=str, default=\"transcribe\", choices=[\"transcribe\", \"translate\"], help=\"whether to perform X->X speech recognition ('transcribe') or X->English translation ('translate')\")\n    parser.add_argument(\"--language\", type=str, default=None, choices=sorted(LANGUAGES.keys()) + sorted([k.title() for k in TO_LANGUAGE_CODE.keys()]), help=\"language spoken in the audio, specify None to perform language detection\")\n\n    parser.add_argument(\"--temperature\", type=float, default=0, help=\"temperature to use for sampling\")\n    parser.add_argument(\"--best_of\", type=optional_int, default=5, help=\"number of candidates when sampling with non-zero temperature\")","sourceCodeStart":505,"sourceCodeEnd":541,"githubUrl":"https://github.com/openai/whisper/blob/5f86d1d86363843179951550570367b37c5d6f78/whisper/transcribe.py#L505-L541","documentation":"The whisper CLI registers --model with type=valid_model_name, an argparse type callable that accepts the value only if it is in whisper.available_models() or an existing filesystem path (os.path.exists, note: not isfile). argparse wraps the ValueError into 'invalid valid_model_name value' and exits before any transcription.","triggerScenarios":"whisper audio.mp3 --model large (older name no longer in _MODELS) or --model ./models/finetuned.pt when the path does not exist from the current directory; any typo triggers it at argument-parsing time.","commonSituations":"Scripts written against older/newer whisper versions where the model list changed (e.g. 'large-v3-turbo' vs 'turbo'); relative checkpoint paths run from a different CWD (cron, systemd services); CI invoking the CLI with a model path that was never downloaded into the image.","solutions":["List valid names: python -m whisper --help or python -c \"import whisper; print(whisper.available_models())\"","Use an absolute path for local checkpoints: --model $PWD/models/finetuned.pt","Fix the typo (dot for .en variants: base.en) and re-run"],"exampleFix":"# before\nwhisper audio.mp3 --model medium-en  # argparse error: invalid valid_model_name value\n\n# after\nwhisper audio.mp3 --model medium.en\n# or a real checkpoint path:\nwhisper audio.mp3 --model /abs/path/finetuned.pt","handlingStrategy":"validation","validationCode":"import os, whisper\n\ndef valid_cli_model(name: str) -> str:\n    if name in whisper.available_models() or os.path.exists(os.path.abspath(name)):\n        return name\n    raise ValueError(f\"model must be one of {whisper.available_models()} or an existing path\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In scripts, resolve checkpoint paths to absolute before passing --model","Print whisper.available_models() in deployment logs after upgrade to catch registry drift"],"tags":["cli","argparse","model-loading","configuration"],"backgroundTag":null,"analyzedSha":"5f86d1d86363843179951550570367b37c5d6f78","analyzedAt":"2026-08-14T18:53:59.547Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}