Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -34,14 +34,27 @@ def identify_audio(file):
|
|
34 |
full_result = acr.recognize_by_file(file_path, 0)
|
35 |
full_result_dict = json.loads(full_result)
|
36 |
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
result_md = f"""
|
39 |
### **Full Result**:
|
40 |
-
- **Track**: {
|
41 |
-
- **Artist**: {
|
42 |
-
- **Album**: {
|
43 |
-
- **Release Date**: {
|
44 |
-
- **Score**: {
|
|
|
|
|
|
|
45 |
"""
|
46 |
|
47 |
return gr.Markdown(result_md)
|
|
|
34 |
full_result = acr.recognize_by_file(file_path, 0)
|
35 |
full_result_dict = json.loads(full_result)
|
36 |
|
37 |
+
music = full_result_dict['metadata']['music'][0]
|
38 |
+
|
39 |
+
# Spotify link
|
40 |
+
spotify_track_id = music['external_metadata']['spotify']['track']['id']
|
41 |
+
spotify_link = f"https://open.spotify.com/track/{spotify_track_id}"
|
42 |
+
|
43 |
+
# Deezer link
|
44 |
+
deezer_track_id = music['external_metadata']['deezer']['track']['id']
|
45 |
+
deezer_link = f"https://www.deezer.com/track/{deezer_track_id}"
|
46 |
+
|
47 |
+
# Final markdown result
|
48 |
result_md = f"""
|
49 |
### **Full Result**:
|
50 |
+
- **Track**: {music['title']}
|
51 |
+
- **Artist**: {music['artists'][0]['name']}
|
52 |
+
- **Album**: {music['album']['name']}
|
53 |
+
- **Release Date**: {music['release_date']}
|
54 |
+
- **Score**: {music['score']}%
|
55 |
+
- **Download Link**:
|
56 |
+
- [Listen on Spotify]({spotify_link})
|
57 |
+
- [Listen on Deezer]({deezer_link})
|
58 |
"""
|
59 |
|
60 |
return gr.Markdown(result_md)
|