Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,7 +13,7 @@ from io import BytesIO
|
|
| 13 |
import hashlib
|
| 14 |
from audio_recorder_streamlit import audio_recorder
|
| 15 |
from transformers import pipeline
|
| 16 |
-
|
| 17 |
|
| 18 |
|
| 19 |
|
|
@@ -58,7 +58,7 @@ def get_voice_transcription(state_key):
|
|
| 58 |
st.info(f"📝 Transcribed: {transcribed_text}")
|
| 59 |
# Append (or set) new transcription
|
| 60 |
st.session_state[state_key] += (" " + transcribed_text).strip()
|
| 61 |
-
st.
|
| 62 |
except Exception as e:
|
| 63 |
st.error(f"Voice input error: {str(e)}")
|
| 64 |
return st.session_state[state_key]
|
|
@@ -366,7 +366,7 @@ def main():
|
|
| 366 |
{"role": "assistant", "content": first_question}
|
| 367 |
]
|
| 368 |
st.session_state.game_state = "gameplay"
|
| 369 |
-
st.
|
| 370 |
|
| 371 |
# Gameplay screen with progress bar
|
| 372 |
elif st.session_state.game_state == "gameplay":
|
|
@@ -394,7 +394,7 @@ def main():
|
|
| 394 |
if "Final Guess:" in current_question:
|
| 395 |
st.session_state.final_guess = current_question.split("Final Guess:")[1].strip()
|
| 396 |
st.session_state.game_state = "confirm_guess"
|
| 397 |
-
st.
|
| 398 |
with st.form("answer_form"):
|
| 399 |
# --- Voice Input for Answer ---
|
| 400 |
st.markdown("#### Use Voice (English/Urdu) for Your Answer")
|
|
@@ -425,7 +425,7 @@ def main():
|
|
| 425 |
st.session_state.current_q += 1
|
| 426 |
if st.session_state.current_q >= 20:
|
| 427 |
st.session_state.game_state = "result"
|
| 428 |
-
st.
|
| 429 |
with st.expander("Need Help? Chat with AI Assistant"):
|
| 430 |
# --- Voice Input for Help Query ---
|
| 431 |
st.markdown("#### Use Voice (English/Urdu) for Help Query")
|
|
@@ -467,7 +467,7 @@ def main():
|
|
| 467 |
else:
|
| 468 |
if confirm_input == "yes":
|
| 469 |
st.session_state.game_state = "result"
|
| 470 |
-
st.
|
| 471 |
st.stop()
|
| 472 |
else:
|
| 473 |
st.session_state.conversation_history.append(
|
|
@@ -483,7 +483,7 @@ def main():
|
|
| 483 |
{"role": "assistant", "content": next_response}
|
| 484 |
)
|
| 485 |
st.session_state.current_q += 1
|
| 486 |
-
st.
|
| 487 |
|
| 488 |
elif st.session_state.game_state == "result":
|
| 489 |
if not st.session_state.final_guess:
|
|
@@ -506,7 +506,7 @@ def main():
|
|
| 506 |
unsafe_allow_html=True)
|
| 507 |
if st.button("Play Again", key="play_again"):
|
| 508 |
st.session_state.clear()
|
| 509 |
-
st.
|
| 510 |
|
| 511 |
if __name__ == "__main__":
|
| 512 |
main()
|
|
|
|
| 13 |
import hashlib
|
| 14 |
from audio_recorder_streamlit import audio_recorder
|
| 15 |
from transformers import pipeline
|
| 16 |
+
st.experimental_rerun()
|
| 17 |
|
| 18 |
|
| 19 |
|
|
|
|
| 58 |
st.info(f"📝 Transcribed: {transcribed_text}")
|
| 59 |
# Append (or set) new transcription
|
| 60 |
st.session_state[state_key] += (" " + transcribed_text).strip()
|
| 61 |
+
st.rerun()
|
| 62 |
except Exception as e:
|
| 63 |
st.error(f"Voice input error: {str(e)}")
|
| 64 |
return st.session_state[state_key]
|
|
|
|
| 366 |
{"role": "assistant", "content": first_question}
|
| 367 |
]
|
| 368 |
st.session_state.game_state = "gameplay"
|
| 369 |
+
st.rerun()
|
| 370 |
|
| 371 |
# Gameplay screen with progress bar
|
| 372 |
elif st.session_state.game_state == "gameplay":
|
|
|
|
| 394 |
if "Final Guess:" in current_question:
|
| 395 |
st.session_state.final_guess = current_question.split("Final Guess:")[1].strip()
|
| 396 |
st.session_state.game_state = "confirm_guess"
|
| 397 |
+
st.rerun()
|
| 398 |
with st.form("answer_form"):
|
| 399 |
# --- Voice Input for Answer ---
|
| 400 |
st.markdown("#### Use Voice (English/Urdu) for Your Answer")
|
|
|
|
| 425 |
st.session_state.current_q += 1
|
| 426 |
if st.session_state.current_q >= 20:
|
| 427 |
st.session_state.game_state = "result"
|
| 428 |
+
st.rerun()
|
| 429 |
with st.expander("Need Help? Chat with AI Assistant"):
|
| 430 |
# --- Voice Input for Help Query ---
|
| 431 |
st.markdown("#### Use Voice (English/Urdu) for Help Query")
|
|
|
|
| 467 |
else:
|
| 468 |
if confirm_input == "yes":
|
| 469 |
st.session_state.game_state = "result"
|
| 470 |
+
st.rerun()
|
| 471 |
st.stop()
|
| 472 |
else:
|
| 473 |
st.session_state.conversation_history.append(
|
|
|
|
| 483 |
{"role": "assistant", "content": next_response}
|
| 484 |
)
|
| 485 |
st.session_state.current_q += 1
|
| 486 |
+
st.rerun()
|
| 487 |
|
| 488 |
elif st.session_state.game_state == "result":
|
| 489 |
if not st.session_state.final_guess:
|
|
|
|
| 506 |
unsafe_allow_html=True)
|
| 507 |
if st.button("Play Again", key="play_again"):
|
| 508 |
st.session_state.clear()
|
| 509 |
+
st.rerun()
|
| 510 |
|
| 511 |
if __name__ == "__main__":
|
| 512 |
main()
|