Spaces:
Runtime error
Runtime error
app.py
CHANGED
@@ -11,12 +11,10 @@ def generate_dialogue(rounds, method, role1, role2):
|
|
11 |
|
12 |
def main_function(rounds: int, method: str, role1: str, role2: str):
|
13 |
structured_dialogue = generate_dialogue(rounds, method, role1, role2)
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
audio_path = dialogue_to_audio([(item["role"], item["content"]) for item in structured_dialogue])
|
18 |
json_output = json.dumps({"dialogue": structured_dialogue}, ensure_ascii=False, indent=4)
|
19 |
-
|
20 |
# 儲存對話為 JSON 文件
|
21 |
file_name = "dialogue_output.txt"
|
22 |
with open(file_name, "w", encoding="utf-8") as f:
|
@@ -36,12 +34,12 @@ if __name__ == "__main__":
|
|
36 |
main_function,
|
37 |
[
|
38 |
gr.components.Slider(minimum=2, maximum=6, step=2, label="對話輪數"),
|
39 |
-
gr.components.Dropdown(choices=["auto", "manual"],
|
40 |
-
gr.components.Textbox(label="角色 1 名稱"
|
41 |
-
gr.components.Textbox(label="角色 2 名稱"
|
42 |
],
|
43 |
[
|
44 |
-
gr.components.Chatbot(
|
45 |
gr.components.Audio(type="filepath", label="對話朗讀"),
|
46 |
gr.components.File(label="下載對話 JSON 文件")
|
47 |
]
|
|
|
11 |
|
12 |
def main_function(rounds: int, method: str, role1: str, role2: str):
|
13 |
structured_dialogue = generate_dialogue(rounds, method, role1, role2)
|
14 |
+
chatbot_dialogue = structured_dialogue
|
15 |
+
audio_path = dialogue_to_audio(structured_dialogue)
|
|
|
|
|
16 |
json_output = json.dumps({"dialogue": structured_dialogue}, ensure_ascii=False, indent=4)
|
17 |
+
|
18 |
# 儲存對話為 JSON 文件
|
19 |
file_name = "dialogue_output.txt"
|
20 |
with open(file_name, "w", encoding="utf-8") as f:
|
|
|
34 |
main_function,
|
35 |
[
|
36 |
gr.components.Slider(minimum=2, maximum=6, step=2, label="對話輪數"),
|
37 |
+
gr.components.Dropdown(choices=["auto", "manual"], label="生成方式"),
|
38 |
+
gr.components.Textbox(label="角色 1 名稱"),
|
39 |
+
gr.components.Textbox(label="角色 2 名稱"),
|
40 |
],
|
41 |
[
|
42 |
+
gr.components.Chatbot(label="生成的對話"),
|
43 |
gr.components.Audio(type="filepath", label="對話朗讀"),
|
44 |
gr.components.File(label="下載對話 JSON 文件")
|
45 |
]
|