mirror of
https://github.com/rany2/edge-tts
synced 2024-11-22 09:56:53 +00:00
19 lines
510 B
Python
Executable File
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())
|