Spaces:
Sleeping
Sleeping
Aditya DN commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -102,16 +102,17 @@ def recognize_audio(choice, url, file):
|
|
| 102 |
# Parse the response into a structured format
|
| 103 |
try:
|
| 104 |
data = response.json()
|
| 105 |
-
result = data.get('result', {})
|
| 106 |
|
| 107 |
-
# Check if
|
| 108 |
-
if
|
| 109 |
-
error_message =
|
| 110 |
return f"""
|
| 111 |
### Song recognition failed
|
| 112 |
{error_message}
|
| 113 |
-
|
| 114 |
|
|
|
|
|
|
|
| 115 |
artist = result.get('artist', 'Unknown Artist')
|
| 116 |
title = result.get('title', 'Unknown Title')
|
| 117 |
album = result.get('album', 'Unknown Album')
|
|
|
|
| 102 |
# Parse the response into a structured format
|
| 103 |
try:
|
| 104 |
data = response.json()
|
|
|
|
| 105 |
|
| 106 |
+
# Check if there's an error in the response
|
| 107 |
+
if data.get("status") == "error":
|
| 108 |
+
error_message = data.get("error", {}).get("error_message", "Unknown error.")
|
| 109 |
return f"""
|
| 110 |
### Song recognition failed
|
| 111 |
{error_message}
|
| 112 |
+
"""
|
| 113 |
|
| 114 |
+
result = data.get('result', {})
|
| 115 |
+
|
| 116 |
artist = result.get('artist', 'Unknown Artist')
|
| 117 |
title = result.get('title', 'Unknown Title')
|
| 118 |
album = result.get('album', 'Unknown Album')
|