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

46 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
# ======= 配置 =======
# 用于声音复刻的音频文件
VOICE_FILE_PATH = os.path.join(os.path.dirname(__file__), "少惠林.wav")
def main():
"""
T1: 声音复刻 (克隆)
"""
print('[T1] 启动声音复刻流程...')
if not os.path.exists(VOICE_FILE_PATH):
print(f'[错误] 找不到录音文件: {VOICE_FILE_PATH}')
print('请确保该目录下存在用于复刻的 wav 文件。')
return
try:
# 1. 初始化管理器
tts_manager = QwenTTSManager()
# 2. 执行复刻
print(f'[系统] 正在上传并复刻音频: {os.path.basename(VOICE_FILE_PATH)} ...')
voice_id = tts_manager.create_voice_enrollment(VOICE_FILE_PATH)
print('\n' + '='*50)
print(f' 声音复刻成功!')
print(f' Voice ID: {voice_id}')
print('='*50)
print('\n请复制上面的 Voice ID用于 T2_PlayVoice.py 进行播音测试。')
except Exception as e:
print(f'[错误] 复刻过程中发生异常: {e}')
if __name__ == '__main__':
main()