Files
aiData/TTS/T2_PlayVoice.py
HuangHai b20d15c03e 'commit'
2026-01-31 16:05:14 +08:00

49 lines
1.4 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.

# coding=utf-8
import os
import sys
# 添加项目根目录到 sys.path 以便导入 Util
root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if root_dir not in sys.path:
sys.path.append(root_dir)
from Util.AlyTtsKit import QwenTTSManager
# ======= 配置 =======
# 请在此处粘贴 T1_CloneVoice.py 生成的 Voice ID
MY_VOICE_ID = "qwen-tts-vc-guanyu-voice-20260131160431051-8e51"
# 待合成播音的文本列表
PLAY_TEXTS = [
'您好,这是利用克隆完成的声音进行的播音测试。',
'如果您能听到这段话,说明声音复刻和实时合成流程已经全部打通。',
'这种模块化的拆分让调试变得更加简单了!'
]
def main():
"""
T2: 播音测试
"""
print('[T2] 启动播音测试流程...')
if not MY_VOICE_ID or "请替换" in MY_VOICE_ID:
print('[错误] 未检测到有效的 Voice ID。')
print('请先运行 T1_CloneVoice.py 获取 ID并修改本脚本中的 MY_VOICE_ID 变量。')
return
try:
# 1. 初始化管理器
tts_manager = QwenTTSManager()
# 2. 执行播音
print(f'[系统] 正在使用 Voice ID: {MY_VOICE_ID} 进行播音...')
tts_manager.start_synthesis(MY_VOICE_ID, PLAY_TEXTS)
print('[系统] 播音测试完成。')
except Exception as e:
print(f'[错误] 播音过程中发生异常: {e}')
if __name__ == '__main__':
main()