Files
tts/scripts/final_initialize_characters.py
2026-01-19 10:27:41 +08:00

113 lines
3.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
播客角色初始化脚本
根据 chapter8.md 文件中的角色定义进行初始化
"""
import os
from datetime import datetime
def initialize_characters():
"""初始化所有角色"""
print("=== 播客角色初始化 ===")
print(f"时间: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
print()
# 定义所有角色
characters = [
{
"name": "Host",
"role": "主持人",
"full_name": "Sonia",
"accent": "冷静、客观、甚至带点冷幽默",
"voice_recommendation": "Edge TTS 的 en-GB-RyanNeural或 en-US-JennyNeural"
},
{
"name": "Graham",
"role": "硅谷",
"full_name": "Graham",
"accent": "典型的 American Tech Bro语速快自信",
"voice_recommendation": "Edge TTS 的 en-US-GuyNeural 或 en-US-ChristopherNeural"
},
{
"name": "Dmitri",
"role": "俄罗斯",
"full_name": "Dmitri",
"accent": "深沉,重音在后",
"voice_recommendation": "en-IE-ConnorNeural爱尔兰音稍微带点卷舌和厚重感"
},
{
"name": "Amita",
"role": "印度",
"full_name": "Amita",
"accent": "语速快,清晰的印度口音",
"voice_recommendation": "en-IN-NeerjaNeural或 en-IN-PrabhatNeural"
},
{
"name": "穆罕默德",
"role": "中东",
"full_name": "穆罕默德",
"accent": "沧桑,缓慢",
"voice_recommendation": "en-EG-SalmaNeural埃及英语"
},
{
"name": "Author",
"role": "作者",
"full_name": "Author",
"accent": "分析性,权威性",
"voice_recommendation": "en-US-GuyNeural"
}
]
print(f"找到 {len(characters)} 个角色:")
print()
# 创建角色目录
os.makedirs("output/characters", exist_ok=True)
for i, char in enumerate(characters, 1):
print(f"{i}. {char['name']} ({char['role']})")
print(f" 全名: {char['full_name']}")
print(f" 风格: {char['accent']}")
print(f" 推荐语音: {char['voice_recommendation']}")
print()
# 创建角色配置文件
config_content = f"""角色配置文件
名称: {char['name']}
角色: {char['role']}
全名: {char['full_name']}
风格: {char['accent']}
推荐语音: {char['voice_recommendation']}
初始化时间: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
状态: 已初始化
"""
config_path = f"output/characters/{char['name'].lower()}_config.txt"
with open(config_path, 'w', encoding='utf-8') as f:
f.write(config_content)
print(f"✓ 所有 {len(characters)} 个角色已初始化完成")
print(f"✓ 配置文件已保存到 output/characters/ 目录")
# 创建总体角色清单
summary_path = "output/characters/character_summary.txt"
with open(summary_path, 'w', encoding='utf-8') as f:
f.write("播客角色清单\n")
f.write("=" * 50 + "\n")
f.write(f"生成时间: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n\n")
for i, char in enumerate(characters, 1):
f.write(f"{i}. {char['name']} ({char['role']})\n")
f.write(f" 全名: {char['full_name']}\n")
f.write(f" 风格: {char['accent']}\n")
f.write(f" 推荐语音: {char['voice_recommendation']}\n\n")
print(f"✓ 角色清单已保存到: {summary_path}")
# 特别强调不使用Judy
print("\n⚠️ 注意: 根据要求播客中不使用Judy作为主持人")
return characters
if __name__ == "__main__":
initialize_characters()