Liphos commited on
Commit
ec6f741
·
verified ·
1 Parent(s): d77c1f2
Files changed (1) hide show
  1. app.py +18 -8
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) -> 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
  # 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
- play_audio_from_url(first_track['preview'])
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: