Spaces:
Sleeping
Sleeping
Muhammed Essam
commited on
Commit
Β·
3dcdd5f
1
Parent(s):
24506f5
Performance: Fix
Browse filesredundant service calls and upgrade
Gradio
- Remove duplicate name extraction and
division matching in voice search
- Upgrade Gradio from 4.0.0 to 4.44.0
(security fix)
- Reduce voice query response time from
~60s to ~5-10s
- app.py +4 -8
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -206,22 +206,18 @@ def search_contacts_voice(audio: Optional[Tuple[int, np.ndarray]]) -> str:
|
|
| 206 |
voice_result = voice_processor.process_voice_query(temp_path)
|
| 207 |
query = voice_result['query']
|
| 208 |
|
| 209 |
-
# Search contacts
|
| 210 |
contacts = contact_search_service.search_contacts(query, top_k=10, min_confidence=0.3)
|
| 211 |
|
| 212 |
-
#
|
| 213 |
-
names = name_extractor.extract_names(query)
|
| 214 |
-
division_matches = embedding_service.find_division(query, top_k=3)
|
| 215 |
-
matched_divisions = [m.division for m in division_matches]
|
| 216 |
-
|
| 217 |
-
# Format output
|
| 218 |
output = []
|
| 219 |
output.append(f"**π€ Transcribed Text:** {query}")
|
| 220 |
output.append(f"**π Language:** {voice_result['language_name']}")
|
| 221 |
if voice_result['was_translated']:
|
| 222 |
output.append(f"**π Original:** {voice_result['original_text']}")
|
| 223 |
output.append("")
|
| 224 |
-
|
|
|
|
| 225 |
|
| 226 |
# Cleanup
|
| 227 |
voice_processor.cleanup_temp_file(temp_path)
|
|
|
|
| 206 |
voice_result = voice_processor.process_voice_query(temp_path)
|
| 207 |
query = voice_result['query']
|
| 208 |
|
| 209 |
+
# Search contacts (this already extracts names and divisions internally)
|
| 210 |
contacts = contact_search_service.search_contacts(query, top_k=10, min_confidence=0.3)
|
| 211 |
|
| 212 |
+
# Format output - names and divisions are already extracted by search_contacts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
output = []
|
| 214 |
output.append(f"**π€ Transcribed Text:** {query}")
|
| 215 |
output.append(f"**π Language:** {voice_result['language_name']}")
|
| 216 |
if voice_result['was_translated']:
|
| 217 |
output.append(f"**π Original:** {voice_result['original_text']}")
|
| 218 |
output.append("")
|
| 219 |
+
# Pass empty arrays since contact_search already did the matching
|
| 220 |
+
output.append(format_contact_results(contacts, [], []))
|
| 221 |
|
| 222 |
# Cleanup
|
| 223 |
voice_processor.cleanup_temp_file(temp_path)
|
requirements.txt
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
# Optimized for Gradio deployment
|
| 3 |
|
| 4 |
# Gradio for the web interface
|
| 5 |
-
gradio>=4.
|
| 6 |
|
| 7 |
# AI/ML Core Libraries - with version pinning for compatibility
|
| 8 |
transformers>=4.35.0,<5.0.0 # Transformer models (needed for sentence-transformers)
|
|
|
|
| 2 |
# Optimized for Gradio deployment
|
| 3 |
|
| 4 |
# Gradio for the web interface
|
| 5 |
+
gradio>=4.44.0
|
| 6 |
|
| 7 |
# AI/ML Core Libraries - with version pinning for compatibility
|
| 8 |
transformers>=4.35.0,<5.0.0 # Transformer models (needed for sentence-transformers)
|