Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -24,11 +24,8 @@ st.title("English Accent Audio Detector")
|
|
24 |
# Initialize session state
|
25 |
initialize_session_state()
|
26 |
|
27 |
-
# Load models once
|
28 |
-
if '
|
29 |
-
with st.spinner("Loading SpeechBrain model..."):
|
30 |
-
st.session_state.classifier = load_accent_model()
|
31 |
-
if 'whisper' not in st.session_state:
|
32 |
with st.spinner("Loading Whisper model..."):
|
33 |
st.session_state.whisper = load_whisper()
|
34 |
|
@@ -92,6 +89,10 @@ if st.session_state.audio_path and not st.session_state.transcription:
|
|
92 |
st.markdown(" Transcript Preview")
|
93 |
st.markdown(st.session_state.transcription)
|
94 |
st.success("Audio extracted and ready for analysis!")
|
|
|
|
|
|
|
|
|
95 |
mem = psutil.virtual_memory()
|
96 |
st.write(f"Memory used: {mem.percent}%")
|
97 |
|
@@ -112,7 +113,7 @@ if st.session_state.transcription:
|
|
112 |
|
113 |
else:
|
114 |
st.warning("Could not determine accent.")
|
115 |
-
|
116 |
except Exception as e:
|
117 |
st.error("Failed to analyze accent.")
|
118 |
st.code(str(e))
|
|
|
24 |
# Initialize session state
|
25 |
initialize_session_state()
|
26 |
|
27 |
+
# Load models once when there is no transcription
|
28 |
+
if 'whisper' not in st.session_state and not session_state.trascription:
|
|
|
|
|
|
|
29 |
with st.spinner("Loading Whisper model..."):
|
30 |
st.session_state.whisper = load_whisper()
|
31 |
|
|
|
89 |
st.markdown(" Transcript Preview")
|
90 |
st.markdown(st.session_state.transcription)
|
91 |
st.success("Audio extracted and ready for analysis!")
|
92 |
+
unload_model(st.session_state.whisper)
|
93 |
+
|
94 |
+
if 'classifier' not in st.session_state:
|
95 |
+
st.session_state.classifier = load_accent_model()
|
96 |
mem = psutil.virtual_memory()
|
97 |
st.write(f"Memory used: {mem.percent}%")
|
98 |
|
|
|
113 |
|
114 |
else:
|
115 |
st.warning("Could not determine accent.")
|
116 |
+
unload_model(st.session_state.classifier)
|
117 |
except Exception as e:
|
118 |
st.error("Failed to analyze accent.")
|
119 |
st.code(str(e))
|