RemVdH commited on
Commit
e666150
·
verified ·
1 Parent(s): cfc4d77

Create tools/play_music.py

Browse files
Files changed (1) hide show
  1. tools/play_music.py +20 -0
tools/play_music.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import time
3
+
4
+ from typing import Any, Optional
5
+ from smolagents.tools import Tool
6
+ from pydub import AudioSegment
7
+ from SoundFile import SoundFile
8
+
9
+ class PlaySomeMusicMeastro(Tool):
10
+ name = "prepare_play_music"
11
+ description = "Return a SoundFile object so the sounds can be played later to the listener. This tool does not play the music, that will be done in the final answer"
12
+ inputs = {'filename': {'type': 'string', 'description': 'The full file name of the song to play.'}}
13
+ output_type = "object"
14
+
15
+ def __init__(self, *args, **kwargs):
16
+ super().__init__()
17
+
18
+ def forward(self, filename: str) -> str:
19
+ print(f"Filename to prepare for playing => {filename}")
20
+ return SoundFile(f"./downloads/{filename}")