Spaces:
Running
Running
File size: 2,355 Bytes
e29f761 ea1af87 e29f761 3730a63 e29f761 12360eb ea1af87 12360eb ea1af87 12360eb ea1af87 12360eb ea1af87 12360eb ea1af87 12360eb ea1af87 12360eb ea1af87 12360eb 3730a63 ea1af87 12360eb ea1af87 3730a63 ea1af87 3730a63 12360eb 3730a63 ea1af87 12360eb ea1af87 12360eb ea1af87 12360eb ea1af87 12360eb ea1af87 3730a63 ea1af87 12360eb 3730a63 ea1af87 12360eb ea1af87 3730a63 ea1af87 3730a63 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
import gradio as gr
import os
import utils
example_video_id = "ErnWZxJovaM"
example_output_transcript = utils.load_transcript(example_video_id)
example_chapters = utils.load_json_chapters(example_video_id)
example_output_html = utils.get_result_as_html(example_chapters, example_video_id)
example_video_id_dict = {"MIT Introduction to Deep Learning | 6.S191 - Alexander Amini": "ErnWZxJovaM",
"dog": "b8HO6hba9ZE",
"bird": "EuC1GWhQdKE"}
example_video_names = list(example_video_id_dict.keys())
def gradio_load_example(example_video):
video_id = example_video_id_dict[example_video]
transcript_as_text = utils.load_transcript(video_id)
chapters = utils.load_json_chapters(video_id)
output_html = utils.get_result_as_html(chapters, video_id)
return {output_processing: output_html,
output_transcript: transcript_as_text}
# %%
css = """
.content {
padding: 20px;
max-width: 800px;
margin: 0 auto;
background-color: #ffffff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
border-radius: 8px;
}
"""
with (gr.Blocks(css=css) as app):
gr.HTML("<div align='center'><h1>Demo: Automatic video chaptering with LLMs and TF-IDF</h1></div>")
gr.HTML("<div align='center'><h2>From raw transcript to structured document</h2></div>")
gr.HTML("<div align='center'><h3>See the companion <a href=''>Medium article</a> and <a href=''>Github repository</a> for more details</h3>")
gr.HTML("<hr>")
#gv_transcript = gr.State()
video_id_input = gr.Dropdown(choices=example_video_names,
label="Choose a video to see the structured transcript",
value=example_video_names[0])
load_button = gr.Button("Load example")
#gv_output = gr.State()
gr.HTML("<hr>")
with gr.Accordion("See raw transcript", open=False):
output_transcript = gr.Textbox(value=example_output_transcript, max_lines=10, lines=10, label="Raw transcript")
output_processing = gr.HTML(label="Output processing", value=example_output_html)
load_button.click(gradio_load_example,
inputs=[video_id_input],
outputs=[output_processing, output_transcript])
# gr.HTML(result_as_html)
app.launch(debug=True, width="100%") |