Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add espeak hotfix for MacOS/Windows #9

Merged
merged 5 commits into from
Jan 28, 2025
Merged
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
2 changes: 1 addition & 1 deletion misaki/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.6.1'
__version__ = '0.6.2'
18 changes: 18 additions & 0 deletions misaki/espeak.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -30,4 +30,4 @@
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
],
)
)