AmirFARES commited on
Commit
abc37f9
·
1 Parent(s): 469219e

fixing cache

Browse files
Files changed (1) hide show
  1. src/detector.py +12 -1
src/detector.py CHANGED
@@ -1,6 +1,17 @@
 
 
1
  from transformers import pipeline
2
 
3
- asr = pipeline("automatic-speech-recognition", model="openai/whisper-base")
 
 
 
 
 
 
 
 
 
4
 
5
  def detect_accent(audio_path: str):
6
  result = asr(audio_path)
 
1
+ import os
2
+ from huggingface_hub import snapshot_download
3
  from transformers import pipeline
4
 
5
+ # Create and set custom cache dir
6
+ cache_dir = "./hf_cache"
7
+ os.makedirs(cache_dir, exist_ok=True)
8
+ os.environ["TRANSFORMERS_CACHE"] = cache_dir
9
+
10
+ # Manually download model to avoid permission/lock errors
11
+ model_path = snapshot_download(repo_id="openai/whisper-base", cache_dir=cache_dir)
12
+
13
+ # Load the pipeline from the local path
14
+ asr = pipeline("automatic-speech-recognition", model=model_path)
15
 
16
  def detect_accent(audio_path: str):
17
  result = asr(audio_path)