Spaces:
Build error
Build error
Update Gradio_UI.py
Browse files- Gradio_UI.py +10 -5
Gradio_UI.py
CHANGED
|
@@ -299,13 +299,18 @@ class GradioUI:
|
|
| 299 |
|
| 300 |
# NEW: Add a helper function to extract audio file path from stored messages
|
| 301 |
def extract_audio(messages):
|
|
|
|
| 302 |
if not messages:
|
| 303 |
return None
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
return None
|
| 310 |
|
| 311 |
with gr.Blocks(fill_height=True) as demo:
|
|
|
|
| 299 |
|
| 300 |
# NEW: Add a helper function to extract audio file path from stored messages
|
| 301 |
def extract_audio(messages):
|
| 302 |
+
# Iterate backwards over messages until we find one with audio content.
|
| 303 |
if not messages:
|
| 304 |
return None
|
| 305 |
+
for msg in reversed(messages):
|
| 306 |
+
# Only process messages that are objects with a "content" attribute.
|
| 307 |
+
if not hasattr(msg, "content"):
|
| 308 |
+
continue
|
| 309 |
+
# If the content is a dict and contains an audio mime type, return the file path.
|
| 310 |
+
if isinstance(msg.content, dict):
|
| 311 |
+
mime = msg.content.get("mime_type", "")
|
| 312 |
+
if mime.startswith("audio"):
|
| 313 |
+
return msg.content.get("path")
|
| 314 |
return None
|
| 315 |
|
| 316 |
with gr.Blocks(fill_height=True) as demo:
|