Awell00 commited on
Commit
9361dca
·
1 Parent(s): e9ef9ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -119,6 +119,10 @@ def record(audio):
119
  str: A success message if the audio is recorded correctly, otherwise an error message.
120
  """
121
  try:
 
 
 
 
122
  # Unpack the sample rate and data from the audio tuple
123
  sr, data = audio
124
 
@@ -132,7 +136,7 @@ def record(audio):
132
  return f"Audio receive correctly"
133
  except Exception as e:
134
  # If an error occurs, return an error message
135
- return f"Error: {e}"
136
 
137
 
138
  # -----------------Frame----------------- #
 
119
  str: A success message if the audio is recorded correctly, otherwise an error message.
120
  """
121
  try:
122
+ # Check if the audio tuple contains exactly two elements
123
+ if len(audio) != 2:
124
+ return f"Error: Expected a tuple with 2 elements, but got {len(audio)}"
125
+
126
  # Unpack the sample rate and data from the audio tuple
127
  sr, data = audio
128
 
 
136
  return f"Audio receive correctly"
137
  except Exception as e:
138
  # If an error occurs, return an error message
139
+ return f"Error: {str(e)}"
140
 
141
 
142
  # -----------------Frame----------------- #