Fixes
This commit is contained in:
21
examples/input_example.py
Normal file
21
examples/input_example.py
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Example Python script that shows how to use edge-tts as a module
|
||||
|
||||
import asyncio
|
||||
import tempfile
|
||||
import edgeTTS as e
|
||||
from playsound import playsound
|
||||
|
||||
async def main():
|
||||
ask = input("What do you want TTS to say? ")
|
||||
overhead = len(e.mkssmlmsg('').encode('utf-8'))
|
||||
ask = e._minimize(e.escape(e.removeIncompatibleControlChars(ask)), b" ", 2**16 - overhead)
|
||||
with tempfile.NamedTemporaryFile() as fp:
|
||||
for part in ask:
|
||||
async for i in e.run_tts(e.mkssmlmsg(part.decode('utf-8'))):
|
||||
fp.write(i)
|
||||
playsound(fp.name)
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user