Skip to content

Commit

Permalink
add espeak hotfix for MacOS/Windows (#9)
Browse files Browse the repository at this point in the history
* add espeak hotfix for MacOS/Windows

bootphon/phonemizer#44 (comment)

Detects which platform is running then applies the hotfix, assumes default installation folders.

* Update espeak.py

* Update espeak.py

* Update __init__.py

* Update setup.py

---------

Co-authored-by: hexgrad <[email protected]>
  • Loading branch information
mansourkheffache and hexgrad authored Jan 28, 2025
1 parent 7515cf2 commit ca2723c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
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',
],
)
)

0 comments on commit ca2723c

Please sign in to comment.