Spaces:
Sleeping
Sleeping
Restore music problem
Browse files
app.py
CHANGED
@@ -57,22 +57,12 @@ def play_audio_from_url(url):
|
|
57 |
pygame.time.Clock().tick(10)
|
58 |
|
59 |
@tool
|
60 |
-
def play_preview_deezer(track: str, artist:str):
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
"track": {
|
67 |
-
"type": "string",
|
68 |
-
"description": "The name of the track.",
|
69 |
-
},
|
70 |
-
"artist": {
|
71 |
-
"type": "string",
|
72 |
-
"description": "The name of the artist.",
|
73 |
-
}
|
74 |
-
}
|
75 |
-
output_type = "audio"
|
76 |
|
77 |
# Define the API endpoint
|
78 |
url = "https://api.deezer.com/search"
|
@@ -98,7 +88,7 @@ def play_preview_deezer(track: str, artist:str):
|
|
98 |
print(f"link: {first_track['link']}")
|
99 |
# Play the track
|
100 |
print("Playing preview: ", first_track['preview'])
|
101 |
-
|
102 |
else:
|
103 |
print("No tracks found.")
|
104 |
else:
|
|
|
57 |
pygame.time.Clock().tick(10)
|
58 |
|
59 |
@tool
|
60 |
+
def play_preview_deezer(track: str, artist:str) -> None:
|
61 |
+
"""Play a preview of a track from Deezer.
|
62 |
+
Args:
|
63 |
+
track: The track to play.
|
64 |
+
artist: The artist of the track.
|
65 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
# Define the API endpoint
|
68 |
url = "https://api.deezer.com/search"
|
|
|
88 |
print(f"link: {first_track['link']}")
|
89 |
# Play the track
|
90 |
print("Playing preview: ", first_track['preview'])
|
91 |
+
play_audio_from_url(first_track['preview'])
|
92 |
else:
|
93 |
print("No tracks found.")
|
94 |
else:
|