import edge_tts
import asyncio
import random
num=random.randint(2,10000)
TEXT = ""
with open('C:\\Users\\test.txt', 'rb') as f:
data = f.read()
TEXT = data.decode('utf-8')
print(TEXT)
print('--num--{}',num)
voice = 'zh-CN-XiaoxiaoNeural'
voices = [
"zh-CN-XiaoxiaoNeural",
"zh-CN-XiaoyiNeural",
"zh-CN-YunjianNeural",
"zh-CN-YunxiNeural",
"zh-CN-YunxiaNeural",
"zh-CN-YunyangNeural",
"zh-CN-liaoning-XiaobeiNeural",
"zh-CN-shaanxi-XiaoniNeural",
"zh-HK-HiuGaaiNeural",
"zh-HK-HiuMaanNeural",
"zh-HK-WanLungNeural",
"zh-TW-HsiaoChenNeural"
]
# output = 'C:\\Users\\test'+str(num)+'.mp3'
output=''
rate = '-2%'
volume = '+2%'
async def my_function():
tts = edge_tts.Communicate(text=TEXT, voice=voice, rate=rate, volume=volume)
await tts.save(output)
async def my_function2():
ct=len(voices)
print('--ct-' + str(ct))
for i in range(ct):
print('-i--'+str(i))
voice=voices[i]
print('--voice-' + str(voice))
tts = edge_tts.Communicate(text=TEXT, voice=voice, rate=rate, volume=volume)
output = 'C:\\Users\\test' + str(voice) + '.mp3'
await tts.save(output)
#await tts.save(output)
if __name__ == '__main__':
asyncio.run(my_function2())
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
所有评论(0)