Spaces:
Sleeping
Sleeping
Update asr_tool.py
Browse files1234561 unmodified line89101112131415101617181911 unmodified lines31323334from faster_whisper import WhisperModelimport osimport torch # Lägg till import av torch för att kontrollera GPU
# Globalt model för att undvika återladdningmodel = None1 unmodified linedef get_model(): global model if model is None: # Kontrollera om GPU är tillgänglig och använd den device = "cuda" if torch.cuda.is_available() else "cpu" # Använd float16 för att dra nytta av GPU:n, int8_float16 är också ett alternativ compute_type = "float16" if device == "cuda" else "int8" print(f"Laddar Whisper-modell på {device} med compute_type={compute_type}") model = WhisperModel("base", device="cpu", compute_type="int8") model = WhisperModel("base", device=device, compute_type=compute_type) return model
def transcribe_audio(audio_path: str) -> str:11 unmodified lines except Exception as e: return f"Error transcribing audio: {str(e)}"
asr_tool.py+8-1