|
@@ -3,6 +3,7 @@ import ffmpeg
|
|
import asyncio
|
|
import asyncio
|
|
import subprocess
|
|
import subprocess
|
|
import os
|
|
import os
|
|
|
|
+import shutil
|
|
|
|
|
|
SAMPLE_RATE = 16000
|
|
SAMPLE_RATE = 16000
|
|
|
|
|
|
@@ -43,9 +44,12 @@ class ASR():
|
|
self.lock = asyncio.Lock()
|
|
self.lock = asyncio.Lock()
|
|
|
|
|
|
def load_model(self):
|
|
def load_model(self):
|
|
- if not os.path.exists(self.model_path):
|
|
|
|
- print("Downloading model...")
|
|
|
|
- subprocess.run(["wget", self.model_url, "-O", self.model_path], check=True)
|
|
|
|
|
|
+ if not os.path.exists(self.model_path) or os.path.getsize(self.model_path) == 0:
|
|
|
|
+ print("Fetching model...")
|
|
|
|
+ if os.path.exists(f"ggml-model-whisper-{self.model}.bin"):
|
|
|
|
+ shutil.copy(f"ggml-model-whisper-{self.model}.bin", self.model_path)
|
|
|
|
+ else:
|
|
|
|
+ subprocess.run(["wget", self.model_url, "-O", self.model_path], check=True)
|
|
print("Done.")
|
|
print("Done.")
|
|
|
|
|
|
async def transcribe(self, audio: bytes) -> str:
|
|
async def transcribe(self, audio: bytes) -> str:
|