forked from open-webui/open-webui
Merge pull request #725 from jnkstr/no-internet-whisper
fix: no internet connection for whisper if you use docker
This commit is contained in:
commit
1def55cf09
3 changed files with 13 additions and 5 deletions
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
from fastapi import (
|
||||
FastAPI,
|
||||
Request,
|
||||
|
@ -20,7 +21,7 @@ from utils.utils import (
|
|||
)
|
||||
from utils.misc import calculate_sha256
|
||||
|
||||
from config import CACHE_DIR, UPLOAD_DIR, WHISPER_MODEL_NAME
|
||||
from config import CACHE_DIR, UPLOAD_DIR, WHISPER_MODEL, WHISPER_MODEL_DIR
|
||||
|
||||
app = FastAPI()
|
||||
app.add_middleware(
|
||||
|
@ -53,12 +54,11 @@ def transcribe(
|
|||
f.write(contents)
|
||||
f.close()
|
||||
|
||||
model_name = WHISPER_MODEL_NAME
|
||||
model = WhisperModel(
|
||||
model_name,
|
||||
WHISPER_MODEL,
|
||||
device="cpu",
|
||||
compute_type="int8",
|
||||
download_root=f"{CACHE_DIR}/whisper/models",
|
||||
download_root=WHISPER_MODEL_DIR,
|
||||
)
|
||||
|
||||
segments, info = model.transcribe(file_path, beam_size=5)
|
||||
|
|
|
@ -139,4 +139,6 @@ CHUNK_OVERLAP = 100
|
|||
####################################
|
||||
# Transcribe
|
||||
####################################
|
||||
WHISPER_MODEL_NAME = "base"
|
||||
|
||||
WHISPER_MODEL = os.getenv("WHISPER_MODEL", "base")
|
||||
WHISPER_MODEL_DIR = os.getenv("WHISPER_MODEL_DIR", f"{CACHE_DIR}/whisper/models")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue