diff --git a/common/modulemanager.py b/common/modulemanager.py index 95ff84c..b6390ac 100755 --- a/common/modulemanager.py +++ b/common/modulemanager.py @@ -45,7 +45,7 @@ class ModuleManager: module_name = self.find_module(action) if(module_name): try: - return self.import_module(module_name).getInstance() + return self.import_module(module_name).getInstance() except: #print dir(self.import_module(module_name)) print "Failed to get instance for " + module_name diff --git a/modules/transliterator/cmudict.py b/modules/transliterator/cmudict.py index 6116438..c45354d 100755 --- a/modules/transliterator/cmudict.py +++ b/modules/transliterator/cmudict.py @@ -63,6 +63,47 @@ CMU_MALAYALAM_MAP = { "V" : "വ്", "Z" : "സ്", } + +CMU_KANNADA_MAP = { + "AA" : "ಆ", + "AH" : "ಅ", + "AE" : "ಏ", + "AO" : "ಓ", + "AW" : "ಔ", + "AY" : "ಐ", + "B" : "ಬ್", + "CH" : "ಚ್", + "D" : "ಡ್", + "DH" : "ದ್", + "EA" : "ಈ", + "EH" : "ಎ", + "ER" : "ಅರ್", + "EY" : "ಎಯ್", + "F" : "ಫ್", + "G" : "ಗ್", + "HH" : "ಹ್", + "IH" : "ಇ", + "IY" : "ಈ", + "J" : "ಜ್", + "JH" : "ಜ್", + "K" : "ಕ್", + "L" : "ಲ್", + "M" : "ಮ್", + "N" : "ನ್", + "NG" : "ಂಗ್", + "OW" : "ಒ", + "P" : "ಪ್", + "R" : "ರ್", + "S" : "ಸ್", + "SH" : "ಷ್", + "T" : "ಟ್", + "TH" : "ತ್", + "Y" : "ಯ್", + "UW" : "ಉ", + "W" : "ವ್", + "V" : "ವ್", + "Z":"ಸ್" +} class CMUDict(): def __init__(self): @@ -97,7 +138,15 @@ class CMUDict(): pronunciation_str += CMU_MALAYALAM_MAP[syl] except KeyError: pronunciation_str += syl - pronunciation_str = self._fix_vowel_signs_ml(pronunciation_str) + pronunciation_str = self._fix_vowel_signs_ml(pronunciation_str) + + if language == "kn_IN": + for symbol in cmu_pronunciation: + try: + pronunciation_str += CMU_KANNADA_MAP[symbol] + except KeyError: + pronunciation_str += symbol + pronunciation_str = self._fix_vowel_signs_kn(pronunciation_str) return (pronunciation_str).decode("utf-8") + punctuations def _fix_vowel_signs_ml(self,text) : text= text.replace("്അ","") @@ -129,3 +178,19 @@ class CMUDict(): text= text.replace("റ്ര","റ്റ") text= text.replace("ന്‍റ്റ","ന്റ") return text + + def _fix_vowel_signs_kn(self,text) : + text= text.replace("್ಅ","") + text= text.replace("್ಆ","ಾ") + text= text.replace("್ಇ","ಿ") + text= text.replace("್ಈ","ೀ") + text= text.replace("್ಉ","ು") + text= text.replace("್ಊ","ೂ") + text= text.replace("್ಋ","ೃ") + text= text.replace("್ಎ","ೆ") + text= text.replace("್ಏ","ೇ") + text= text.replace("್ಐ","ೈ") + text= text.replace("್ಒ","ೊ") + text= text.replace("್ಓ","ೋ") + text= text.replace("್ಔ","ೌ") + return text diff --git a/modules/transliterator/transliterate.py b/modules/transliterator/transliterate.py index cb53d58..62e63fa 100755 --- a/modules/transliterator/transliterate.py +++ b/modules/transliterator/transliterate.py @@ -38,6 +38,14 @@ class Transliterator(SilpaModule): CMU pronuciation dictionary """ return self.cmu.pronunciation(word,"ml_IN") + + def transliterate_en_kn(self, word): + """ + Transliterate English to Malayalam with the help of + CMU pronuciation dictionary + """ + return self.cmu.pronunciation(word,"kn_IN") + def transliterate_en_xx(self,word, target_lang): """ @@ -45,7 +53,12 @@ class Transliterator(SilpaModule): """ if target_lang=="en_IN" or target_lang=="en_US": return word - tx_str = self.transliterate_en_ml(word) + if target_lang == "kn_IN": + tx_str = self.transliterate_en_kn(word) + return tx_str + else: + tx_str = self.transliterate_en_ml(word) + if target_lang == "ml_IN": return tx_str #chain it through indic indic transliteratioin