Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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)
|