Spaces:
Paused
Paused
Update crew.py
Browse files
crew.py
CHANGED
|
@@ -9,6 +9,7 @@ from crewai_tools import (
|
|
| 9 |
WebsiteSearchTool,
|
| 10 |
YoutubeVideoSearchTool
|
| 11 |
)
|
|
|
|
| 12 |
from openinference.instrumentation.crewai import CrewAIInstrumentor
|
| 13 |
from phoenix.otel import register
|
| 14 |
from util import get_final_answer
|
|
@@ -32,11 +33,12 @@ def run_crew(question, file_name):
|
|
| 32 |
# Tools
|
| 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 |
-
|
|
|
|
| 40 |
|
| 41 |
Returns:
|
| 42 |
str: Transcribed text from the audio file
|
|
@@ -50,13 +52,13 @@ def run_crew(question, file_name):
|
|
| 50 |
|
| 51 |
try:
|
| 52 |
# Load Whisper model (using base model by default)
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
return
|
| 60 |
except Exception as e:
|
| 61 |
raise RuntimeError(f"Failed to transcribe audio: {str(e)}")
|
| 62 |
###
|
|
|
|
| 9 |
WebsiteSearchTool,
|
| 10 |
YoutubeVideoSearchTool
|
| 11 |
)
|
| 12 |
+
from openai import OpenAI
|
| 13 |
from openinference.instrumentation.crewai import CrewAIInstrumentor
|
| 14 |
from phoenix.otel import register
|
| 15 |
from util import get_final_answer
|
|
|
|
| 33 |
# Tools
|
| 34 |
|
| 35 |
@tool("Audio Analysis Tool")
|
| 36 |
+
def audio_analysis_tool(question: str, file_name: str) -> str:
|
| 37 |
"""Transcribe audio file using OpenAI's Whisper model.
|
| 38 |
|
| 39 |
Args:
|
| 40 |
+
question (str): Question to answer
|
| 41 |
+
file_name (str): Name of the audio file to transcribe
|
| 42 |
|
| 43 |
Returns:
|
| 44 |
str: Transcribed text from the audio file
|
|
|
|
| 52 |
|
| 53 |
try:
|
| 54 |
# Load Whisper model (using base model by default)
|
| 55 |
+
client = OpenAI()
|
| 56 |
+
client.audio.transcriptions.create(
|
| 57 |
+
file=open(audio_filepath, "rb"),
|
| 58 |
+
model="whisper-1",
|
| 59 |
+
prompt=prompt,
|
| 60 |
+
)
|
| 61 |
+
return transcript.text
|
| 62 |
except Exception as e:
|
| 63 |
raise RuntimeError(f"Failed to transcribe audio: {str(e)}")
|
| 64 |
###
|