Softcatala / whisper-ctranslate2

Whisper command line client compatible with original OpenAI client based on CTranslate2.
MIT License
880 stars 75 forks source link

Path to local model directory should be considered a valid model option #92

Closed lutangar closed 5 months ago

lutangar commented 5 months ago

Considering openai-whisper is the reference implementation, in open-whisper one may provide a path to a model instead of the name of a model.

Here's theload_model implementation :

if name in _MODELS:
    checkpoint_file = _download(_MODELS[name], download_root, in_memory)
    alignment_heads = _ALIGNMENT_HEADS[name]
elif os.path.isfile(name):
    checkpoint_file = open(name, "rb").read() if in_memory else name
    alignment_heads = None
else:
    raise RuntimeError(
        f"Model {name} not found; available models = {available_models()}"
    )

https://github.com/openai/whisper/blob/main/whisper/__init__.py#L132-L141

On the other hand, in whisper-ctranslate2 the same feature is only achievable using yet another option --model_directory.

Which is confusing btw since there is another option named model_dir...

Furthermore, there is a hard constraint on the model filename which must be named model.bin. Anything else would be considered invalid.

see https://github.com/Softcatala/whisper-ctranslate2/blob/main/src/whisper_ctranslate2/whisper_ctranslate2.py#L172

The openai-whisper whisper behavior could be implemented in whisper-ctranslate2 for :

lutangar commented 5 months ago

I wrongly assumed a CTranslate2 model could be a single .bin file as openai-whisper --model option may point to a single .pt file.

Still, I think this issue remains relevant, the --model option could be used to point to either a model name or model directory instead of relying on an extra model_directory option.

jordimas commented 5 months ago

Thanks for your feedback. No plans to change this at this point.