fix for windows users

This commit is contained in:
rany
2022-03-13 13:25:41 +02:00
parent 7d03764943
commit 393233ecf9
2 changed files with 33 additions and 25 deletions

View File

@@ -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

View File

@@ -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,8 +16,12 @@ 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)
try:
media.close()
subtitle.close()
print() print()
print(f"Media file: {media.name}") print(f"Media file: {media.name}")
print(f"Subtitle file: {subtitle.name}\n") print(f"Subtitle file: {subtitle.name}\n")
@@ -40,6 +45,9 @@ def main():
] ]
) as process: ) as process:
process.communicate() 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.")