Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -194,12 +194,10 @@ elif page == "Semantic Search":
|
|
| 194 |
|
| 195 |
recognition.onresult = (event) => {
|
| 196 |
const transcript = event.results[0][0].transcript;
|
| 197 |
-
//
|
| 198 |
-
const
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
inputBox.dispatchEvent(new Event('input', { bubbles: true }));
|
| 202 |
-
}
|
| 203 |
micBtn.textContent = '🎤';
|
| 204 |
};
|
| 205 |
|
|
@@ -214,10 +212,15 @@ elif page == "Semantic Search":
|
|
| 214 |
scrolling=False,
|
| 215 |
)
|
| 216 |
|
| 217 |
-
#
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
|
| 222 |
# Automatically run semantic search if flag is set
|
| 223 |
if st.session_state.auto_run_search:
|
|
|
|
| 194 |
|
| 195 |
recognition.onresult = (event) => {
|
| 196 |
const transcript = event.results[0][0].transcript;
|
| 197 |
+
// Update URL query parameter with recognized text
|
| 198 |
+
const url = new URL(window.location);
|
| 199 |
+
url.searchParams.set('voice_input', transcript);
|
| 200 |
+
window.history.replaceState(null, '', url);
|
|
|
|
|
|
|
| 201 |
micBtn.textContent = '🎤';
|
| 202 |
};
|
| 203 |
|
|
|
|
| 212 |
scrolling=False,
|
| 213 |
)
|
| 214 |
|
| 215 |
+
# Check if voice input is passed via query params
|
| 216 |
+
query_params = st.experimental_get_query_params()
|
| 217 |
+
if "voice_input" in query_params:
|
| 218 |
+
voice_text = query_params["voice_input"][0]
|
| 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:
|