Fix example

This commit is contained in:
rany 2021-06-05 18:38:16 +03:00
parent a29581479e
commit f1674a5d15

View File

@ -3,16 +3,18 @@
# Example Python script that shows how to use edge-tts as a module
import asyncio
import edgeTTS
import time
import tempfile
import edgeTTS as e
from playsound import playsound
async def main():
ask = input("What do you want TTS to say? ")
overhead = len(e.mkssmlmsg('').encode('utf-8'))
ask = e._minimize(e.escape(e.removeIncompatibleControlChars(ask)), b" ", 2**16 - overhead)
with tempfile.NamedTemporaryFile() as fp:
async for i in edgeTTS.run_tts(edgeTTS.mkssmlmsg(ask)): # default Aria, audio-24khz-48kbitrate-mono-mp3, etc..
fp.write(i)
for part in ask:
async for i in e.run_tts(e.mkssmlmsg(part.decode('utf-8'))):
fp.write(i)
playsound(fp.name)
if __name__ == "__main__":