From f1674a5d15dfee4ae5523f749a6bac351d970d00 Mon Sep 17 00:00:00 2001 From: rany Date: Sat, 5 Jun 2021 18:38:16 +0300 Subject: [PATCH] Fix example --- example/input_example.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/example/input_example.py b/example/input_example.py index f3e5d74..bda62dc 100644 --- a/example/input_example.py +++ b/example/input_example.py @@ -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__":