Sborole-Final-Assignment / tools /ReadAudioTool.py
Sborole's picture
Update tools/ReadAudioTool.py
bb4b0e1 verified
raw
history blame contribute delete
507 Bytes
from smolagents.tools import Tool
class ReadAudioTool(Tool):
name = "read_audio"
description = "Reads an audio file and returns base64 so Gemini can transcribe it."
inputs = {
"file_path": {
"type": "string",
"description": "The full path of the text file to read"
}
}
output_type = "string"
def forward(self, file_path: str) -> str:
with open(file_path, "rb") as aud:
return base64.b64encode(aud.read()).decode("utf-8")