Fix: pyopenjtalk_worker not working

This commit is contained in:
tsukumi
2024-03-08 09:21:09 +00:00
parent df68771651
commit 766699e812
2 changed files with 4 additions and 4 deletions

View File

@@ -56,7 +56,6 @@ def initialize(port: int = WORKER_PORT) -> None:
import sys
import time
logger.debug("initialize")
global WORKER_CLIENT
if WORKER_CLIENT:
return
@@ -98,6 +97,7 @@ def initialize(port: int = WORKER_PORT) -> None:
if count == 20:
raise TimeoutError("サーバーに接続できませんでした")
logger.debug("pyopenjtalk worker server started")
WORKER_CLIENT = client
atexit.register(terminate)
@@ -110,7 +110,7 @@ def initialize(port: int = WORKER_PORT) -> None:
# top-level declaration
def terminate() -> None:
logger.debug("terminate")
logger.debug("pyopenjtalk worker server terminated")
global WORKER_CLIENT
if not WORKER_CLIENT:
return

View File

@@ -16,7 +16,7 @@ from style_bert_vits2.nlp.japanese.pyopenjtalk_worker.worker_common import (
# To make it as fast as possible
# Probably faster than calling getattr every time
__PYOPENJTALK_FUNC_DICT = {
PYOPENJTALK_FUNC_DICT = {
"run_frontend": pyopenjtalk.run_frontend,
"make_label": pyopenjtalk.make_label,
"mecab_dict_index": pyopenjtalk.mecab_dict_index,
@@ -57,7 +57,7 @@ class WorkerServer:
elif request_type == RequestType.PYOPENJTALK:
func_name = request.get("func")
assert isinstance(func_name, str)
func = __PYOPENJTALK_FUNC_DICT[func_name]
func = PYOPENJTALK_FUNC_DICT[func_name]
args = request.get("args")
kwargs = request.get("kwargs")
assert isinstance(args, list)