diff --git a/.gitignore b/.gitignore index 47a8817..1cdf84d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ !setup.cfg !setup.py !pyproject.toml +!src/ !src/edgeTTS/__init__.py !src/edgePlayback/ !src/edgePlayback/__init__.py diff --git a/src/edgePlayback/__init__.py b/src/edgePlayback/__init__.py new file mode 100755 index 0000000..9973f04 --- /dev/null +++ b/src/edgePlayback/__init__.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +import sys +import tempfile +import subprocess +from shutil import which + +def main(): + if which('mpv') and which('edge-tts'): + with tempfile.NamedTemporaryFile() as media: + with tempfile.NamedTemporaryFile() as subtitle: + print ("Media file: %s" % media.name) + print ("Subtitle file: %s" % subtitle.name) + p = subprocess.Popen(['edge-tts', '-w'] + sys.argv[1:], stdout=media, stderr=subtitle) + p.communicate() + p = subprocess.Popen(['mpv', '--keep-open=yes', '--sub-file=' + subtitle.name, media.name]) + p.communicate() + else: + print ("This script requires mpv and edge-tts.") + +if __name__ == "__main__": + main()