Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -358,24 +358,34 @@ def process_with_claude(text):
|
|
358 |
|
359 |
# 9. UI Components
|
360 |
def render_search_interface():
|
361 |
-
"""Render main search interface"""
|
362 |
st.header("🔍 Voice Search")
|
363 |
|
364 |
# Voice component with autorun
|
365 |
-
|
366 |
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
371 |
|
372 |
# Process with selected model
|
373 |
-
if st.session_state.autoplay_audio:
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
|
|
|
|
|
|
379 |
|
380 |
# Manual search option
|
381 |
with st.expander("📝 Manual Search", expanded=False):
|
@@ -384,11 +394,14 @@ def render_search_interface():
|
|
384 |
query = st.text_input("Enter search query:")
|
385 |
with col2:
|
386 |
if st.button("🔍 Search"):
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
|
|
|
|
|
|
392 |
|
393 |
def display_file_manager():
|
394 |
"""Display file manager with media preview"""
|
|
|
358 |
|
359 |
# 9. UI Components
|
360 |
def render_search_interface():
|
361 |
+
"""Render main search interface with voice component"""
|
362 |
st.header("🔍 Voice Search")
|
363 |
|
364 |
# Voice component with autorun
|
365 |
+
voice_text = create_voice_component()
|
366 |
|
367 |
+
# Handle voice input
|
368 |
+
if voice_text and isinstance(voice_text, (str, dict)):
|
369 |
+
# Convert dict to string if necessary
|
370 |
+
current_text = voice_text if isinstance(voice_text, str) else voice_text.get('value', '')
|
371 |
+
|
372 |
+
# Compare with last processed text
|
373 |
+
if current_text and current_text != st.session_state.get('last_voice_text', ''):
|
374 |
+
st.session_state.last_voice_text = current_text
|
375 |
+
|
376 |
+
# Clean the text
|
377 |
+
cleaned_text = current_text.replace('\n', ' ').strip()
|
378 |
|
379 |
# Process with selected model
|
380 |
+
if st.session_state.autoplay_audio and cleaned_text:
|
381 |
+
try:
|
382 |
+
response, audio_file = asyncio.run(process_voice_search(cleaned_text))
|
383 |
+
if response:
|
384 |
+
st.markdown(response)
|
385 |
+
if audio_file:
|
386 |
+
render_audio_result(audio_file, "Search Results")
|
387 |
+
except Exception as e:
|
388 |
+
st.error(f"Error processing voice search: {str(e)}")
|
389 |
|
390 |
# Manual search option
|
391 |
with st.expander("📝 Manual Search", expanded=False):
|
|
|
394 |
query = st.text_input("Enter search query:")
|
395 |
with col2:
|
396 |
if st.button("🔍 Search"):
|
397 |
+
try:
|
398 |
+
response, audio_file = asyncio.run(process_voice_search(query))
|
399 |
+
if response:
|
400 |
+
st.markdown(response)
|
401 |
+
if audio_file:
|
402 |
+
render_audio_result(audio_file)
|
403 |
+
except Exception as e:
|
404 |
+
st.error(f"Error processing search: {str(e)}")
|
405 |
|
406 |
def display_file_manager():
|
407 |
"""Display file manager with media preview"""
|