Skip to content

Commit

Permalink
move hugging face env var to module where it is used
Browse files Browse the repository at this point in the history
  • Loading branch information
jblom committed Oct 1, 2024
1 parent da939ee commit 0281720
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 0 additions & 2 deletions asr.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
s3_endpoint_url,
s3_bucket,
s3_folder_in_bucket,
model_base_dir,
w_word_timestamps,
w_device,
w_model,
Expand All @@ -24,7 +23,6 @@
from daan_transcript import generate_daan_transcript, DAAN_JSON_FILE

logger = logging.getLogger(__name__)
os.environ["HF_HOME"] = model_base_dir # change dir where model is downloaded


def _get_project_meta():
Expand Down
7 changes: 7 additions & 0 deletions whisper_api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import os
from typing import Optional
from uuid import uuid4
from fastapi import BackgroundTasks, FastAPI, HTTPException, status, Response
Expand All @@ -17,8 +18,14 @@
api = FastAPI()

logger.info(f"Loading model on device {w_device}")


# change hugging face home dir where model is downloaded
os.environ["HF_HOME"] = model_base_dir

# checking if model needs to be downloaded from HF or not
model_location = model_base_dir if check_model_availability() else w_model

model = faster_whisper.WhisperModel(
model_location,
device=w_device,
Expand Down

0 comments on commit 0281720

Please sign in to comment.