bstraehle commited on
Commit
adf9d94
·
verified ·
1 Parent(s): 6718d4a

Update crew.py

Browse files
Files changed (1) hide show
  1. crew.py +29 -1
crew.py CHANGED
@@ -1,6 +1,7 @@
1
  import os
2
 
3
  from crewai import Agent, Crew, Process, Task
 
4
  from crewai_tools import (
5
  CodeInterpreterTool,
6
  SerperDevTool,
@@ -17,6 +18,7 @@ from util import get_final_answer
17
  MANAGER_MODEL = "gpt-4.1"
18
  AGENT_MODEL = "gpt-4.1"
19
  FINAL_ANSWER_MODEL = "gpt-4.5-preview"
 
20
 
21
  # LLM evaluation
22
 
@@ -35,7 +37,33 @@ CrewAIInstrumentor().instrument(tracer_provider=tracer_provider)
35
  def run_crew(question, file_path):
36
  # Custom tools
37
 
38
- audio_analysis_tool = get_audio_analysis_tool()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  # Built-in tools
41
 
 
1
  import os
2
 
3
  from crewai import Agent, Crew, Process, Task
4
+ from crewai.tools import tool
5
  from crewai_tools import (
6
  CodeInterpreterTool,
7
  SerperDevTool,
 
18
  MANAGER_MODEL = "gpt-4.1"
19
  AGENT_MODEL = "gpt-4.1"
20
  FINAL_ANSWER_MODEL = "gpt-4.5-preview"
21
+ STT_MODEL = "whisper-1"
22
 
23
  # LLM evaluation
24
 
 
37
  def run_crew(question, file_path):
38
  # Custom tools
39
 
40
+ @tool("Audio Analysis Tool")
41
+ def audio_analysis_tool(question: str, file_path: str) -> str:
42
+ """Transcribe audio file using OpenAI's Whisper model.
43
+
44
+ Args:
45
+ question (str): Question to answer
46
+ file_path (str): Path of the audio file to transcribe
47
+
48
+ Returns:
49
+ str: Transcribed text from the audio file
50
+
51
+ Raises:
52
+ FileNotFoundError: If audio file does not exist
53
+ RuntimeError: If transcription fails"""
54
+ if not os.path.exists(file_path):
55
+ raise FileNotFoundError(f"Audio file not found: {file_path}")
56
+
57
+ try:
58
+ client = OpenAI()
59
+ transcript = client.audio.transcriptions.create(
60
+ file=open(file_path, "rb"),
61
+ model=STT_MODEL,
62
+ prompt=question,
63
+ )
64
+ return transcript.text
65
+ except Exception as e:
66
+ raise RuntimeError(f"Failed to transcribe audio: {str(e)}")
67
 
68
  # Built-in tools
69