Upload app.py
Browse files
app.py
CHANGED
@@ -40,6 +40,12 @@ VOICE_OPTIONS = [
|
|
40 |
{"id": "zh-TW-YunJheNeural", "name": "雲哲(湾湾男声)"},
|
41 |
{"id": "zh-TW-HsiaoYuNeural", "name": "曉雨(湾湾女声)"},
|
42 |
{"id": "zh-CN-shaanxi-XiaoniNeural", "name": "晓妮(陕西女声)"},
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
]
|
44 |
|
45 |
def get_api_key(key_name, ui_value):
|
@@ -166,6 +172,7 @@ def process_inputs(
|
|
166 |
'question': tts_openai_question,
|
167 |
'answer': tts_openai_answer
|
168 |
},
|
|
|
169 |
},
|
170 |
},
|
171 |
}
|
@@ -337,13 +344,13 @@ with gr.Blocks(
|
|
337 |
value=2000,
|
338 |
step=100,
|
339 |
label="字数统计",
|
340 |
-
info="
|
341 |
)
|
342 |
|
343 |
conversation_style = gr.Textbox(
|
344 |
label="对话风格",
|
345 |
value="engaging,fast-paced,enthusiastic",
|
346 |
-
info="
|
347 |
)
|
348 |
|
349 |
# Roles and Structure
|
@@ -357,25 +364,34 @@ with gr.Blocks(
|
|
357 |
roles_person1 = gr.Textbox(
|
358 |
label="第一位发言者的角色",
|
359 |
value="main summarizer",
|
360 |
-
info="
|
361 |
)
|
362 |
|
363 |
roles_person2 = gr.Textbox(
|
364 |
label="第二位发言者的角色",
|
365 |
value="questioner/clarifier",
|
366 |
-
info="
|
367 |
)
|
368 |
|
369 |
dialogue_structure = gr.Textbox(
|
370 |
label="对话结构",
|
371 |
value="Introduction,Main Content Summary,Conclusion",
|
372 |
-
info="
|
373 |
)
|
374 |
|
375 |
engagement_techniques = gr.Textbox(
|
376 |
label="沟通技巧",
|
377 |
value="rhetorical questions,anecdotes,analogies,humor",
|
378 |
-
info="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
379 |
)
|
380 |
|
381 |
# Podcast Identity
|
@@ -404,24 +420,12 @@ with gr.Blocks(
|
|
404 |
info="播客使用的语言"
|
405 |
)
|
406 |
|
407 |
-
api_key_label = gr.Textbox(
|
408 |
-
label="自定义基于云的 LLM",
|
409 |
-
value="GEMINI_API_KEY",
|
410 |
-
info="可选,默认使用 Gemini,如使用 OPENAI,上面填入 'OPENAI_API_KEY' 并保证设置好环境变量且设置好下面的模型"
|
411 |
-
)
|
412 |
-
|
413 |
-
llm_model_name = gr.Textbox(
|
414 |
-
label="设置好对应自定义基于云的 LLM 模型",
|
415 |
-
value="gemini-1.5-pro-latest",
|
416 |
-
info="可选,配合上面的参数,默认是 Gemini 的 gemini-1.5-pro-latest,默认 OPENAI 可支持模型 api.168369.xyz/v1/models 获取"
|
417 |
-
)
|
418 |
-
|
419 |
longform = gr.Checkbox(
|
420 |
label="长篇模式",
|
421 |
value=False,
|
422 |
info="启���长篇内容生成模式"
|
423 |
)
|
424 |
-
|
425 |
# Voice Settings
|
426 |
gr.Markdown(
|
427 |
"""
|
@@ -443,13 +447,13 @@ with gr.Blocks(
|
|
443 |
)
|
444 |
tts_openai_question = gr.Dropdown(
|
445 |
choices=[voice["name"] for voice in VOICE_OPTIONS],
|
446 |
-
value=VOICE_OPTIONS[
|
447 |
label="OpenAI TTS 主持人",
|
448 |
info="选择OpenAI TTS 主持人角色语音"
|
449 |
)
|
450 |
tts_openai_answer = gr.Dropdown(
|
451 |
choices=[voice["name"] for voice in VOICE_OPTIONS],
|
452 |
-
value=VOICE_OPTIONS[
|
453 |
label="OpenAI TTS 嘉宾",
|
454 |
info="选择OpenAI TTS 嘉宾角色语音"
|
455 |
)
|
@@ -462,14 +466,6 @@ with gr.Blocks(
|
|
462 |
</h3>
|
463 |
""",
|
464 |
)
|
465 |
-
creativity_level = gr.Slider(
|
466 |
-
minimum=0,
|
467 |
-
maximum=1,
|
468 |
-
value=0.7,
|
469 |
-
step=0.1,
|
470 |
-
label="创意等级",
|
471 |
-
info="调节生成对话的创意程度(0 为注重事实,1 为更具创意)"
|
472 |
-
)
|
473 |
|
474 |
user_instructions = gr.Textbox(
|
475 |
label="个性化指令",
|
@@ -478,6 +474,18 @@ with gr.Blocks(
|
|
478 |
placeholder="在此处添加你希望AI遵循的具体指令,以控制对话的走向和内容...",
|
479 |
info="一些额外的指令,用来帮助AI更好地理解你想要聊天的内容和方向"
|
480 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
481 |
|
482 |
# Output Section
|
483 |
gr.Markdown(
|
|
|
40 |
{"id": "zh-TW-YunJheNeural", "name": "雲哲(湾湾男声)"},
|
41 |
{"id": "zh-TW-HsiaoYuNeural", "name": "曉雨(湾湾女声)"},
|
42 |
{"id": "zh-CN-shaanxi-XiaoniNeural", "name": "晓妮(陕西女声)"},
|
43 |
+
{"id": "alloy", "name": "alloy(用于官方)"},
|
44 |
+
{"id": "echo", "name": "echo"},
|
45 |
+
{"id": "fable", "name": "fable"},
|
46 |
+
{"id": "onyx", "name": "onyx"},
|
47 |
+
{"id": "nova", "name": "nova"},
|
48 |
+
{"id": "shimmer", "name": "shimmer"},
|
49 |
]
|
50 |
|
51 |
def get_api_key(key_name, ui_value):
|
|
|
172 |
'question': tts_openai_question,
|
173 |
'answer': tts_openai_answer
|
174 |
},
|
175 |
+
"model": "tts-1",
|
176 |
},
|
177 |
},
|
178 |
}
|
|
|
344 |
value=2000,
|
345 |
step=100,
|
346 |
label="字数统计",
|
347 |
+
info="目标字数(用于生成内容)学术辩论:3000。讲故事:1000"
|
348 |
)
|
349 |
|
350 |
conversation_style = gr.Textbox(
|
351 |
label="对话风格",
|
352 |
value="engaging,fast-paced,enthusiastic",
|
353 |
+
info="用于对话的风格列表(以逗号分隔)默认:生动活泼,节奏明快,热情洋溢。学术辩论: formal,analytical,critical;讲故事: narrative,suspenseful,descriptive"
|
354 |
)
|
355 |
|
356 |
# Roles and Structure
|
|
|
364 |
roles_person1 = gr.Textbox(
|
365 |
label="第一位发言者的角色",
|
366 |
value="main summarizer",
|
367 |
+
info="在对话中,第一个说话人扮演的角色,默认:主要负责总结的人。学术辩论: thesis presenter;讲故事: storyteller"
|
368 |
)
|
369 |
|
370 |
roles_person2 = gr.Textbox(
|
371 |
label="第二位发言者的角色",
|
372 |
value="questioner/clarifier",
|
373 |
+
info="在对话中,第二个说话人所扮演的角色或承担的任务,默认:提问者/释疑者。学术辩论: counterargument provider;讲故事: audience participator"
|
374 |
)
|
375 |
|
376 |
dialogue_structure = gr.Textbox(
|
377 |
label="对话结构",
|
378 |
value="Introduction,Main Content Summary,Conclusion",
|
379 |
+
info="对话结构的各个部分(用逗号隔开)默认:引言,主要内容的概括,总结。学术辩论: Opening Statements,Thesis Presentation,Counterarguments,Rebuttals,Closing Remarks;讲故事: Scene Setting,Character Introduction,Rising Action,Climax,Resolution"
|
380 |
)
|
381 |
|
382 |
engagement_techniques = gr.Textbox(
|
383 |
label="沟通技巧",
|
384 |
value="rhetorical questions,anecdotes,analogies,humor",
|
385 |
+
info="一些沟通和交流方式(用逗号隔开)默认:各种修辞、生动例子、形象比喻、诙谐幽默。学术辩论: socratic questioning,historical references,thought experiments;讲故事: cliffhangers,vivid imagery,audience prompts"
|
386 |
+
)
|
387 |
+
|
388 |
+
creativity_level = gr.Slider(
|
389 |
+
minimum=0,
|
390 |
+
maximum=1,
|
391 |
+
value=0.7,
|
392 |
+
step=0.1,
|
393 |
+
label="创意等级",
|
394 |
+
info="调节生成对话的创意程度(0 为注重事实,1 为更具创意)。学术辩论:0。讲故事:0.9"
|
395 |
)
|
396 |
|
397 |
# Podcast Identity
|
|
|
420 |
info="播客使用的语言"
|
421 |
)
|
422 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
423 |
longform = gr.Checkbox(
|
424 |
label="长篇模式",
|
425 |
value=False,
|
426 |
info="启���长篇内容生成模式"
|
427 |
)
|
428 |
+
|
429 |
# Voice Settings
|
430 |
gr.Markdown(
|
431 |
"""
|
|
|
447 |
)
|
448 |
tts_openai_question = gr.Dropdown(
|
449 |
choices=[voice["name"] for voice in VOICE_OPTIONS],
|
450 |
+
value=VOICE_OPTIONS[27]["name"], # 默认选择选项
|
451 |
label="OpenAI TTS 主持人",
|
452 |
info="选择OpenAI TTS 主持人角色语音"
|
453 |
)
|
454 |
tts_openai_answer = gr.Dropdown(
|
455 |
choices=[voice["name"] for voice in VOICE_OPTIONS],
|
456 |
+
value=VOICE_OPTIONS[31]["name"], # 默认选择选项
|
457 |
label="OpenAI TTS 嘉宾",
|
458 |
info="选择OpenAI TTS 嘉宾角色语音"
|
459 |
)
|
|
|
466 |
</h3>
|
467 |
""",
|
468 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
469 |
|
470 |
user_instructions = gr.Textbox(
|
471 |
label="个性化指令",
|
|
|
474 |
placeholder="在此处添加你希望AI遵循的具体指令,以控制对话的走向和内容...",
|
475 |
info="一些额外的指令,用来帮助AI更好地理解你想要聊天的内容和方向"
|
476 |
)
|
477 |
+
|
478 |
+
api_key_label = gr.Textbox(
|
479 |
+
label="自定义基于云的 LLM",
|
480 |
+
value="GEMINI_API_KEY",
|
481 |
+
info="可选,默认使用 Gemini,如使用 OPENAI,上面填入 'OPENAI_API_KEY' 并保证设置好环境变量且设置好下面的模型"
|
482 |
+
)
|
483 |
+
|
484 |
+
llm_model_name = gr.Textbox(
|
485 |
+
label="设置好对应自定义基于云的 LLM 模型",
|
486 |
+
value="gemini-1.5-pro-latest",
|
487 |
+
info="可选,配合上面的参数,默认是 Gemini 的 gemini-1.5-pro-latest,默认 OPENAI 可支持模型 api.168369.xyz/v1/models 获取"
|
488 |
+
)
|
489 |
|
490 |
# Output Section
|
491 |
gr.Markdown(
|