Fix example
This commit is contained in:
@@ -3,16 +3,18 @@
|
|||||||
# Example Python script that shows how to use edge-tts as a module
|
# Example Python script that shows how to use edge-tts as a module
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import edgeTTS
|
|
||||||
import time
|
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import edgeTTS as e
|
||||||
from playsound import playsound
|
from playsound import playsound
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
ask = input("What do you want TTS to say? ")
|
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:
|
with tempfile.NamedTemporaryFile() as fp:
|
||||||
async for i in edgeTTS.run_tts(edgeTTS.mkssmlmsg(ask)): # default Aria, audio-24khz-48kbitrate-mono-mp3, etc..
|
for part in ask:
|
||||||
fp.write(i)
|
async for i in e.run_tts(e.mkssmlmsg(part.decode('utf-8'))):
|
||||||
|
fp.write(i)
|
||||||
playsound(fp.name)
|
playsound(fp.name)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user