mirror of
https://github.com/rany2/edge-tts
synced 2024-11-22 01:45:02 +00:00
fix for windows users
This commit is contained in:
parent
7d03764943
commit
393233ecf9
@ -1,6 +1,6 @@
|
||||
[metadata]
|
||||
name = edge-tts
|
||||
version = 4.0.8
|
||||
version = 4.0.9
|
||||
author = rany
|
||||
author_email = ranygh@riseup.net
|
||||
description = Microsoft Edge's TTS
|
||||
|
@ -4,6 +4,7 @@
|
||||
Playback TTS with subtitles using edge-tts and mpv.
|
||||
"""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
@ -15,31 +16,38 @@ def main():
|
||||
Main function.
|
||||
"""
|
||||
if which("mpv") and which("edge-tts"):
|
||||
with tempfile.NamedTemporaryFile() as media:
|
||||
with tempfile.NamedTemporaryFile() as subtitle:
|
||||
print()
|
||||
print(f"Media file: {media.name}")
|
||||
print(f"Subtitle file: {subtitle.name}\n")
|
||||
with subprocess.Popen(
|
||||
[
|
||||
"edge-tts",
|
||||
"--boundary-type=2",
|
||||
f"--write-media={media.name}",
|
||||
f"--write-subtitles={subtitle.name}",
|
||||
]
|
||||
+ sys.argv[1:]
|
||||
) as process:
|
||||
process.communicate()
|
||||
media = tempfile.NamedTemporaryFile(delete=False)
|
||||
subtitle = tempfile.NamedTemporaryFile(delete=False)
|
||||
try:
|
||||
media.close()
|
||||
subtitle.close()
|
||||
|
||||
with subprocess.Popen(
|
||||
[
|
||||
"mpv",
|
||||
"--keep-open=yes",
|
||||
f"--sub-file={subtitle.name}",
|
||||
media.name,
|
||||
]
|
||||
) as process:
|
||||
process.communicate()
|
||||
print()
|
||||
print(f"Media file: {media.name}")
|
||||
print(f"Subtitle file: {subtitle.name}\n")
|
||||
with subprocess.Popen(
|
||||
[
|
||||
"edge-tts",
|
||||
"--boundary-type=2",
|
||||
f"--write-media={media.name}",
|
||||
f"--write-subtitles={subtitle.name}",
|
||||
]
|
||||
+ sys.argv[1:]
|
||||
) as process:
|
||||
process.communicate()
|
||||
|
||||
with subprocess.Popen(
|
||||
[
|
||||
"mpv",
|
||||
"--keep-open=yes",
|
||||
f"--sub-file={subtitle.name}",
|
||||
media.name,
|
||||
]
|
||||
) as process:
|
||||
process.communicate()
|
||||
finally:
|
||||
os.unlink(media.name)
|
||||
os.unlink(subtitle.name)
|
||||
else:
|
||||
print("This script requires mpv and edge-tts.")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user