Commit History

refactor
d400299

youngtsai commited on

json_textbox = gr.Textbox(readonly=True, label="對話 JSON 內容", lines=10)
cc31c5b

youngtsai commited on

demo.launch(inline=False, share=True)
eee5af3

youngtsai commited on

with gr.Blocks(theme="light") as demo: # 使用 'light' 主题作为默认值
8d56c8c

youngtsai commited on

layout = gr.Row(
50c9cb2

youngtsai commited on

layout="1:3" # 新增這一行
833774e

youngtsai commited on

readonly=True, label="對話 JSON 內容", lines=10
3dae297

youngtsai commited on

prompt = f"您將進行一場以{theme}為主題的對話。{role1} (gender: {role1_gender}) 和{role2} (gender: {role2_gender})將是參與者。請依次交談{rounds}輪。(1輪對話的定義是 {role1} 和 {role2} 各說一句話,總共 {sentenses_count} 句話。)以json格式儲存對話。並回傳對話JSON文件。格式為:[{{role:\"{role1}\", \"gender\": {role1_gender} , content: \".....\"}}, {{role:\"{role2}\", \"gender\": {role2_gender}, content: \".....\"}}]"
f4819db

youngtsai commited on

delete audio
d4dc5f0

youngtsai commited on

def detect_language(text):
635f86b

youngtsai commited on

azure-cognitiveservices-speech
dc702e1

youngtsai commited on

speech_config = speechsdk.SpeechConfig(subscription=AZURE_API_KEY, region=AZURE_REGION)
16e04ca

youngtsai commited on

import pyttsx3
7fac4f2

youngtsai commited on

engine = pyttsx3.init()
8d75709

youngtsai commited on

audio_path = dialogue_to_audio(structured_dialogue, role1_gender, role2_gender)
89c580c

youngtsai commited on

def dialogue_to_audio(dialogue, role1_gender, role2_gender):
a2e3e4d

youngtsai commited on

def main_function(password: str, theme: str, language: str, method: str, rounds: int, role1: str, role1_gender: str, role2: str, role2_gender: str):
71cee5c

youngtsai commited on

def main_function(password: str, theme: str, language: str, method: str, rounds: int, role1_data: tuple, role2_data: tuple):
6ac85f0

youngtsai commited on

text = " ".join([f"{item['content']}" for item in dialogue])
cb575a5

youngtsai commited on

role1_content = f"{structured_dialogue[i]['content']}"
cb56cc7

youngtsai commited on

dialogue = create_chat_dialogue(rounds, role1, role2, theme, language)
46d0709

youngtsai commited on

def create_chat_dialogue(rounds, role1, role2, theme, language):
a48f81b

youngtsai commited on

gr.components.Dropdown(choices=["中文", "英文"], label="語言"),
acdf0a8

youngtsai commited on

import gradio as gr
1f9274c

youngtsai commited on

prompt = f"您將進行一場以{theme}為主題的對話。{role1}和{role2}將是參與者。請依次交談{rounds}輪。(1輪對話的定義是 {role1} 和 {role2} 各說一句話。)以json格式儲存對話。並回傳對話JSON文件。格式為:[{{role:\"{role1}\", content: \".....\"}}, {{role:\"{role2}\", content: \".....\"}}]"
e3ecbca

youngtsai commited on

sys_content = f"你是一個英文家教,請用英文生成對話,請嚴格控制 {rounds} 輪對話的長度。 1輪對話的定義是 {role1} 和 {role2} 各說一句話。"
fc2ceb8

youngtsai commited on

sys_content = f"你是一個英文家教,請用英文生成對話,請嚴格控制 {rounds} 輪對話的長度。"
c62c781

youngtsai commited on

prompt = f"您將進行一場以{theme}為主題的對話。{role1}和{role2}將是參與者。請依次交談{rounds}輪。以json格式儲存對話。並回傳對話JSON文件。格式為:[{{role:\"{role1}\", content: \".....\"}}, {{role:\"{role2}\", content: \".....\"}}]"
1e259ff

youngtsai commited on

dialogue = validate_and_correct_chat(data=extract_json, roles=[role1, role2], rounds=rounds)
c17ed50

youngtsai commited on

roles = [role1, role2]
c2cda0e

youngtsai commited on

dialogue = validate_and_correct_chat(extract_json, roles=[role1, role2], rounds)
3f9e47f

youngtsai commited on

prompt = f"您將進行一場以{theme}為主題的對話。{role1}和{role2}將是參與者。請依次交談{rounds}輪。以json格式儲存對話。並回傳對話JSON文件。格式為:[{{role1:\"{role1}\", content: \".....\"}}, {{role2:\"{role2}\", content: \".....\"}}]"
500d500

youngtsai commited on

print(messages)
6deb073

youngtsai commited on

def generate_dialogue(rounds, method, role1, role2, theme):
318fe60

youngtsai commited on

def generate_dialogue(rounds=2, method="auto", role1="Mary", role2="Ken", theme="購物"):
af62096

youngtsai commited on

def main_function(password: str, theme: str, method: str, rounds: int, role1: str, role2: str):
06479e1

youngtsai commited on

max_tokens=int(500 * int(rounds)) # 設定一個較大的值,可根據需要調整
4896256

youngtsai commited on

max_tokens=500 * rounds # 設定一個較大的值,可根據需要調整
0ff0132

youngtsai commited on

ne desult
d335288

youngtsai commited on

gr.components.Textbox(label="角色 2 名稱", default="Alex"),
005e338

youngtsai commited on

main_function,
bd1aa67

youngtsai commited on

sys_content = f"你是一個英文家教,請用英文生成對話"
77a2db1

youngtsai commited on

gr.components.Textbox(label="對話主題", default="購物"), # 加入 theme 的輸入框,設定預設值為 '購物'
25e4cb4

youngtsai commited on

response = openai.ChatCompletion.create(
61cea89

youngtsai commited on

def extract_json_from_response(response_text):
b90df65

youngtsai commited on

create_chat_dialogue
bc52e2a

youngtsai commited on

def generate_dialogue_with_openai(rounds, role1, role2):
523f3ec

youngtsai commited on

response = openai.Completion.create(
8109133

youngtsai commited on

def main_function(password: str, rounds: int, method: str, role1: str, role2: str):
1e07170

youngtsai commited on