Spaces:
Configuration error
Configuration error
Update crew.py
Browse files
crew.py
CHANGED
|
@@ -37,14 +37,15 @@ def run_crew(question, file_path):
|
|
| 37 |
# Custom tools
|
| 38 |
|
| 39 |
@tool("Audio Analysis Tool")
|
| 40 |
-
def audio_analysis_tool(file_path: str) -> str:
|
| 41 |
-
"""Transcribe audio file
|
| 42 |
|
| 43 |
Args:
|
| 44 |
-
|
|
|
|
| 45 |
|
| 46 |
Returns:
|
| 47 |
-
str:
|
| 48 |
|
| 49 |
Raises:
|
| 50 |
FileNotFoundError: If audio file does not exist
|
|
@@ -54,10 +55,13 @@ def run_crew(question, file_path):
|
|
| 54 |
|
| 55 |
try:
|
| 56 |
client = OpenAI()
|
|
|
|
| 57 |
transcript = client.audio.transcriptions.create(
|
| 58 |
file=open(file_path, "rb"),
|
| 59 |
-
model=STT_MODEL
|
|
|
|
| 60 |
)
|
|
|
|
| 61 |
return transcript.text
|
| 62 |
except Exception as e:
|
| 63 |
raise RuntimeError(f"Failed to transcribe audio: {str(e)}")
|
|
|
|
| 37 |
# Custom tools
|
| 38 |
|
| 39 |
@tool("Audio Analysis Tool")
|
| 40 |
+
def audio_analysis_tool(question: str, file_path: str) -> str:
|
| 41 |
+
"""Transcribe the audio file and answer the question.
|
| 42 |
|
| 43 |
Args:
|
| 44 |
+
question (str): Question about the audio file
|
| 45 |
+
file_path (str): Path of audio the file
|
| 46 |
|
| 47 |
Returns:
|
| 48 |
+
str: Answer to the question about the audio file
|
| 49 |
|
| 50 |
Raises:
|
| 51 |
FileNotFoundError: If audio file does not exist
|
|
|
|
| 55 |
|
| 56 |
try:
|
| 57 |
client = OpenAI()
|
| 58 |
+
|
| 59 |
transcript = client.audio.transcriptions.create(
|
| 60 |
file=open(file_path, "rb"),
|
| 61 |
+
model=STT_MODEL,
|
| 62 |
+
prompt=question
|
| 63 |
)
|
| 64 |
+
|
| 65 |
return transcript.text
|
| 66 |
except Exception as e:
|
| 67 |
raise RuntimeError(f"Failed to transcribe audio: {str(e)}")
|