Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Fix issues to enable Windows support #62

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions larynx/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,8 +618,10 @@ def _signal_handler(*_: typing.Any) -> None:
"""Signal shutdown to Hypercorn"""
shutdown_event.set()


_LOOP.add_signal_handler(signal.SIGTERM, _signal_handler)
try:
_LOOP.add_signal_handler(signal.SIGTERM, _signal_handler)
except NotImplementedError:
pass

try:
if args.pidfile:
Expand Down
15 changes: 11 additions & 4 deletions larynx/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ def download_voice(

try:
with urllib.request.urlopen(link) as response:
with tempfile.NamedTemporaryFile(mode="wb+", suffix=".tar.gz") as temp_file:
temp_file = tempfile.NamedTemporaryFile(mode="wb+", suffix=".tar.gz", delete=False)
temp_file_name = temp_file.name

try:
with tqdm(
unit="B",
unit_scale=True,
Expand All @@ -131,13 +134,13 @@ def download_voice(
pbar.update(len(chunk))
chunk = response.read(4096)

temp_file.seek(0)
temp_file.close()

# Extract
with tempfile.TemporaryDirectory() as temp_dir_str:
temp_dir = Path(temp_dir_str)
_LOGGER.debug("Extracting %s to %s", temp_file.name, temp_dir_str)
shutil.unpack_archive(temp_file.name, temp_dir_str)
_LOGGER.debug("Extracting %s to %s", temp_file_name, temp_dir_str)
shutil.unpack_archive(temp_file_name, temp_dir_str)

# Expecting <language>/<voice_name>
lang_dir = next(temp_dir.iterdir())
Expand All @@ -160,6 +163,10 @@ def download_voice(
shutil.move(str(voice_dir), str(dest_voice_dir))

return dest_voice_dir
finally:
temp_file.close()
os.remove(temp_file_name)

except HTTPError as e:
_LOGGER.exception("download_voice")
raise VoiceDownloadError(
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dataclasses-json~=0.5.0
gruut[de,es,fr,it,nl,ru,sv,sw]~=2.1.0
numpy>=1.20.0
onnxruntime>=1.6.0,<2.0
phonemes2ids~=1.0.0
phonemes2ids~=1.2.0
python-pidfile~=3.0.0
psutil~=5.8.0
quart~=0.15.0
Expand Down