iTranslated by AI
Solving the pyopenjtalk_worker TimeoutError in Style-Bert-VITS2
Introduction
It's been a while since I wanted to use the model merging feature of SBV2, and when I tried to use the SBV2 web app, I encountered the situation mentioned in the title. I'm summarizing the journey to the solution as a memo.
Regarding SBV2, I have written an article on how to use it in the past, so if you want to know how to use it, please check that out.
SBV2 itself is here.
For Busy People
In short, this is it.
Author's Environment
Macbook Pro M4 Max
RAM 24GB
python 3.11.13
(Managed with uv)
Issues Encountered
TimeoutError in pyopenjtalk_worker
After setting up the environment, an error occurs when launching the web app with the following command:
python app.py
07-26 00:44:05 | DEBUG | __init__.py:92 | try starting pyopenjtalk worker server
Traceback (most recent call last):
File "/Users/02/Desktop/workspace/coding/BD/try-ai/Style-Bert-VITS2-26/style_bert_vits2/nlp/japanese/pyopenjtalk_worker/__init__.py", line 90, in initialize_worker
client = WorkerClient(port)
^^^^^^^^^^^^^^^^^^
File "/Users/02/Desktop/workspace/coding/BD/try-ai/Style-Bert-VITS2-26/style_bert_vits2/nlp/japanese/pyopenjtalk_worker/worker_client.py", line 19, in __init__
sock.connect((socket.gethostname(), port))
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/02/Desktop/workspace/coding/BD/try-ai/Style-Bert-VITS2-26/style_bert_vits2/nlp/japanese/pyopenjtalk_worker/__init__.py", line 121, in initialize_worker
client = WorkerClient(port)
^^^^^^^^^^^^^^^^^^
File "/Users/02/Desktop/workspace/coding/BD/try-ai/Style-Bert-VITS2-26/style_bert_vits2/nlp/japanese/pyopenjtalk_worker/worker_client.py", line 19, in __init__
sock.connect((socket.gethostname(), port))
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/02/Desktop/workspace/coding/BD/try-ai/Style-Bert-VITS2-26/app.py", line 9, in <module>
from gradio_tabs.inference import create_inference_app
File "/Users/02/Desktop/workspace/coding/BD/try-ai/Style-Bert-VITS2-26/gradio_tabs/inference.py", line 30, in <module>
pyopenjtalk.initialize_worker()
File "/Users/02/Desktop/workspace/coding/BD/try-ai/Style-Bert-VITS2-26/style_bert_vits2/nlp/japanese/pyopenjtalk_worker/__init__.py", line 128, in initialize_worker
raise TimeoutError("サーバーに接続できませんでした")
TimeoutError: サーバーに接続できませんでした
Web app screen goes blank
After resolving the issue above, when launching the web app with the following command, the browser screen remains completely white and nothing is displayed.
python app.py
Solutions
TimeoutError in pyopenjtalk_worker
Cause
I am not sure if it was some kind of glitch with the PC or an issue with the antivirus software, but the hostname MacBook-Pro.local, which is supposed to be the Mac's local hostname, was in a state where it could not be resolved.
In other words:
$ ping MacBook-Pro.local
ping: cannot resolve MacBook-Pro.local: Unknown host
It had fallen into this state.
In that case, in style_bert_vits2/nlp/japanese/pyopenjtalk_worker/worker_client.py:
def __init__(self, port: int) -> None:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# timeout: 60 seconds
sock.settimeout(60)
sock.connect((socket.gethostname(), port))
self.sock = sock
It seems that sock.connect((socket.gethostname(), port)) was unable to connect to the MacBook-Pro.local set by socket.gethostname(), leading to endless retries and timeouts.
Solution
Please modify the following two files as shown below.
Since it only needs to work locally for now, we will eliminate any need for name resolution.
First file:
style_bert_vits2/nlp/japanese/pyopenjtalk_worker/worker_client.py
class WorkerClient:
"""pyopenjtalk worker client"""
def __init__(self, port: int) -> None:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# timeout: 60 seconds
sock.settimeout(60)
- sock.connect((socket.gethostname(), port))
+ sock.connect(("localhost", port))
self.sock = sock
Second file:
style_bert_vits2/nlp/japanese/pyopenjtalk_worker/worker_server.py
def start_server(self, port: int, no_client_timeout: int = 30) -> None:
logger.info("start pyopenjtalk worker server")
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as server_socket:
- server_socket.bind((socket.gethostname(), port))
+ server_socket.bind(("localhost", port))
server_socket.listen()
sockets = [server_socket]
With these modifications, the Timeout error was resolved for me.
Web app screen goes blank
Cause
The cause was identified thanks to the following X post. Thank you.
Solution
It seems that gradio version 5.36.2 is causing issues, and fixing it to 5.34.0 resolves the problem.
cmudict
cn2an
faster-whisper==0.10.1
g2p_en
GPUtil
-gradio>=4.32
+gradio==5.34.0
jieba
librosa==0.9.2
loguru
num2words
numpy<2
protobuf==4.25
psutil
punctuators
pyannote.audio>=3.1.0
pyloudnorm
pyopenjtalk-dict
pypinyin
pyworld-prebuilt
stable_ts
tensorboard
torch
torchaudio
transformers
umap-learn
Result
It is now working properly.

Summary
Since this is a personal memo, I'll leave it at this for now.
It took some time, but I'm glad that model merging is now working.
Discussion