Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -194,10 +194,12 @@ elif page == "Semantic Search":
|
|
194 |
|
195 |
recognition.onresult = (event) => {
|
196 |
const transcript = event.results[0][0].transcript;
|
197 |
-
//
|
198 |
-
const
|
199 |
-
|
200 |
-
|
|
|
|
|
201 |
micBtn.textContent = '🎤';
|
202 |
};
|
203 |
|
@@ -212,15 +214,10 @@ elif page == "Semantic Search":
|
|
212 |
scrolling=False,
|
213 |
)
|
214 |
|
215 |
-
#
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
if voice_text != st.session_state.voice_question:
|
220 |
-
st.session_state.voice_question = voice_text
|
221 |
-
st.session_state.auto_run_search = True
|
222 |
-
# Clear the query param to avoid repeated triggers
|
223 |
-
st.experimental_set_query_params()
|
224 |
|
225 |
# Automatically run semantic search if flag is set
|
226 |
if st.session_state.auto_run_search:
|
|
|
194 |
|
195 |
recognition.onresult = (event) => {
|
196 |
const transcript = event.results[0][0].transcript;
|
197 |
+
// Send transcript to Streamlit by updating the input field
|
198 |
+
const inputBox = window.parent.document.querySelector('input[data-key="question_input"]');
|
199 |
+
if (inputBox) {
|
200 |
+
inputBox.value = transcript;
|
201 |
+
inputBox.dispatchEvent(new Event('input', { bubbles: true }));
|
202 |
+
}
|
203 |
micBtn.textContent = '🎤';
|
204 |
};
|
205 |
|
|
|
214 |
scrolling=False,
|
215 |
)
|
216 |
|
217 |
+
# Update session state voice_question if question input changed manually or by voice
|
218 |
+
if question != st.session_state.voice_question:
|
219 |
+
st.session_state.voice_question = question
|
220 |
+
st.session_state.auto_run_search = True
|
|
|
|
|
|
|
|
|
|
|
221 |
|
222 |
# Automatically run semantic search if flag is set
|
223 |
if st.session_state.auto_run_search:
|