Esempio n. 1
0
def translate_text(text_list):
    translate_analyzer = TranslationAnalyzer(
        model_name_or_path="Helsinki-NLP/opus-mt-hi-en",
        device="auto"
    )
    source_responses = [AnalyzerRequest(processed_text=text.processed_text, source_name="sample") for text in text_list]
    analyzer_responses = translate_analyzer.analyze_input(source_response_list=source_responses)
    return [
        AnalyzerRequest(processed_text=response.segmented_data['translated_text'], source_name="translator")
        for response in analyzer_responses
    ]
Esempio n. 2
0
def translate_analyzer():
    return TranslationAnalyzer(model_name_or_path="Helsinki-NLP/opus-mt-hi-en",
                               batch_size=1)