rany2 / edge-tts

Use Microsoft Edge's online text-to-speech service from Python WITHOUT needing Microsoft Edge or Windows or an API key
https://pypi.org/project/edge-tts/
GNU General Public License v3.0
4.21k stars 444 forks source link

Different performance in diff network #185

Closed picturesque-software closed 2 months ago

picturesque-software commented 4 months ago

I used clash system proxy in global and rule mode, and ran the example code. It takes almost 10s to finish. But if I ran the program without anonymous network, It takes 0.6s. I want to know why and if I can use edgetts normally in clash env.

code:

`from datetime import datetime

import edge_tts import asyncio

TEXT = "" with open('text2voicetest.txt', 'rb') as f: data = f.read() TEXT = data.decode('utf-8') print(TEXT) voice = 'zh-CN-YunxiNeural' output = 'text2voicetest.mp3' rate = '-10%' volume = '+0%'

async def my_function(): time = datetime.now() print(time) tts = edge_tts.Communicate(text=TEXT, voice=voice, rate=rate, volume=volume) await tts.save(output) print(datetime.now())

if name == 'main': asyncio.run(my_function())`

rany2 commented 2 months ago

The recent version might help with better performance on networks with high latency, if it doesn't then in all likelihood it's Microsoft throttling the service. I've observed that the Mb/s is very different depending on the network, so I assume there is a rate-limiting of sorts going on.