Sborole commited on
Commit
d190aeb
·
verified ·
1 Parent(s): 9cb2644

Create ReadAudioTool.py

Browse files
Files changed (1) hide show
  1. tools/ReadAudioTool.py +11 -0
tools/ReadAudioTool.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents.tools import Tool
2
+
3
+ class ReadAudioTool(Tool):
4
+ name = "read_audio"
5
+ description = "Reads an audio file and returns base64 so Gemini can transcribe it."
6
+ inputs = {"file_path": {"type": "string"}}
7
+ output_type = "string"
8
+
9
+ def forward(self, file_path: str) -> str:
10
+ with open(file_path, "rb") as aud:
11
+ return base64.b64encode(aud.read()).decode("utf-8")