edge-tts/examples/input_example.py

19 lines
510 B
Python
Raw Normal View History

2021-06-05 14:29:16 +00:00
#!/usr/bin/env python3
# Example Python script that shows how to use edge-tts as a module
import asyncio
import tempfile
2021-06-08 15:46:08 +00:00
import edgeTTS
2021-06-05 14:29:16 +00:00
from playsound import playsound
async def main():
2021-06-09 11:16:51 +00:00
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)
2021-06-05 14:29:16 +00:00
if __name__ == "__main__":
2021-06-09 11:16:51 +00:00
asyncio.run(main())