Spaces:
Runtime error
Runtime error
David Li commited on
Commit ·
ac9b2c3
1
Parent(s): 4163e77
fix: youtube summarization
Browse files- app.py +21 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import re
|
| 3 |
+
from openbb_terminal.sdk import openbb
|
| 4 |
+
|
| 5 |
+
def get_video_id(url):
|
| 6 |
+
video_id = re.findall(r"v=([-\w]{11})", url)[0]
|
| 7 |
+
# make folder to store output files
|
| 8 |
+
os.makedirs(video_id, exist_ok=True)
|
| 9 |
+
# extract video ID from URL using regular expression
|
| 10 |
+
openbb.forecast.whisper(video=url, output_dir=video_id)
|
| 11 |
+
# return files from video_id folder
|
| 12 |
+
# find file with video_id/*_summary.txt
|
| 13 |
+
summary_file = glob.glob(f"{video_id}/*_summary.txt")[0]
|
| 14 |
+
# file .srt file
|
| 15 |
+
subtitle_file = glob.glob(f"{video_id}/*.srt")[0] or glob.glob(f"{video_id}/*.vtt")[0]
|
| 16 |
+
return summary_file, subtitle_file
|
| 17 |
+
|
| 18 |
+
input_text = gr.inputs.Textbox(label="Enter a YouTube URL")
|
| 19 |
+
output_text = [gr.outputs.Textbox(label="Summary File"), gr.outputs.Textbox(label="Subtitle File")]
|
| 20 |
+
|
| 21 |
+
gr.Interface(fn=get_video_id, inputs=input_text, outputs=output_text, title="YouTube Video ID Finder").launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
openbb
|