Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,6 +17,8 @@ import traceback
|
|
| 17 |
from streamlit_webrtc import webrtc_streamer, WebRtcMode
|
| 18 |
from twilio.rest import Client
|
| 19 |
import logging
|
|
|
|
|
|
|
| 20 |
|
| 21 |
|
| 22 |
# ✅ MUST be the first Streamlit command
|
|
@@ -805,6 +807,8 @@ def get_ice_servers():
|
|
| 805 |
|
| 806 |
return token.ice_servers
|
| 807 |
|
|
|
|
|
|
|
| 808 |
# === Main QA Interface ===
|
| 809 |
if st.session_state["generated_questions"]:
|
| 810 |
idx = st.session_state["current_question_index"]
|
|
@@ -881,9 +885,21 @@ if st.session_state["generated_questions"]:
|
|
| 881 |
st.audio(wav_path, format="audio/wav")
|
| 882 |
|
| 883 |
if st.button("⏹️ Confirm & Next"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 884 |
st.session_state["answers"].append({
|
| 885 |
"question": question,
|
| 886 |
-
"response_file": st.session_state["response_file"]
|
|
|
|
| 887 |
})
|
| 888 |
|
| 889 |
if st.session_state["current_question_index"] == len(st.session_state["generated_questions"]):
|
|
|
|
| 17 |
from streamlit_webrtc import webrtc_streamer, WebRtcMode
|
| 18 |
from twilio.rest import Client
|
| 19 |
import logging
|
| 20 |
+
import whisper
|
| 21 |
+
model = whisper.load_model("base")
|
| 22 |
|
| 23 |
|
| 24 |
# ✅ MUST be the first Streamlit command
|
|
|
|
| 807 |
|
| 808 |
return token.ice_servers
|
| 809 |
|
| 810 |
+
|
| 811 |
+
|
| 812 |
# === Main QA Interface ===
|
| 813 |
if st.session_state["generated_questions"]:
|
| 814 |
idx = st.session_state["current_question_index"]
|
|
|
|
| 885 |
st.audio(wav_path, format="audio/wav")
|
| 886 |
|
| 887 |
if st.button("⏹️ Confirm & Next"):
|
| 888 |
+
try:
|
| 889 |
+
with st.spinner("🧠 Transcribing your answer..."):
|
| 890 |
+
result = model.transcribe(st.session_state["response_file"])
|
| 891 |
+
transcript = result["text"].strip()
|
| 892 |
+
if not transcript:
|
| 893 |
+
transcript = "[Transcription failed or empty]"
|
| 894 |
+
|
| 895 |
+
except Exception as e:
|
| 896 |
+
st.error(f"❌ Transcription error: {e}")
|
| 897 |
+
transcript = "[Transcription error]"
|
| 898 |
+
|
| 899 |
st.session_state["answers"].append({
|
| 900 |
"question": question,
|
| 901 |
+
"response_file": st.session_state["response_file"],
|
| 902 |
+
"response_text": transcript
|
| 903 |
})
|
| 904 |
|
| 905 |
if st.session_state["current_question_index"] == len(st.session_state["generated_questions"]):
|