Update app.py
Browse files
app.py
CHANGED
@@ -558,18 +558,25 @@ async def async_interface():
|
|
558 |
|
559 |
st.subheader("🎤 Speech-to-Chat")
|
560 |
from mycomponent import mycomponent
|
|
|
|
|
561 |
transcript_data = mycomponent(default_value=st.session_state.get('last_transcript', ''), key="speech_input")
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
|
|
|
|
569 |
edited_transcript = st.text_area("✏️ Edit Transcript:", value=transcript, height=100, key="transcript_input")
|
|
|
|
|
570 |
if transcript:
|
571 |
st.write(f"🎙️ You said: {transcript}")
|
572 |
|
|
|
573 |
if edited_transcript and edited_transcript != st.session_state.get('last_sent_transcript', ''):
|
574 |
if st.session_state.autosend:
|
575 |
await save_chat_entry(st.session_state.username, edited_transcript, True)
|
|
|
558 |
|
559 |
st.subheader("🎤 Speech-to-Chat")
|
560 |
from mycomponent import mycomponent
|
561 |
+
|
562 |
+
# Invoke the speech component
|
563 |
transcript_data = mycomponent(default_value=st.session_state.get('last_transcript', ''), key="speech_input")
|
564 |
+
|
565 |
+
# Extract transcript, defaulting to empty string if None or invalid
|
566 |
+
transcript = transcript_data['value'].strip().replace('\n', ' ') if transcript_data and 'value' in transcript_data else st.session_state.get('last_transcript', '')
|
567 |
+
|
568 |
+
# Update session state only if new transcript differs
|
569 |
+
if transcript and transcript != st.session_state.get('last_transcript', ''):
|
570 |
+
st.session_state.last_transcript = transcript
|
571 |
+
|
572 |
+
# Text area for editing transcript
|
573 |
edited_transcript = st.text_area("✏️ Edit Transcript:", value=transcript, height=100, key="transcript_input")
|
574 |
+
|
575 |
+
# Display raw transcript for feedback
|
576 |
if transcript:
|
577 |
st.write(f"🎙️ You said: {transcript}")
|
578 |
|
579 |
+
# Send edited transcript to chat
|
580 |
if edited_transcript and edited_transcript != st.session_state.get('last_sent_transcript', ''):
|
581 |
if st.session_state.autosend:
|
582 |
await save_chat_entry(st.session_state.username, edited_transcript, True)
|