mirror of
https://github.com/rany2/edge-tts
synced 2024-11-21 17:29:07 +00:00
Fix example
This commit is contained in:
parent
a29581479e
commit
f1674a5d15
@ -3,16 +3,18 @@
|
||||
# Example Python script that shows how to use edge-tts as a module
|
||||
|
||||
import asyncio
|
||||
import edgeTTS
|
||||
import time
|
||||
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:
|
||||
async for i in edgeTTS.run_tts(edgeTTS.mkssmlmsg(ask)): # default Aria, audio-24khz-48kbitrate-mono-mp3, etc..
|
||||
fp.write(i)
|
||||
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__":
|
||||
|
Loading…
Reference in New Issue
Block a user