Create model/download_model.py
Browse files- model/download_model.py +23 -0
model/download_model.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import subprocess
|
| 3 |
+
|
| 4 |
+
MODEL_PATH = "model"
|
| 5 |
+
MODEL_URL = "https://huggingface.co/vosk-models/vosk-small-en-us/resolve/main"
|
| 6 |
+
|
| 7 |
+
# Danh s谩ch file c岷 t岷
|
| 8 |
+
files = ["am", "conf", "graph", "ivector", "rescore"]
|
| 9 |
+
|
| 10 |
+
if not os.path.exists(MODEL_PATH):
|
| 11 |
+
os.makedirs(MODEL_PATH)
|
| 12 |
+
|
| 13 |
+
for file in files:
|
| 14 |
+
file_url = f"{MODEL_URL}/{file}.zip"
|
| 15 |
+
file_path = os.path.join(MODEL_PATH, f"{file}.zip")
|
| 16 |
+
|
| 17 |
+
if not os.path.exists(file_path):
|
| 18 |
+
print(f"膼ang t岷 {file_url} ...")
|
| 19 |
+
subprocess.run(["wget", "-O", file_path, file_url])
|
| 20 |
+
subprocess.run(["unzip", "-o", file_path, "-d", MODEL_PATH])
|
| 21 |
+
os.remove(file_path)
|
| 22 |
+
|
| 23 |
+
print("T岷 model th脿nh c么ng!")
|