diff --git a/misaki/__init__.py b/misaki/__init__.py index 3966a5f..aece342 100644 --- a/misaki/__init__.py +++ b/misaki/__init__.py @@ -1 +1 @@ -__version__ = '0.6.1' \ No newline at end of file +__version__ = '0.6.2' diff --git a/misaki/espeak.py b/misaki/espeak.py index 87c0656..06a2846 100644 --- a/misaki/espeak.py +++ b/misaki/espeak.py @@ -1,6 +1,24 @@ import phonemizer import re +### BEGIN ### +def set_espeak_library(): + # https://github.com/bootphon/phonemizer/issues/44#issuecomment-1540885186 + from phonemizer.backend.espeak.wrapper import EspeakWrapper + if not EspeakWrapper._ESPEAK_LIBRARY: + import os + import platform + library = dict( + Darwin='/opt/homebrew/Cellar/espeak-ng/1.52.0/lib/libespeak-ng.1.dylib', + Windows='C:\Program Files\eSpeak NG\libespeak-ng.dll', + ).get(platform.system()) + if library and os.path.exists(library): + EspeakWrapper.set_library(library) + return EspeakWrapper._ESPEAK_LIBRARY + +set_espeak_library() +#### END #### + FROM_ESPEAKS = sorted({'\u0303':'','a^ɪ':'I','a^ʊ':'W','d^ʒ':'ʤ','e':'A','e^ɪ':'A','r':'ɹ','t^ʃ':'ʧ','x':'k','ç':'k','ɐ':'ə','ɔ^ɪ':'Y','ə^l':'ᵊl','ɚ':'əɹ','ɬ':'l','ʔ':'t','ʔn':'tᵊn','ʔˌn\u0329':'tᵊn','ʲ':'','ʲO':'jO','ʲQ':'jQ'}.items(), key=lambda kv: -len(kv[0])) class EspeakFallback: diff --git a/setup.py b/setup.py index 1a62863..2a259fe 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='misaki', - version='0.6.1', + version='0.6.2', packages=find_packages(), package_data={ 'misaki': ['data/*.json', 'data/*.txt', 'hangul/data/*.csv', 'hangul/data/*.tsv'], @@ -30,4 +30,4 @@ 'License :: OSI Approved :: Apache Software License', 'Operating System :: OS Independent', ], -) \ No newline at end of file +)