mirror of
https://github.com/rany2/edge-tts
synced 2024-11-22 01:45:02 +00:00
Fix support for Python 3.10
Signed-off-by: rany2 <rany2@riseup.net>
This commit is contained in:
parent
0094e3b952
commit
ca6e7b0669
@ -20,7 +20,8 @@ VOICE = "en-GB-SoniaNeural"
|
||||
OUTPUT_FILE = "test.mp3"
|
||||
|
||||
|
||||
async def _main() -> None:
|
||||
async def amain() -> None:
|
||||
"""Main function"""
|
||||
communicate = edge_tts.Communicate(TEXT, VOICE)
|
||||
with open(OUTPUT_FILE, "wb") as file:
|
||||
async for chunk in communicate.stream():
|
||||
@ -31,8 +32,8 @@ async def _main() -> None:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
loop = asyncio.get_event_loop()
|
||||
loop = asyncio.get_event_loop_policy().get_event_loop()
|
||||
try:
|
||||
loop.run_until_complete(_main())
|
||||
loop.run_until_complete(amain())
|
||||
finally:
|
||||
loop.close()
|
||||
|
@ -13,14 +13,15 @@ VOICE = "en-GB-SoniaNeural"
|
||||
OUTPUT_FILE = "test.mp3"
|
||||
|
||||
|
||||
async def _main() -> None:
|
||||
async def amain() -> None:
|
||||
"""Main function"""
|
||||
communicate = edge_tts.Communicate(TEXT, VOICE)
|
||||
await communicate.save(OUTPUT_FILE)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
loop = asyncio.get_event_loop()
|
||||
loop = asyncio.get_event_loop_policy().get_event_loop()
|
||||
try:
|
||||
loop.run_until_complete(_main())
|
||||
loop.run_until_complete(amain())
|
||||
finally:
|
||||
loop.close()
|
||||
|
@ -14,7 +14,8 @@ TEXT = "Hoy es un buen día."
|
||||
OUTPUT_FILE = "spanish.mp3"
|
||||
|
||||
|
||||
async def _main() -> None:
|
||||
async def amain() -> None:
|
||||
"""Main function"""
|
||||
voices = await VoicesManager.create()
|
||||
voice = voices.find(Gender="Male", Language="es")
|
||||
# Also supports Locales
|
||||
@ -25,8 +26,8 @@ async def _main() -> None:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
loop = asyncio.get_event_loop()
|
||||
loop = asyncio.get_event_loop_policy().get_event_loop()
|
||||
try:
|
||||
loop.run_until_complete(_main())
|
||||
loop.run_until_complete(amain())
|
||||
finally:
|
||||
loop.close()
|
||||
|
@ -17,7 +17,8 @@ OUTPUT_FILE = "test.mp3"
|
||||
WEBVTT_FILE = "test.vtt"
|
||||
|
||||
|
||||
async def _main() -> None:
|
||||
async def amain() -> None:
|
||||
"""Main function"""
|
||||
communicate = edge_tts.Communicate(TEXT, VOICE)
|
||||
submaker = edge_tts.SubMaker()
|
||||
with open(OUTPUT_FILE, "wb") as file:
|
||||
@ -32,8 +33,8 @@ async def _main() -> None:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
loop = asyncio.get_event_loop()
|
||||
loop = asyncio.get_event_loop_policy().get_event_loop()
|
||||
try:
|
||||
loop.run_until_complete(_main())
|
||||
loop.run_until_complete(amain())
|
||||
finally:
|
||||
loop.close()
|
||||
|
@ -77,7 +77,8 @@ async def _run_tts(args: Any) -> None:
|
||||
sub_file.write(subs.generate_subs(args.words_in_cue))
|
||||
|
||||
|
||||
async def _async_main() -> None:
|
||||
async def amain() -> None:
|
||||
"""Async main function"""
|
||||
parser = argparse.ArgumentParser(description="Microsoft Edge TTS")
|
||||
group = parser.add_mutually_exclusive_group(required=True)
|
||||
group.add_argument("-t", "--text", help="what TTS will say")
|
||||
@ -131,9 +132,9 @@ async def _async_main() -> None:
|
||||
|
||||
def main() -> None:
|
||||
"""Run the main function using asyncio."""
|
||||
loop = asyncio.get_event_loop()
|
||||
loop = asyncio.get_event_loop_policy().get_event_loop()
|
||||
try:
|
||||
loop.run_until_complete(_async_main())
|
||||
loop.run_until_complete(amain())
|
||||
finally:
|
||||
loop.close()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user