Spaces:
Paused
Paused
Update crew.py
Browse files
crew.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import os
|
| 2 |
|
| 3 |
from crewai import Agent, Crew, Process, Task
|
| 4 |
from crewai.tools import tool
|
|
@@ -33,8 +33,33 @@ def run_crew(question, file_name):
|
|
| 33 |
|
| 34 |
@tool("Audio Analysis Tool")
|
| 35 |
def audio_analysis_tool(file_name: str) -> str:
|
| 36 |
-
"""
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
image_analysis_tool = VisionTool()
|
| 40 |
python_coding_tool = CodeInterpreterTool()
|
|
|
|
| 1 |
+
import os, whisper
|
| 2 |
|
| 3 |
from crewai import Agent, Crew, Process, Task
|
| 4 |
from crewai.tools import tool
|
|
|
|
| 33 |
|
| 34 |
@tool("Audio Analysis Tool")
|
| 35 |
def audio_analysis_tool(file_name: str) -> str:
|
| 36 |
+
"""Transcribe audio file using OpenAI's Whisper model.
|
| 37 |
+
|
| 38 |
+
Args:
|
| 39 |
+
file_path (str): Path to the audio file to transcribe
|
| 40 |
+
|
| 41 |
+
Returns:
|
| 42 |
+
str: Transcribed text from the audio file
|
| 43 |
+
|
| 44 |
+
Raises:
|
| 45 |
+
FileNotFoundError: If audio file does not exist
|
| 46 |
+
RuntimeError: If transcription fails"""
|
| 47 |
+
###
|
| 48 |
+
if not os.path.exists(file_name):
|
| 49 |
+
raise FileNotFoundError(f"Audio file not found: {file_name}")
|
| 50 |
+
|
| 51 |
+
try:
|
| 52 |
+
# Load Whisper model (using base model by default)
|
| 53 |
+
model = whisper.load_model("base")
|
| 54 |
+
|
| 55 |
+
# Transcribe the audio file
|
| 56 |
+
result = model.transcribe(file_path)
|
| 57 |
+
|
| 58 |
+
# Return transcribed text
|
| 59 |
+
return result["text"].strip()
|
| 60 |
+
except Exception as e:
|
| 61 |
+
raise RuntimeError(f"Failed to transcribe audio: {str(e)}")
|
| 62 |
+
###
|
| 63 |
|
| 64 |
image_analysis_tool = VisionTool()
|
| 65 |
python_coding_tool = CodeInterpreterTool()
|