Spaces:
Running
Running
Yannael_LB
commited on
Commit
·
9fa0e9e
1
Parent(s):
f1d78c4
Update
Browse files- app.py +7 -12
- examples/ErnWZxJovaM.json +0 -0
- utils.py +4 -2
app.py
CHANGED
@@ -9,14 +9,16 @@ example_output_transcript = utils.load_transcript(example_video_id)
|
|
9 |
example_chapters = utils.load_json_chapters(example_video_id)
|
10 |
example_output_html = utils.get_result_as_html(example_chapters, example_video_id)
|
11 |
|
12 |
-
example_video_id_dict = {"MIT Introduction to Deep Learning | 6.S191 - Alexander Amini": "ErnWZxJovaM",
|
13 |
-
"
|
14 |
-
"
|
15 |
|
16 |
example_video_names = list(example_video_id_dict.keys())
|
17 |
|
18 |
def gradio_load_example(example_video):
|
19 |
|
|
|
|
|
20 |
video_id = example_video_id_dict[example_video]
|
21 |
|
22 |
transcript_as_text = utils.load_transcript(video_id)
|
@@ -46,27 +48,20 @@ with (gr.Blocks(css=css) as app):
|
|
46 |
gr.HTML("<div align='center'><h3>See the companion <a href=''>Medium article</a> and <a href=''>Github repository</a> for more details</h3>")
|
47 |
gr.HTML("<hr>")
|
48 |
|
49 |
-
#gv_transcript = gr.State()
|
50 |
-
|
51 |
video_id_input = gr.Dropdown(choices=example_video_names,
|
52 |
label="Choose a video to see the structured transcript",
|
53 |
value=example_video_names[0])
|
54 |
|
55 |
-
load_button = gr.Button("Load example")
|
56 |
-
|
57 |
-
#gv_output = gr.State()
|
58 |
-
|
59 |
gr.HTML("<hr>")
|
60 |
|
61 |
with gr.Accordion("See raw transcript", open=False):
|
62 |
output_transcript = gr.Textbox(value=example_output_transcript, max_lines=10, lines=10, label="Raw transcript")
|
63 |
|
|
|
64 |
output_processing = gr.HTML(label="Output processing", value=example_output_html)
|
65 |
|
66 |
-
|
67 |
inputs=[video_id_input],
|
68 |
outputs=[output_processing, output_transcript])
|
69 |
|
70 |
-
# gr.HTML(result_as_html)
|
71 |
-
|
72 |
app.launch(debug=True, width="100%")
|
|
|
9 |
example_chapters = utils.load_json_chapters(example_video_id)
|
10 |
example_output_html = utils.get_result_as_html(example_chapters, example_video_id)
|
11 |
|
12 |
+
example_video_id_dict = {"MIT Introduction to Deep Learning | 6.S191 - Alexander Amini - 2024": "ErnWZxJovaM",
|
13 |
+
"How to speak - Patrick Winston - 2018": "Unzc731iCUY",
|
14 |
+
"Let's build the GPT Tokenizer - Andrej Karpathy - 2024": "zduSFxRajkE"}
|
15 |
|
16 |
example_video_names = list(example_video_id_dict.keys())
|
17 |
|
18 |
def gradio_load_example(example_video):
|
19 |
|
20 |
+
print(f"Loading example: {example_video}")
|
21 |
+
|
22 |
video_id = example_video_id_dict[example_video]
|
23 |
|
24 |
transcript_as_text = utils.load_transcript(video_id)
|
|
|
48 |
gr.HTML("<div align='center'><h3>See the companion <a href=''>Medium article</a> and <a href=''>Github repository</a> for more details</h3>")
|
49 |
gr.HTML("<hr>")
|
50 |
|
|
|
|
|
51 |
video_id_input = gr.Dropdown(choices=example_video_names,
|
52 |
label="Choose a video to see the structured transcript",
|
53 |
value=example_video_names[0])
|
54 |
|
|
|
|
|
|
|
|
|
55 |
gr.HTML("<hr>")
|
56 |
|
57 |
with gr.Accordion("See raw transcript", open=False):
|
58 |
output_transcript = gr.Textbox(value=example_output_transcript, max_lines=10, lines=10, label="Raw transcript")
|
59 |
|
60 |
+
|
61 |
output_processing = gr.HTML(label="Output processing", value=example_output_html)
|
62 |
|
63 |
+
video_id_input.change(gradio_load_example,
|
64 |
inputs=[video_id_input],
|
65 |
outputs=[output_processing, output_transcript])
|
66 |
|
|
|
|
|
67 |
app.launch(debug=True, width="100%")
|
examples/ErnWZxJovaM.json
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
utils.py
CHANGED
@@ -71,7 +71,6 @@ def toc_to_html(chapters):
|
|
71 |
|
72 |
return toc_html
|
73 |
|
74 |
-
|
75 |
def section_to_html(section_json_data):
|
76 |
formatted_section = ""
|
77 |
|
@@ -132,6 +131,7 @@ def get_result_as_html(chapters, video_id):
|
|
132 |
|
133 |
result_as_html = f"""
|
134 |
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
|
135 |
<div class="container mt-4">
|
136 |
<div class="content">
|
137 |
{video_embed}
|
@@ -144,7 +144,9 @@ def get_result_as_html(chapters, video_id):
|
|
144 |
<div class="content">
|
145 |
{edited_transcript}
|
146 |
</div>
|
147 |
-
</div>
|
|
|
|
|
148 |
|
149 |
return result_as_html
|
150 |
|
|
|
71 |
|
72 |
return toc_html
|
73 |
|
|
|
74 |
def section_to_html(section_json_data):
|
75 |
formatted_section = ""
|
76 |
|
|
|
131 |
|
132 |
result_as_html = f"""
|
133 |
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
134 |
+
|
135 |
<div class="container mt-4">
|
136 |
<div class="content">
|
137 |
{video_embed}
|
|
|
144 |
<div class="content">
|
145 |
{edited_transcript}
|
146 |
</div>
|
147 |
+
</div>
|
148 |
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script>
|
149 |
+
"""
|
150 |
|
151 |
return result_as_html
|
152 |
|