Spaces:
Sleeping
Sleeping
fixing cache
Browse files- src/detector.py +7 -3
- src/streamlit_app.py +0 -8
src/detector.py
CHANGED
|
@@ -2,14 +2,18 @@ import os
|
|
| 2 |
from huggingface_hub import snapshot_download
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
cache_dir = "
|
| 7 |
os.makedirs(cache_dir, exist_ok=True)
|
| 8 |
os.environ["TRANSFORMERS_CACHE"] = cache_dir
|
| 9 |
|
| 10 |
-
#
|
| 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 |
|
|
|
|
| 2 |
from huggingface_hub import snapshot_download
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
+
# Use /tmp which is always writable in Hugging Face Spaces
|
| 6 |
+
cache_dir = "/tmp/hf_cache"
|
| 7 |
os.makedirs(cache_dir, exist_ok=True)
|
| 8 |
os.environ["TRANSFORMERS_CACHE"] = cache_dir
|
| 9 |
|
| 10 |
+
# Download model to the writable tmp directory
|
| 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 |
+
|
| 17 |
# Load the pipeline from the local path
|
| 18 |
asr = pipeline("automatic-speech-recognition", model=model_path)
|
| 19 |
|
src/streamlit_app.py
CHANGED
|
@@ -4,14 +4,6 @@ from downloader import download_video
|
|
| 4 |
from extractor import extract_audio
|
| 5 |
from detector import detect_accent
|
| 6 |
|
| 7 |
-
# Create the cache directory if it doesn't exist
|
| 8 |
-
cache_dir = "./hf_cache"
|
| 9 |
-
os.makedirs(cache_dir, exist_ok=True)
|
| 10 |
-
|
| 11 |
-
# Set it as the Transformers cache
|
| 12 |
-
os.environ["TRANSFORMERS_CACHE"] = cache_dir
|
| 13 |
-
|
| 14 |
-
|
| 15 |
st.set_page_config(page_title="Accent Detector", page_icon="๐๏ธ")
|
| 16 |
|
| 17 |
st.title("๐๏ธ English Accent Classifier")
|
|
|
|
| 4 |
from extractor import extract_audio
|
| 5 |
from detector import detect_accent
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
st.set_page_config(page_title="Accent Detector", page_icon="๐๏ธ")
|
| 8 |
|
| 9 |
st.title("๐๏ธ English Accent Classifier")
|