import os

vd = 'voices'
files = sorted([f for f in os.listdir(vd) if f.endswith('.mp3')])
nm = {f.replace('.mp3',''): f.replace('.mp3','') for f in files}  # 简洁: voice名=文件名

total_size = sum(os.path.getsize(os.path.join(vd, f)) for f in files)

lines = ['# CosyVoice v3-flash 音色样本\n']
lines.append(f'\n共 **{len(files)}** 个音色 | 总大小 **{total_size/1024/1024:.1f} MB** | 阿里云百炼 API\n\n')
lines.append('| # | voice参数 | 文件 |\n')
lines.append('|---|----------|------|\n')
for i, f in enumerate(files):
    voice = f.replace('.mp3', '')
    lines.append(f'| {i+1} | `{voice}` | [{f}]({f}) |\n')

with open(os.path.join(vd, 'INDEX.md'), 'w', encoding='utf-8') as fp:
    fp.writelines(lines)
print(f'✅ {vd}/INDEX.md 已生成, {len(files)} 个音色')
