Spaces:
Running
Running
test
Browse files
app.py
CHANGED
@@ -57,12 +57,23 @@ 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 |
# Define the API endpoint
|
67 |
url = "https://api.deezer.com/search"
|
68 |
|
@@ -87,8 +98,7 @@ def play_preview_deezer(track: str, artist:str) -> None:
|
|
87 |
print(f"link: {first_track['link']}")
|
88 |
# Play the track
|
89 |
print("Playing preview: ", first_track['preview'])
|
90 |
-
|
91 |
-
time.sleep(30)
|
92 |
else:
|
93 |
print("No tracks found.")
|
94 |
else:
|
|
|
57 |
pygame.time.Clock().tick(10)
|
58 |
|
59 |
@tool
|
60 |
+
def play_preview_deezer(track: str, artist:str):
|
61 |
+
name = "play_music"
|
62 |
+
description = (
|
63 |
+
"Play the preview of the music given the name of the track and the artist. Use this to play music."
|
64 |
+
)
|
65 |
+
inputs = {
|
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"
|
79 |
|
|
|
98 |
print(f"link: {first_track['link']}")
|
99 |
# Play the track
|
100 |
print("Playing preview: ", first_track['preview'])
|
101 |
+
return first_track['preview']
|
|
|
102 |
else:
|
103 |
print("No tracks found.")
|
104 |
else:
|