Skip to content

mecab load error #3

Description

@f2janyway

When I test MeloTTS for Korean

MeloTTS use g2pkk for Korean and When I use Ubuntu it works fine but Mac M1 had trouble on here.

g2pkk/g2pkk/utils.py

Lines 165 to 167 in adec977

def annotate(string, mecab):
tokens = mecab.pos(string)
if string.replace(" ", "") != "".join(token for token, _ in tokens):

AttributeError: 'NoneType' object has no attribute 'pos'

Debugging shows `mecab' return None on here

g2pkk/g2pkk/g2pkk.py

Lines 56 to 68 in adec977

def get_mecab(self):
if platform.system() == 'Windows':
try:
m = self.load_module_func('eunjeon')
return m.Mecab()
except Exception as e:
raise print(f'you have to install eunjeon. "pip install eunjeon"')
else:
try:
m = self.load_module_func('mecab')
return m.MeCab()
except Exception as e:
print(f'you have to install python-mecab-ko. "pip install python-mecab-ko"')

Difference of Ubuntu and M1 is mecab module existance. Ubuntu has but not M1.

I think pip install mecab-python3 make a little different in each OS.

So when I changed here

      m = self.load_module_func('mecab') 
      return m.MeCab()
 def annotate(string, mecab): 
     tokens = mecab.pos(string) 
     if string.replace(" ", "") != "".join(token for token, _ in tokens): 

to

    import MeCab
    return MeCab.Tagger()
     tokens = mecab.parse(string) 
     if string.replace(" ", "") != "".join(token for token in tokens): 

It works.

So I think it might need to check self.load_module_func('mecab') is None or not

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions