Spaces:
Running
Running
youtube_link.change(process_youtube_link, inputs=youtube_link, outputs=[btn_1, btn_2, btn_3, df_string_output, df_summarise, transcript_html, slide_image, slide_text])
Browse files
app.py
CHANGED
@@ -313,13 +313,18 @@ def process_youtube_link(link):
|
|
313 |
global TRANSCRIPTS
|
314 |
TRANSCRIPTS = formatted_transcript
|
315 |
|
|
|
|
|
|
|
316 |
# 确保返回与 UI 组件预期匹配的输出
|
317 |
return questions[0] if len(questions) > 0 else "", \
|
318 |
questions[1] if len(questions) > 1 else "", \
|
319 |
questions[2] if len(questions) > 2 else "", \
|
320 |
df_string_output, \
|
321 |
df_summarise, \
|
322 |
-
html_content
|
|
|
|
|
323 |
|
324 |
|
325 |
def format_transcript_to_html(formatted_transcript):
|
@@ -495,7 +500,10 @@ def update_slide(direction):
|
|
495 |
|
496 |
# 获取当前条目的文本和截图 URL
|
497 |
current_transcript = TRANSCRIPTS[CURRENT_INDEX]
|
498 |
-
|
|
|
|
|
|
|
499 |
|
500 |
def prev_slide():
|
501 |
return update_slide(-1)
|
@@ -520,13 +528,13 @@ with gr.Blocks() as demo:
|
|
520 |
with gr.Tab("截圖與逐字稿"):
|
521 |
transcript_html = gr.HTML(label="YouTube Transcript and Video")
|
522 |
with gr.Tab("投影片"):
|
523 |
-
|
524 |
-
|
525 |
with gr.Row():
|
526 |
prev_button = gr.Button("Previous")
|
527 |
next_button = gr.Button("Next")
|
528 |
-
prev_button.click(fn=prev_slide, inputs=[], outputs=[
|
529 |
-
next_button.click(fn=next_slide, inputs=[], outputs=[
|
530 |
with gr.Tab("資料本文"):
|
531 |
df_string_output = gr.Textbox(lines=40, label="Data Text")
|
532 |
with gr.Tab("資料摘要"):
|
@@ -553,7 +561,7 @@ with gr.Blocks() as demo:
|
|
553 |
file_upload.change(process_file, inputs=file_upload, outputs=[btn_1, btn_2, btn_3, df_summarise, df_string_output])
|
554 |
|
555 |
# 当输入 YouTube 链接时触发
|
556 |
-
youtube_link.change(process_youtube_link, inputs=youtube_link, outputs=[btn_1, btn_2, btn_3, df_string_output, df_summarise, transcript_html])
|
557 |
|
558 |
# 当输入网页链接时触发
|
559 |
web_link.change(process_web_link, inputs=web_link, outputs=[btn_1, btn_2, btn_3, df_summarise, df_string_output])
|
|
|
313 |
global TRANSCRIPTS
|
314 |
TRANSCRIPTS = formatted_transcript
|
315 |
|
316 |
+
first_image = formatted_transcript[0]['screenshot_path']
|
317 |
+
first_text = formatted_transcript[0]['text']
|
318 |
+
|
319 |
# 确保返回与 UI 组件预期匹配的输出
|
320 |
return questions[0] if len(questions) > 0 else "", \
|
321 |
questions[1] if len(questions) > 1 else "", \
|
322 |
questions[2] if len(questions) > 2 else "", \
|
323 |
df_string_output, \
|
324 |
df_summarise, \
|
325 |
+
html_content, \
|
326 |
+
first_image, \
|
327 |
+
first_text
|
328 |
|
329 |
|
330 |
def format_transcript_to_html(formatted_transcript):
|
|
|
500 |
|
501 |
# 获取当前条目的文本和截图 URL
|
502 |
current_transcript = TRANSCRIPTS[CURRENT_INDEX]
|
503 |
+
slide_image = current_transcript["screenshot_path"]
|
504 |
+
slide_text = current_transcript["text"]
|
505 |
+
|
506 |
+
return slide_image, slide_text
|
507 |
|
508 |
def prev_slide():
|
509 |
return update_slide(-1)
|
|
|
528 |
with gr.Tab("截圖與逐字稿"):
|
529 |
transcript_html = gr.HTML(label="YouTube Transcript and Video")
|
530 |
with gr.Tab("投影片"):
|
531 |
+
slide_image = gr.Image()
|
532 |
+
slide_text = gr.Textbox()
|
533 |
with gr.Row():
|
534 |
prev_button = gr.Button("Previous")
|
535 |
next_button = gr.Button("Next")
|
536 |
+
prev_button.click(fn=prev_slide, inputs=[], outputs=[slide_image, slide_text])
|
537 |
+
next_button.click(fn=next_slide, inputs=[], outputs=[slide_image, slide_text])
|
538 |
with gr.Tab("資料本文"):
|
539 |
df_string_output = gr.Textbox(lines=40, label="Data Text")
|
540 |
with gr.Tab("資料摘要"):
|
|
|
561 |
file_upload.change(process_file, inputs=file_upload, outputs=[btn_1, btn_2, btn_3, df_summarise, df_string_output])
|
562 |
|
563 |
# 当输入 YouTube 链接时触发
|
564 |
+
youtube_link.change(process_youtube_link, inputs=youtube_link, outputs=[btn_1, btn_2, btn_3, df_string_output, df_summarise, transcript_html, slide_image, slide_text])
|
565 |
|
566 |
# 当输入网页链接时触发
|
567 |
web_link.change(process_web_link, inputs=web_link, outputs=[btn_1, btn_2, btn_3, df_summarise, df_string_output])
|