update examples/basic_generation.py for new API

* also rename it
This commit is contained in:
rany2 2023-01-05 00:04:48 +02:00
parent f1709e7e93
commit 4a091e4859
2 changed files with 22 additions and 24 deletions

View File

@ -0,0 +1,22 @@
#!/usr/bin/env python3
"""
Basic example of edge_tts usage.
"""
import asyncio
import edge_tts
async def main():
TEXT = "Hello World!"
VOICE = "en-GB-SoniaNeural"
OUTPUT_FILE = "test.mp3"
communicate = edge_tts.Communicate(TEXT, VOICE)
await communicate.save(OUTPUT_FILE)
if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())

View File

@ -1,24 +0,0 @@
#!/usr/bin/env python3
"""
Example Python script that shows how to use edge-tts as a module
"""
import asyncio
import edge_tts
async def main():
"""
Main function
"""
TEXT = "Hello World!"
VOICE = "en-GB-SoniaNeural"
OUTPUT_FILE = "test.mp3"
communicate = edge_tts.Communicate()
with open(OUTPUT_FILE, "wb") as f:
async for i in communicate.run(TEXT, voice=VOICE):
if i[2] is not None:
f.write(i[2])
if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())