dmort27 / epitran

A tool for transcribing orthographic text as IPA (International Phonetic Alphabet)
MIT License
649 stars 123 forks source link

keyerror on any english transliteration #23

Closed jeremy-rutman closed 5 years ago

jeremy-rutman commented 5 years ago

I wanted to give this a whirl but hit some speedbump from the getgo :

In [2]: epi = epitran.Epitran('eng-Latn')
In [3]: epi.transliterate('iceland')
WARNING:root:lex_lookup (from flite) is not installed.
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-3-54aaf7e8072d> in <module>()
----> 1 epi.transliterate('iceland')

/home/jeremy/.local/lib/python3.6/site-packages/epitran/_epitran.py in transliterate(self, word, normpunc, ligatures)
     60             unicode: IPA string
     61         """
---> 62         return self.epi.transliterate(word, normpunc, ligatures)
     63 
     64     def reverse_transliterate(self, ipa):

/home/jeremy/.local/lib/python3.6/site-packages/epitran/flite.py in transliterate(self, text, normpunc, ligatures)
     89         for chunk in self.chunk_re.findall(text):
     90             if self.letter_re.match(chunk):
---> 91                 acc.append(self.english_g2p(chunk))
     92             else:
     93                 acc.append(chunk)

/home/jeremy/.local/lib/python3.6/site-packages/epitran/flite.py in english_g2p(self, text)
    205             logging.warning('Non-zero exit status from lex_lookup.')
    206             arpa_text = ''
--> 207         return self.arpa_to_ipa(arpa_text)

/home/jeremy/.local/lib/python3.6/site-packages/epitran/flite.py in arpa_to_ipa(self, arpa_text, ligatures)
     73         arpa_list = map(lambda d: re.sub('\d', '', d), arpa_list)
     74         ipa_list = map(lambda d: self.arpa_map[d], arpa_list)
---> 75         text = ''.join(ipa_list)
     76         return text
     77 

/home/jeremy/.local/lib/python3.6/site-packages/epitran/flite.py in <lambda>(d)
     72         arpa_list = self.arpa_text_to_list(arpa_text)
     73         arpa_list = map(lambda d: re.sub('\d', '', d), arpa_list)
---> 74         ipa_list = map(lambda d: self.arpa_map[d], arpa_list)
     75         text = ''.join(ipa_list)
     76         return text

KeyError: ''

In [4]: epi2 = epitran.Epitran('rus-Cyrl')

In [7]: epi.transliterate('')
Out[7]: ''

In [9]: epi2.transliterate('Приве́т')
Out[9]: 'prʲivʲét'
jeremy-rutman commented 5 years ago

whoops just finally read that (in addition to the python warning above) "‡English G2P requires the installation of the freely available CMU Flite speech synthesis system."

jeremy-rutman commented 5 years ago

On Thu, Jun 13, 2019 at 12:38 AM khyathiraghavi notifications@github.com wrote:

I am facing an issue running the model for English. I have installed Flite and am able to run c = os.system(command) from my python script as well. I get the following warning: WARNING:root:lex_lookup (from flite) is not installed. Did anyone else face this issue? Could you let me know how you have solved it? Thanks!

Are you sure your system sees the Flite install ? Maybe check the flite path is in your PATH and the like , from the error it looks the system isnt seeing flite.