geethareddy commited on
Commit
8a80580
·
verified ·
1 Parent(s): 7694e0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -151,6 +151,12 @@ def generate_voice_feedback(text):
151
  def analyze_voice(audio_file):
152
  """Analyze voice for health indicators and provide text and voice feedback."""
153
  try:
 
 
 
 
 
 
154
  # Ensure unique file name to avoid Gradio reuse
155
  unique_path = f"/tmp/gradio/{datetime.now().strftime('%Y%m%d%H%M%S%f')}_{os.path.basename(audio_file)}"
156
  os.rename(audio_file, unique_path)
 
151
  def analyze_voice(audio_file):
152
  """Analyze voice for health indicators and provide text and voice feedback."""
153
  try:
154
+ # Check if audio_file is None
155
+ if audio_file is None:
156
+ feedback = "Error: No audio provided. Please record or upload a valid audio file."
157
+ voice_file = generate_voice_feedback(feedback)
158
+ return feedback, voice_file
159
+
160
  # Ensure unique file name to avoid Gradio reuse
161
  unique_path = f"/tmp/gradio/{datetime.now().strftime('%Y%m%d%H%M%S%f')}_{os.path.basename(audio_file)}"
162
  os.rename(audio_file, unique_path)