developer28 commited on
Commit
3a135c5
Β·
verified Β·
1 Parent(s): 91c1296

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -15
app.py CHANGED
@@ -1,4 +1,4 @@
1
- # βœ… Stock Recommendation Extractor from YouTube Audio (Working Pipeline)
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
- if not WHISPER_AVAILABLE:
121
- return "❌ Whisper is not installed. Run: pip install openai-whisper", ""
122
- if not url:
123
- return "❌ YouTube URL required", ""
 
124
 
125
- cookie_path = save_cookies(cookies_file)
126
- audio_path, status = download_audio(url, cookie_path)
127
- if not audio_path:
128
- return status, ""
129
 
130
- transcript = transcribe_audio(audio_path)
131
- if transcript.startswith("❌"):
132
- return transcript, ""
133
 
134
- stock_info = extract_stock_info(transcript)
135
- return "βœ… Complete", stock_info
 
 
 
 
 
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: