no internet connection for whisper if you use docker

This commit is contained in:
Jannik Streidl 2024-02-13 15:11:53 +01:00
parent a8a0ebf3aa
commit 8ab0338e71
2 changed files with 11 additions and 2 deletions

View file

@ -1,3 +1,4 @@
import os
from fastapi import (
FastAPI,
Request,
@ -53,12 +54,14 @@ def transcribe(
f.write(contents)
f.close()
model_name = WHISPER_MODEL_NAME
model_name = os.getenv('WHISPER_MODEL', WHISPER_MODEL_NAME)
download_root = os.getenv('WHISPER_DIR', f"{CACHE_DIR}/whisper/models")
model = WhisperModel(
model_name,
device="cpu",
compute_type="int8",
download_root=f"{CACHE_DIR}/whisper/models",
download_root=download_root,
)
segments, info = model.transcribe(file_path, beam_size=5)