diff --git a/lib/open_jtalk b/lib/open_jtalk index b56a8ed..acd0cc6 160000 --- a/lib/open_jtalk +++ b/lib/open_jtalk @@ -1 +1 @@ -Subproject commit b56a8ed2a63f021e72f237b15b8881ce1cbd621d +Subproject commit acd0cc63ab63d09ea519a39462a2cbc9bc8698d0 diff --git a/pyopenjtalk/__init__.py b/pyopenjtalk/__init__.py index 8ce923b..09a8e94 100644 --- a/pyopenjtalk/__init__.py +++ b/pyopenjtalk/__init__.py @@ -17,28 +17,22 @@ except ImportError: raise ImportError("BUG: version.py doesn't exist. Please file a bug report.") -import locale - from .htsengine import HTSEngine from .openjtalk import CreateUserDict, OpenJTalk -path_encoding = locale.getpreferredencoding() - -path_encoding = locale.getpreferredencoding() - # Dictionary directory # defaults to the package directory where the dictionary will be automatically downloaded OPEN_JTALK_DICT_DIR = os.environ.get( "OPEN_JTALK_DICT_DIR", pkg_resources.resource_filename(__name__, "open_jtalk_dic_utf_8-1.11"), -) +).encode("utf-8") _dict_download_url = "https://github.com/r9y9/open_jtalk/releases/download/v1.11.1" _DICT_URL = f"{_dict_download_url}/open_jtalk_dic_utf_8-1.11.tar.gz" # Default mei_normal.voice for HMM-based TTS DEFAULT_HTS_VOICE = pkg_resources.resource_filename( __name__, "htsvoice/mei_normal.htsvoice" -) +).encode("utf-8") # Global instance of OpenJTalk _global_jtalk = None @@ -73,7 +67,7 @@ def _extract_dic(): f.extractall(path=pkg_resources.resource_filename(__name__, "")) OPEN_JTALK_DICT_DIR = pkg_resources.resource_filename( __name__, "open_jtalk_dic_utf_8-1.11" - ) + ).encode("utf-8") os.remove(filename) @@ -100,7 +94,7 @@ def g2p(*args, **kwargs): global _global_jtalk if _global_jtalk is None: _lazy_init() - _global_jtalk = OpenJTalk(dn_mecab=OPEN_JTALK_DICT_DIR.encode(path_encoding)) + _global_jtalk = OpenJTalk(dn_mecab=OPEN_JTALK_DICT_DIR) return _global_jtalk.g2p(*args, **kwargs) @@ -135,7 +129,7 @@ def synthesize(labels, speed=1.0, half_tone=0.0): global _global_htsengine if _global_htsengine is None: - _global_htsengine = HTSEngine(DEFAULT_HTS_VOICE.encode(path_encoding)) + _global_htsengine = HTSEngine(DEFAULT_HTS_VOICE) sr = _global_htsengine.get_sampling_frequency() _global_htsengine.set_speed(speed) _global_htsengine.add_half_tone(half_tone) @@ -171,7 +165,7 @@ def run_frontend(text, verbose=0): global _global_jtalk if _global_jtalk is None: _lazy_init() - _global_jtalk = OpenJTalk(dn_mecab=OPEN_JTALK_DICT_DIR.encode(path_encoding)) + _global_jtalk = OpenJTalk(dn_mecab=OPEN_JTALK_DICT_DIR) return _global_jtalk.run_frontend(text, verbose) @@ -187,7 +181,7 @@ def create_user_dict(path, out_path): _lazy_init() if not exists(path): raise ValueError("no such file or directory: %s" % path) - CreateUserDict(OPEN_JTALK_DICT_DIR.encode(path_encoding), path.encode(path_encoding), out_path.encode(path_encoding)) + CreateUserDict(OPEN_JTALK_DICT_DIR, path.encode("utf-8"), out_path.encode("utf-8")) def set_user_dict(path): @@ -202,7 +196,7 @@ def set_user_dict(path): if not exists(path): raise ValueError("no such file or directory: %s" % path) _global_jtalk = OpenJTalk( - dn_mecab=OPEN_JTALK_DICT_DIR.encode(path_encoding), user_mecab=path.encode(path_encoding) + dn_mecab=OPEN_JTALK_DICT_DIR, user_mecab=path.encode("utf-8") ) @@ -211,4 +205,4 @@ def unset_user_dict(): global _global_jtalk if _global_jtalk is None: _lazy_init() - _global_jtalk = OpenJTalk(dn_mecab=OPEN_JTALK_DICT_DIR.encode(path_encoding)) \ No newline at end of file + _global_jtalk = OpenJTalk(dn_mecab=OPEN_JTALK_DICT_DIR) \ No newline at end of file