iewniy commited on
Commit
08ea547
·
verified ·
1 Parent(s): ea75923

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py CHANGED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import random
3
+
4
+ # 定義一個簡單的函數來生成題目
5
+ def generate_questions(video_url):
6
+ questions = []
7
+ for i in range(10):
8
+ questions.append(f"問題 {i+1} 圍繞這個影片({video_url})的某個重要點")
9
+ return questions
10
+
11
+ # 使用 Gradio 建立界面
12
+ def interface():
13
+ with gr.Blocks() as demo:
14
+ gr.Markdown("## 影片習題產生器")
15
+
16
+ # 輸入影片連結
17
+ video_url = gr.Textbox(label="影片連結")
18
+
19
+ # 生成題目按鈕
20
+ generate_btn = gr.Button("生成題目")
21
+
22
+ # 顯示生成的題目
23
+ questions_output = gr.Textbox(label="生成的題目", lines=10)
24
+
25
+ # 點擊按鈕時,生成題目
26
+ generate_btn.click(fn=generate_questions, inputs=video_url, outputs=questions_output)
27
+
28
+ return demo
29
+
30
+ # 運行 Gradio 應用
31
+ demo = interface()
32
+ demo.launch()