summary_button = gr.Button("生成摘要", visible=False)
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
# -*- coding: utf-8 -*-
|
2 |
|
|
|
3 |
import gradio as gr
|
4 |
import os
|
5 |
import shutil
|
@@ -174,6 +175,13 @@ def process_all_files(file_list):
|
|
174 |
print("\n=== 檔案處理完成 ===")
|
175 |
return result_text, transcript_text
|
176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
with gr.Blocks() as demo:
|
178 |
gr.Markdown("# AI Notes Assistant")
|
179 |
|
@@ -214,13 +222,19 @@ with gr.Blocks() as demo:
|
|
214 |
with gr.Column(visible=True) as feature_column:
|
215 |
gr.Markdown("### 功能卡片")
|
216 |
with gr.Tab("摘要生成"):
|
217 |
-
summary_button = gr.Button("生成摘要")
|
218 |
-
summary_output = gr.Markdown(
|
|
|
|
|
|
|
|
|
|
|
219 |
with gr.Tab("逐字稿"):
|
220 |
transcript_display = gr.Textbox(
|
221 |
label="YouTube 逐字稿",
|
222 |
interactive=False,
|
223 |
lines=10,
|
|
|
224 |
placeholder="處理 YouTube 影片後,逐字稿將顯示在這裡..."
|
225 |
)
|
226 |
with gr.Tab("其他功能"):
|
@@ -230,26 +244,27 @@ with gr.Blocks() as demo:
|
|
230 |
chat_toggle.change(toggle_visibility, inputs=chat_toggle, outputs=chat_column)
|
231 |
feature_toggle.change(toggle_visibility, inputs=feature_toggle, outputs=feature_column)
|
232 |
|
|
|
|
|
233 |
# 更新處理檔案按鈕的事件處理
|
234 |
process_files_button.click(
|
235 |
process_all_files,
|
236 |
inputs=[file_list],
|
237 |
outputs=[rag_result, transcript_display]
|
|
|
|
|
|
|
|
|
238 |
)
|
239 |
|
240 |
history = gr.State([])
|
241 |
ask_button.click(mock_question_answer, inputs=[question, history], outputs=[chatbot, question])
|
242 |
summary_button.click(
|
243 |
-
fn=
|
244 |
-
inputs=[transcript_display],
|
245 |
outputs=[summary_output]
|
246 |
)
|
247 |
|
248 |
-
|
249 |
-
if not transcript:
|
250 |
-
return "請先上傳文件或輸入 YouTube 連結並處理完成後再生成摘要。"
|
251 |
-
|
252 |
-
summary = generate_summary(transcript)
|
253 |
-
return summary
|
254 |
|
255 |
demo.launch(share=True)
|
|
|
1 |
# -*- coding: utf-8 -*-
|
2 |
|
3 |
+
from typing import Container
|
4 |
import gradio as gr
|
5 |
import os
|
6 |
import shutil
|
|
|
175 |
print("\n=== 檔案處理完成 ===")
|
176 |
return result_text, transcript_text
|
177 |
|
178 |
+
def on_summary_click(transcript):
|
179 |
+
if not transcript:
|
180 |
+
return "請先上傳文件或輸入 YouTube 連結並處理完成後再生成摘要。"
|
181 |
+
|
182 |
+
summary = generate_summary(transcript)
|
183 |
+
return summary
|
184 |
+
|
185 |
with gr.Blocks() as demo:
|
186 |
gr.Markdown("# AI Notes Assistant")
|
187 |
|
|
|
222 |
with gr.Column(visible=True) as feature_column:
|
223 |
gr.Markdown("### 功能卡片")
|
224 |
with gr.Tab("摘要生成"):
|
225 |
+
summary_button = gr.Button("生成摘要", visible=False)
|
226 |
+
summary_output = gr.Markdown(
|
227 |
+
label="摘要",
|
228 |
+
show_label=True,
|
229 |
+
show_copy_button=True,
|
230 |
+
container=True
|
231 |
+
)
|
232 |
with gr.Tab("逐字稿"):
|
233 |
transcript_display = gr.Textbox(
|
234 |
label="YouTube 逐字稿",
|
235 |
interactive=False,
|
236 |
lines=10,
|
237 |
+
show_copy_button=True,
|
238 |
placeholder="處理 YouTube 影片後,逐字稿將顯示在這裡..."
|
239 |
)
|
240 |
with gr.Tab("其他功能"):
|
|
|
244 |
chat_toggle.change(toggle_visibility, inputs=chat_toggle, outputs=chat_column)
|
245 |
feature_toggle.change(toggle_visibility, inputs=feature_toggle, outputs=feature_column)
|
246 |
|
247 |
+
|
248 |
+
|
249 |
# 更新處理檔案按鈕的事件處理
|
250 |
process_files_button.click(
|
251 |
process_all_files,
|
252 |
inputs=[file_list],
|
253 |
outputs=[rag_result, transcript_display]
|
254 |
+
).then(
|
255 |
+
fn=on_summary_click,
|
256 |
+
inputs=[transcript_display],
|
257 |
+
outputs=[summary_output]
|
258 |
)
|
259 |
|
260 |
history = gr.State([])
|
261 |
ask_button.click(mock_question_answer, inputs=[question, history], outputs=[chatbot, question])
|
262 |
summary_button.click(
|
263 |
+
fn=on_summary_click,
|
264 |
+
inputs=[transcript_display],
|
265 |
outputs=[summary_output]
|
266 |
)
|
267 |
|
268 |
+
|
|
|
|
|
|
|
|
|
|
|
269 |
|
270 |
demo.launch(share=True)
|