Axelottle commited on
Commit
879e354
·
1 Parent(s): 4bca212

Add examples, add percentage description

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -225,6 +225,9 @@ def summarize_text(url, percent):
225
  yt = YouTube(url)
226
  video_html = f'<div id="video-container" style="position: relative; width: 100%; padding-bottom: 56.25%;"><iframe id="video" style="position: absolute; width: 100%; height: 100%;" src="{yt.embed_url}" frameborder="0" allowfullscreen></iframe></div>'
227
 
 
 
 
228
  return summary, video_html
229
 
230
  """## Text-to-Speech Module"""
@@ -289,13 +292,14 @@ with gr.Blocks(theme=theme) as demo:
289
  with gr.Column():
290
  fn = summarize_text
291
  url_input = gr.Textbox(label="URL", placeholder="Ex: https://youtu.be/JOiGEI9pQBs", info="Input YouTube URL")
292
- slider = gr.Slider(5, 100, value=20, step=5, label="Percent", info="Choose summary length")
293
 
294
  with gr.Row():
295
  summarize_btn = gr.Button(variant="primary", value="Summarize")
296
  clear_btn = gr.ClearButton()
297
 
298
  video_preview = gr.HTML(label="Video Preview")
 
299
 
300
  with gr.Column():
301
  summary_output = gr.Textbox(label="Summary", interactive=False, show_copy_button=True)
 
225
  yt = YouTube(url)
226
  video_html = f'<div id="video-container" style="position: relative; width: 100%; padding-bottom: 56.25%;"><iframe id="video" style="position: absolute; width: 100%; height: 100%;" src="{yt.embed_url}" frameborder="0" allowfullscreen></iframe></div>'
227
 
228
+ if summary == "":
229
+ raise gr.Error(f"Could not retrieve the video's transcript. Please try another video")
230
+
231
  return summary, video_html
232
 
233
  """## Text-to-Speech Module"""
 
292
  with gr.Column():
293
  fn = summarize_text
294
  url_input = gr.Textbox(label="URL", placeholder="Ex: https://youtu.be/JOiGEI9pQBs", info="Input YouTube URL")
295
+ slider = gr.Slider(5, 100, value=20, step=5, label="Percent", info="Choose summary length (the lower the number, the shorter the summary)")
296
 
297
  with gr.Row():
298
  summarize_btn = gr.Button(variant="primary", value="Summarize")
299
  clear_btn = gr.ClearButton()
300
 
301
  video_preview = gr.HTML(label="Video Preview")
302
+ examples = gr.Examples([['https://youtu.be/libKVRa01L8'], ['https://youtu.be/v6Agqm4K7Ok'], ['https://youtu.be/HpcTJW4ur54'], ['https://youtu.be/gjVX47dLlN8']], inputs=url_input)
303
 
304
  with gr.Column():
305
  summary_output = gr.Textbox(label="Summary", interactive=False, show_copy_button=True)