Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +8 -3
src/streamlit_app.py
CHANGED
@@ -1,6 +1,12 @@
|
|
1 |
import os
|
2 |
-
|
|
|
|
|
|
|
|
|
3 |
|
|
|
|
|
4 |
|
5 |
import streamlit as st
|
6 |
import tempfile
|
@@ -13,12 +19,11 @@ from speechbrain.pretrained.interfaces import foreign_class
|
|
13 |
@st.cache_resource
|
14 |
def load_model():
|
15 |
try:
|
16 |
-
os.environ["SPEECHBRAIN_CACHE"] = "/data/speechbrain"
|
17 |
return foreign_class(
|
18 |
source="Jzuluaga/accent-id-commonaccent_xlsr-en-english",
|
19 |
pymodule_file="custom_interface.py",
|
20 |
classname="CustomEncoderWav2vec2Classifier",
|
21 |
-
savedir=
|
22 |
)
|
23 |
except Exception as e:
|
24 |
st.error(f"❌ Model failed to load: {e}")
|
|
|
1 |
import os
|
2 |
+
import streamlit as st
|
3 |
+
|
4 |
+
# Set app root dynamically
|
5 |
+
APP_ROOT = os.path.dirname(os.path.abspath(__file__))
|
6 |
+
MODEL_CACHE_DIR = os.path.join(APP_ROOT, "model_cache")
|
7 |
|
8 |
+
# Set SpeechBrain cache path
|
9 |
+
os.environ["SPEECHBRAIN_CACHE"] = MODEL_CACHE_DIR
|
10 |
|
11 |
import streamlit as st
|
12 |
import tempfile
|
|
|
19 |
@st.cache_resource
|
20 |
def load_model():
|
21 |
try:
|
|
|
22 |
return foreign_class(
|
23 |
source="Jzuluaga/accent-id-commonaccent_xlsr-en-english",
|
24 |
pymodule_file="custom_interface.py",
|
25 |
classname="CustomEncoderWav2vec2Classifier",
|
26 |
+
savedir=MODEL_CACHE_DIR
|
27 |
)
|
28 |
except Exception as e:
|
29 |
st.error(f"❌ Model failed to load: {e}")
|