New-Approach-for-Speech-Scoring / download_models.py
Kartikeyssj2's picture
Update download_models.py
803b1a4 verified
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}")