edge-tts/examples/input_example.py
2021-06-09 14:16:51 +03:00

19 lines
510 B
Python
Executable File

#!/usr/bin/env python3
# Example Python script that shows how to use edge-tts as a module
import asyncio
import tempfile
import edgeTTS
from playsound import playsound
async def main():
communicate = edgeTTS.Communicate()
ask = input("What do you want TTS to say? ")
with tempfile.NamedTemporaryFile() as fp:
async for i in communicate.run(ask):
if i[2] is not None:
fp.write(i[2])
playsound(fp.name)
if __name__ == "__main__":
asyncio.run(main())