mirror of
https://github.com/rany2/edge-tts
synced 2024-11-22 01:45:02 +00:00
update examples/basic_generation.py for new API
* also rename it
This commit is contained in:
parent
f1709e7e93
commit
4a091e4859
22
examples/basic_generation.py
Normal file
22
examples/basic_generation.py
Normal 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())
|
@ -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())
|
Loading…
Reference in New Issue
Block a user