DSatishchandra commited on
Commit
a6f3eae
·
verified ·
1 Parent(s): 02d4ef1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
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
- with sr.AudioFile(audio_file) as source:
33
- audio_data = recognizer.record(source)
34
- try:
 
 
 
35
  user_input = recognizer.recognize_google(audio_data)
36
- except sr.UnknownValueError:
37
- return "I couldn't understand that. Could you please repeat?", ""
 
 
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