import json import subprocess import os from pathlib import Path class ASR: def __init__(self, hive_home): self.hive_home = Path(hive_home) self.model_path = self.hive_home / "models" / "vosk" self.ensure_model() def ensure_model(self): if not self.model_path.exists(): print("Downloading Vosk model...") os.makedirs(self.model_path.parent, exist_ok=True) subprocess.run([ "wget", "-q", "-O", "-", "https://alphacephei.com/vosk/models/vosk-model-small-en-us-0.15.zip" ], check=True, stdout=subprocess.PIPE) subprocess.run([ "unzip", "-q", "-", "-d", str(self.model_path.parent) ], input=subprocess.Popen([ "wget", "-q", "-O", "-", "https://alphacephei.com/vosk/models/vosk-model-small-en-us-0.15.zip" ], stdout=subprocess.PIPE).stdout) def transcribe(self, audio_path): try: # Simple mock transcription for now # In production, integrate Vosk properly return "Transcribed text from audio" except: return "Could not transcribe audio"