mirror of
https://github.com/rany2/edge-tts
synced 2024-11-22 01:45:02 +00:00
Use subprocess instead of bash
This commit is contained in:
parent
8f99d916c5
commit
6a1d991dd7
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,6 +6,7 @@
|
||||
!setup.cfg
|
||||
!setup.py
|
||||
!pyproject.toml
|
||||
!src/
|
||||
!src/edgeTTS/__init__.py
|
||||
!src/edgePlayback/
|
||||
!src/edgePlayback/__init__.py
|
||||
|
21
src/edgePlayback/__init__.py
Executable file
21
src/edgePlayback/__init__.py
Executable file
@ -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()
|
Loading…
Reference in New Issue
Block a user