Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
# β
Stock Recommendation Extractor from YouTube Audio (
|
2 |
|
3 |
import os
|
4 |
import gradio as gr
|
@@ -114,25 +114,31 @@ def save_cookies(file):
|
|
114 |
f.write(file.read())
|
115 |
return temp_path
|
116 |
|
117 |
-
# β
Full pipeline
|
118 |
|
119 |
def run_pipeline(url, cookies_file):
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
|
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
|
134 |
-
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
136 |
|
137 |
# β
Gradio Interface
|
138 |
with gr.Blocks(title="Stock Insights from YouTube Audio") as demo:
|
|
|
1 |
+
# β
Stock Recommendation Extractor from YouTube Audio (with full error reporting)
|
2 |
|
3 |
import os
|
4 |
import gradio as gr
|
|
|
114 |
f.write(file.read())
|
115 |
return temp_path
|
116 |
|
117 |
+
# β
Full pipeline with error traceback
|
118 |
|
119 |
def run_pipeline(url, cookies_file):
|
120 |
+
try:
|
121 |
+
if not WHISPER_AVAILABLE:
|
122 |
+
return "β Whisper is not installed. Run: pip install openai-whisper", ""
|
123 |
+
if not url:
|
124 |
+
return "β YouTube URL required", ""
|
125 |
|
126 |
+
cookie_path = save_cookies(cookies_file)
|
127 |
+
audio_path, status = download_audio(url, cookie_path)
|
128 |
+
if not audio_path:
|
129 |
+
return status, ""
|
130 |
|
131 |
+
transcript = transcribe_audio(audio_path)
|
132 |
+
if transcript.startswith("β"):
|
133 |
+
return transcript, ""
|
134 |
|
135 |
+
stock_info = extract_stock_info(transcript)
|
136 |
+
return "β
Complete", stock_info
|
137 |
+
|
138 |
+
except Exception as e:
|
139 |
+
tb = traceback.format_exc()
|
140 |
+
print(tb)
|
141 |
+
return f"β Unhandled Error:\n{tb}", ""
|
142 |
|
143 |
# β
Gradio Interface
|
144 |
with gr.Blocks(title="Stock Insights from YouTube Audio") as demo:
|