Spaces:
Running
Running
Update agent.py
Browse files
agent.py
CHANGED
@@ -162,20 +162,25 @@ class DownloadTaskAttachmentTool(Tool):
|
|
162 |
except requests.exceptions.RequestException as e:
|
163 |
return f"Error downloading file for task {task_id}: {str(e)}"
|
164 |
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
|
|
|
|
|
|
|
|
174 |
|
175 |
-
|
|
|
176 |
return f"Error: File not found at {audio_path}"
|
177 |
-
|
178 |
-
|
179 |
|
180 |
class ExcelReaderTool(Tool):
|
181 |
name = "excel_reader"
|
|
|
162 |
except requests.exceptions.RequestException as e:
|
163 |
return f"Error downloading file for task {task_id}: {str(e)}"
|
164 |
|
165 |
+
class SpeechToTextTool(Tool):
|
166 |
+
name = "speech_to_text"
|
167 |
+
description = (
|
168 |
+
"Converts an audio file to text using OpenAI Whisper."
|
169 |
+
)
|
170 |
+
inputs = {
|
171 |
+
"audio_path": {"type": "string", "description": "Path to audio file (.mp3, .wav)"},
|
172 |
+
}
|
173 |
+
output_type = "string"
|
174 |
+
|
175 |
+
def __init__(self):
|
176 |
+
super().__init__()
|
177 |
+
self.model = whisper.load_model("base")
|
178 |
|
179 |
+
def forward(self, audio_path: str) -> str:
|
180 |
+
if not os.path.exists(audio_path):
|
181 |
return f"Error: File not found at {audio_path}"
|
182 |
+
result = self.model.transcribe(audio_path)
|
183 |
+
return result.get("text", "")
|
184 |
|
185 |
class ExcelReaderTool(Tool):
|
186 |
name = "excel_reader"
|