Update crew.py
Browse files
crew.py
CHANGED
|
@@ -120,19 +120,24 @@ def run_crew(question, file_path):
|
|
| 120 |
RuntimeError: If processing fails"""
|
| 121 |
try:
|
| 122 |
# YouTube
|
| 123 |
-
|
|
|
|
| 124 |
file = "audio.mp4"
|
| 125 |
|
|
|
|
| 126 |
yt = YouTube(url)
|
| 127 |
-
|
|
|
|
| 128 |
stream = yt.streams.filter(only_audio=True).first()
|
| 129 |
-
|
|
|
|
| 130 |
stream.download(output_path=".", filename=file)
|
| 131 |
|
| 132 |
# OpenAI
|
| 133 |
|
| 134 |
client = OpenAI()
|
| 135 |
|
|
|
|
| 136 |
transcription = client.audio.transcriptions.create(
|
| 137 |
file=open(file, "rb"),
|
| 138 |
model=AUDIO_MODEL,
|
|
@@ -141,7 +146,7 @@ def run_crew(question, file_path):
|
|
| 141 |
|
| 142 |
return transcription.text
|
| 143 |
except Exception as e:
|
| 144 |
-
raise RuntimeError(f"Failed to process
|
| 145 |
|
| 146 |
@tool("YouTube Video Analysis Tool")
|
| 147 |
def youtube_video_analysis_tool(question: str, url: str) -> str:
|
|
|
|
| 120 |
RuntimeError: If processing fails"""
|
| 121 |
try:
|
| 122 |
# YouTube
|
| 123 |
+
|
| 124 |
+
print("111")
|
| 125 |
file = "audio.mp4"
|
| 126 |
|
| 127 |
+
print("222")
|
| 128 |
yt = YouTube(url)
|
| 129 |
+
|
| 130 |
+
print("333")
|
| 131 |
stream = yt.streams.filter(only_audio=True).first()
|
| 132 |
+
|
| 133 |
+
print("444")
|
| 134 |
stream.download(output_path=".", filename=file)
|
| 135 |
|
| 136 |
# OpenAI
|
| 137 |
|
| 138 |
client = OpenAI()
|
| 139 |
|
| 140 |
+
print("555")
|
| 141 |
transcription = client.audio.transcriptions.create(
|
| 142 |
file=open(file, "rb"),
|
| 143 |
model=AUDIO_MODEL,
|
|
|
|
| 146 |
|
| 147 |
return transcription.text
|
| 148 |
except Exception as e:
|
| 149 |
+
raise RuntimeError(f"Failed to process audio: {str(e)}")
|
| 150 |
|
| 151 |
@tool("YouTube Video Analysis Tool")
|
| 152 |
def youtube_video_analysis_tool(question: str, url: str) -> str:
|