Major update
This commit is contained in:
11
examples/input_example.py
Normal file → Executable file
11
examples/input_example.py
Normal file → Executable file
@@ -2,17 +2,16 @@
|
||||
# Example Python script that shows how to use edge-tts as a module
|
||||
import asyncio
|
||||
import tempfile
|
||||
import edgeTTS as e
|
||||
import edgeTTS
|
||||
from playsound import playsound
|
||||
|
||||
async def main():
|
||||
communicate = edgeTTS.Communicate()
|
||||
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:
|
||||
for part in ask:
|
||||
async for i in e.run_tts(e.mkssmlmsg(part.decode('utf-8'))):
|
||||
fp.write(i)
|
||||
async for i in communicate.run(ask):
|
||||
if i[2] is not None:
|
||||
fp.write(i[2])
|
||||
playsound(fp.name)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user