diff --git a/examples/basic_generation.py b/examples/basic_generation.py new file mode 100644 index 0000000..844513d --- /dev/null +++ b/examples/basic_generation.py @@ -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()) diff --git a/examples/example.py b/examples/example.py deleted file mode 100644 index 14ce848..0000000 --- a/examples/example.py +++ /dev/null @@ -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()) \ No newline at end of file