Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,13 +28,18 @@ def recommend_items(dish_name):
|
|
| 28 |
def process_order(audio_file):
|
| 29 |
import speech_recognition as sr
|
| 30 |
recognizer = sr.Recognizer()
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
| 35 |
user_input = recognizer.recognize_google(audio_data)
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
| 38 |
|
| 39 |
global conversation_history
|
| 40 |
|
|
|
|
| 28 |
def process_order(audio_file):
|
| 29 |
import speech_recognition as sr
|
| 30 |
recognizer = sr.Recognizer()
|
| 31 |
+
|
| 32 |
+
if not audio_file or not isinstance(audio_file, str):
|
| 33 |
+
return "No valid audio file provided. Please try again.", ""
|
| 34 |
+
|
| 35 |
+
try:
|
| 36 |
+
with sr.AudioFile(audio_file) as source:
|
| 37 |
+
audio_data = recognizer.record(source)
|
| 38 |
user_input = recognizer.recognize_google(audio_data)
|
| 39 |
+
except sr.UnknownValueError:
|
| 40 |
+
return "I couldn't understand that. Could you please repeat?", ""
|
| 41 |
+
except Exception as e:
|
| 42 |
+
return f"Error processing audio: {e}", ""
|
| 43 |
|
| 44 |
global conversation_history
|
| 45 |
|