Update to edge-tts 4.0.0

This commit is contained in:
rany
2021-12-07 22:09:43 +02:00
parent 756766fe6e
commit 4fcecddaf0
16 changed files with 207 additions and 101 deletions

View File

@@ -0,0 +1,50 @@
#!/usr/bin/env python3
"""
Playback TTS with subtitles using edge-tts and mpv.
"""
import subprocess
import sys
import tempfile
from shutil import which
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",
"-w",
"--write-media",
media.name,
"--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()
else:
print("This script requires mpv and edge-tts.")
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,10 @@
#!/usr/bin/env python3
"""
This is the main file for the edge_playback package.
"""
from edge_playback.__init__ import main
if __name__ == "__main__":
main()