from transformers import pipeline # Load the translation pipeline for English to French translator = pipeline("translation_en_to_fr") # Define the English text you want to translate english_texts = [ "Hello, how are you?", "I love learning new languages!", "Transformers make NLP tasks so easy." ] # Translate each sentence for text in english_texts: translated = translator(text)[0]['translation_text'] print(f"English: {text}") print(f"French: {translated}\n")