Spaces:
Runtime error
Runtime error
app.py
CHANGED
@@ -2,16 +2,17 @@ import gradio as gr
|
|
2 |
from gtts import gTTS
|
3 |
import json
|
4 |
|
5 |
-
def generate_dialogue(rounds
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
dialogue.append((
|
11 |
-
|
12 |
-
|
13 |
return dialogue
|
14 |
|
|
|
15 |
def main_function(rounds: int, method: str, role1: str, role2: str):
|
16 |
dialogue = generate_dialogue(rounds, method, role1, role2)
|
17 |
|
@@ -36,10 +37,10 @@ if __name__ == "__main__":
|
|
36 |
gr.Interface(
|
37 |
main_function,
|
38 |
[
|
39 |
-
gr.components.Slider(minimum=2, maximum=6, step=2,
|
40 |
-
gr.components.Dropdown(choices=["auto", "manual"], label="生成方式"),
|
41 |
-
gr.components.Textbox(
|
42 |
-
gr.components.Textbox(
|
43 |
],
|
44 |
[
|
45 |
gr.components.Chatbot(label="生成的對話"),
|
|
|
2 |
from gtts import gTTS
|
3 |
import json
|
4 |
|
5 |
+
def generate_dialogue(rounds, method, role1, role2):
|
6 |
+
# 這裡只是一個示例,你可能需要更高級的生成方式
|
7 |
+
if method == "auto":
|
8 |
+
dialogue = []
|
9 |
+
for i in range(rounds):
|
10 |
+
dialogue.append((role1 if i % 2 == 0 else role2, f"自動文本 {i+1}"))
|
11 |
+
else:
|
12 |
+
dialogue = [(role1, "手動輸入文本 1"), (role2, "手動輸入文本 2")]
|
13 |
return dialogue
|
14 |
|
15 |
+
|
16 |
def main_function(rounds: int, method: str, role1: str, role2: str):
|
17 |
dialogue = generate_dialogue(rounds, method, role1, role2)
|
18 |
|
|
|
37 |
gr.Interface(
|
38 |
main_function,
|
39 |
[
|
40 |
+
gr.components.Slider(minimum=2, maximum=6, step=2, label="對話輪數"),
|
41 |
+
gr.components.Dropdown(choices=["auto", "manual"], default="auto", label="生成方式"),
|
42 |
+
gr.components.Textbox(label="角色 1 名稱", default="A"),
|
43 |
+
gr.components.Textbox(label="角色 2 名稱", default="B"),
|
44 |
],
|
45 |
[
|
46 |
gr.components.Chatbot(label="生成的對話"),
|