Spaces:
Build error
Build error
File size: 1,016 Bytes
803b1a4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import whisper
import os
def download_and_save_whisper_model(model_name="tiny", save_directory="./whisper_models"):
"""
Download a Whisper model and save it locally.
:param model_name: Name of the Whisper model to download (default is "tiny")
:param save_directory: Directory to save the model (default is "./whisper_models")
:return: Path to the saved model
"""
# Ensure the save directory exists
os.makedirs(save_directory, exist_ok=True)
# Load the model (this will download it if not already present)
model = whisper.load_model(model_name)
# Get the path where the model is saved
model_path = os.path.join(save_directory, f"whisper-{model_name}.pt")
# Save the model
whisper.save_model(model, model_path)
print(f"Model saved to: {model_path}")
return model_path
# Example usage
if __name__ == "__main__":
model_path = download_and_save_whisper_model("tiny")
print(f"You can now load the model from: {model_path}") |