Spaces:
Sleeping
Sleeping
Aditya DN commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,21 +43,29 @@ def identify_audio(file):
|
|
| 43 |
buf = f.read()
|
| 44 |
buffer_result = acr.recognize_by_filebuffer(buf, 0)
|
| 45 |
|
| 46 |
-
# Convert results
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
{}
|
| 54 |
-
```
|
| 55 |
|
| 56 |
-
###
|
| 57 |
-
|
| 58 |
-
{}
|
| 59 |
-
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
return gr.Markdown(result_md)
|
| 63 |
|
|
|
|
| 43 |
buf = f.read()
|
| 44 |
buffer_result = acr.recognize_by_filebuffer(buf, 0)
|
| 45 |
|
| 46 |
+
# Convert JSON results to dictionary
|
| 47 |
+
full_result_dict = json.loads(full_result)
|
| 48 |
+
buffer_result_dict = json.loads(buffer_result)
|
| 49 |
+
|
| 50 |
+
# Format the results as markdown
|
| 51 |
+
result_md = f"""
|
| 52 |
+
### **Partial Results**:
|
| 53 |
+
{'\n'.join(results)}
|
|
|
|
| 54 |
|
| 55 |
+
### **Full Result**:
|
| 56 |
+
- **Track**: {full_result_dict['metadata']['music'][0]['title']}
|
| 57 |
+
- **Artist**: {full_result_dict['metadata']['music'][0]['artists'][0]['name']}
|
| 58 |
+
- **Album**: {full_result_dict['metadata']['music'][0]['album']['name']}
|
| 59 |
+
- **Release Date**: {full_result_dict['metadata']['music'][0]['release_date']}
|
| 60 |
+
- **Score**: {full_result_dict['metadata']['music'][0]['score']}%
|
| 61 |
+
|
| 62 |
+
### **Buffer Result**:
|
| 63 |
+
- **Track**: {buffer_result_dict['metadata']['music'][0]['title']}
|
| 64 |
+
- **Artist**: {buffer_result_dict['metadata']['music'][0]['artists'][0]['name']}
|
| 65 |
+
- **Album**: {buffer_result_dict['metadata']['music'][0]['album']['name']}
|
| 66 |
+
- **Release Date**: {buffer_result_dict['metadata']['music'][0]['release_date']}
|
| 67 |
+
- **Score**: {buffer_result_dict['metadata']['music'][0]['score']}%
|
| 68 |
+
"""
|
| 69 |
|
| 70 |
return gr.Markdown(result_md)
|
| 71 |
|