fix for windows users
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = edge-tts
|
name = edge-tts
|
||||||
version = 4.0.8
|
version = 4.0.9
|
||||||
author = rany
|
author = rany
|
||||||
author_email = ranygh@riseup.net
|
author_email = ranygh@riseup.net
|
||||||
description = Microsoft Edge's TTS
|
description = Microsoft Edge's TTS
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
Playback TTS with subtitles using edge-tts and mpv.
|
Playback TTS with subtitles using edge-tts and mpv.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
@@ -15,31 +16,38 @@ def main():
|
|||||||
Main function.
|
Main function.
|
||||||
"""
|
"""
|
||||||
if which("mpv") and which("edge-tts"):
|
if which("mpv") and which("edge-tts"):
|
||||||
with tempfile.NamedTemporaryFile() as media:
|
media = tempfile.NamedTemporaryFile(delete=False)
|
||||||
with tempfile.NamedTemporaryFile() as subtitle:
|
subtitle = tempfile.NamedTemporaryFile(delete=False)
|
||||||
print()
|
try:
|
||||||
print(f"Media file: {media.name}")
|
media.close()
|
||||||
print(f"Subtitle file: {subtitle.name}\n")
|
subtitle.close()
|
||||||
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(
|
print()
|
||||||
[
|
print(f"Media file: {media.name}")
|
||||||
"mpv",
|
print(f"Subtitle file: {subtitle.name}\n")
|
||||||
"--keep-open=yes",
|
with subprocess.Popen(
|
||||||
f"--sub-file={subtitle.name}",
|
[
|
||||||
media.name,
|
"edge-tts",
|
||||||
]
|
"--boundary-type=2",
|
||||||
) as process:
|
f"--write-media={media.name}",
|
||||||
process.communicate()
|
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:
|
else:
|
||||||
print("This script requires mpv and edge-tts.")
|
print("This script requires mpv and edge-tts.")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user