espnet2.asr.encoder.hubert_encoder.download_hubert
Less than 1 minute
espnet2.asr.encoder.hubert_encoder.download_hubert
espnet2.asr.encoder.hubert_encoder.download_hubert(model_url, dir_path)
Download the HuBERT model from a given URL and save it to a specified directory.
This function checks if the model already exists in the specified directory. If it does not exist, it downloads the model from the provided URL and saves it to the specified path, ensuring that the directory structure is created if necessary.
- Parameters:
- model_url (str) – The URL from which to download the HuBERT model.
- dir_path (str) – The directory where the model should be saved.
- Returns: The path to the downloaded model file.
- Return type: str
- Raises:
- Exception – If the download fails or if the specified directory cannot be
- created. –
Examples
>>> model_path = download_hubert(
... "https://example.com/hubert_model.pt",
... "./models/hubert"
... )
>>> print(model_path)
./models/hubert/hubert_model.pt
NOTE
The function uses a file lock to prevent concurrent downloads of the same model.