Kartikeyssj2 commited on
Commit
803b1a4
·
verified ·
1 Parent(s): 2141879

Update download_models.py

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