File size: 1,153 Bytes
b11b469
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
def fn_transliterate(input_text : str, input_language : str = 'autodetect') -> dict:
    try:
        from aksharamukha import transliterate
        # Target scripts: key is prefix for output file, value is target script
        target_scripts = {
            "en": "ISO",          # English / Latin transliteration
            "hi": "Devanagari",   # Hindi
            "bn": "Bengali",
            "ta": "Tamil",
            "te": "Telugu",
            "kn": "Kannada",
            "ma" : "Malayalam",
            "gr" : "Grantha",
            "gu": "Gujarati",
            # add more target scripts if needed
        }
        output = {}
        # Transliterate to each target script
        for prefix, target_script in target_scripts.items():
            transliterated_text = transliterate.process(input_language, target_script, input_text)
            output[prefix] = transliterated_text

        return output
    except Exception as e:
        print(f"Error transliterating '{input_text[:30]}...': {e}")
        # Return empty dict with same keys but placeholder values
        return {prefix: input_text for prefix in target_scripts.keys()}