diff --git a/kitchen_counter/conversion/translation/translation_function.py b/kitchen_counter/conversion/translation/translation_function.py index f853ba2..99801ca 100755 --- a/kitchen_counter/conversion/translation/translation_function.py +++ b/kitchen_counter/conversion/translation/translation_function.py @@ -461,11 +461,15 @@ def translate_comparison2(text, source_lang, target_lang, script_data=None, subs if is_dialogue: tokenizers_valid_langs = ("malayalam", "french", "italian", "german", "spanish", "swedish", "finnish", "danish", "english", "slovene", "norwegian", "dutch", "portuguese", "czech", "russian", "polish","turkish", "estonian", "greek") + try: + if code_2_language[source_lang].lower() in tokenizers_valid_langs: + sentences = sent_tokenize(text, language=(code_2_language[source_lang]).lower()) + else: + sentences = text.split(".") + except Exception as e: + print("Error was : ", e) + return text - if code_2_language[source_lang].lower() in tokenizers_valid_langs: - sentences = sent_tokenize(text, language=(code_2_language[source_lang]).lower()) - else: - sentences = text.split(".") # List of translated sentences translated_text = []