Closed brisvag closed 5 years ago
This is perplexing. For some reason, lex_lookup
is producing output with newlines. Can you try entering the following at the command line and reporting the output?
lex_lookup 'berkeley'
I want to rule out the possibility that this has something to do with the lex_lookup
binary on your system. It should output (b er1 k l iy0)
Interesting. I get a repetition:
$ lex_lookup 'berkeley'
(b er1 k l iy0)
(b er1 k l iy0)
I suppose this means somehow my lex_lookup
binary is misbehaving.
Indeed, your lex_lookup
is not behaving as expected. What platform and what OS version are you on?
There is an easy, if kludgy, fix for this (within Epitran): split the output of lex_lookup
on '\n'
and take the first element in the resulting list. I'll implement this and make a new release today.
Try the new release (0.60) and see if it fixes the problem.
Indeed, your
lex_lookup
is not behaving as expected. What platform and what OS version are you on?
I'm on ArchLinux, and I built flite
from the source on github. This might be some problem/change with the latest upstream... I really doubt I did anything strange, since the installation process is quite easy and streamlined.
Anyways, your quick-and-dirty fix works just fine, thank you!
You built flite
from the GitHub source, then? This probably explains the problem. I think Alan Black, author of flite
, may have changed the behavior of lex_lookup
since the non-release release that is recommended in the README for Epitran. I'll talk to @awbcmu and @saikrishnarallabandi to see if there are any other interface changes to the lex_lookup
interface that I should accomodate. Then perhaps I can start directing people to the GitHub source rather than the package linked from the README.
I just talked to @awbcmu and apparently there was a change in behavior in lex_lookup
. He said epitran
should take the first transcription, so the current behavior is right.
Good, glad this helped to solve something! I'd say this can be closed for good now.
@brisvag Have you solved this problem? Is there a viable solution?
Yes. As I said in my last message, dmort's upstream fix was enough.
Thank you very much:)
from langdetect import detect import epitran
def get_phonetics(text): try:
language = detect(text)
# Language code mapping for epitran
language_map = {
'en': 'eng-Latn', # English
'hi': 'hin-Deva', # Hindi
# Add more mappings as needed
}
# Get the corresponding epitran code
epi_code = language_map.get(language)
if not epi_code:
return f"Language '{language}' not supported for phonetic transcription."
# Initialize Epitran
epi = epitran.Epitran(epi_code)
# Generate phonetics
phonetics = epi.transliterate(text)
return phonetics
except Exception as e:
return f"An error occurred: {e}"
text_hindi = "नमस्ते, आप कैसे हैं?" text_english = "Hello, how are you?"
print(get_phonetics(text_hindi)) print(get_phonetics(text_english))
i am getting this error while running this code:
nəmste, aːpə kæːse ɦæːn? WARNING:epitran:lex_lookup (from flite) is not installed. An error occurred: list index out of range
can any one help me to solve this issue
I've been trying to use the english transliteration, without success.
I did follow installation instructions for flite (and also copied the relevant binaries in the
/usr/local/bin
), and the process seems to have worked since I do not get anymore the "lex_lookup not installed" kind of error.However, I'm still stuck at a rather cryptic KeyError. When I do (in python3):
this is what I get:
No matter my query, it seems
self.arpa_map
does not have it. What am I doing wrong?