Introduction
Imagine trying to understand a letter written in a language you don't know. Translation solves this problem by converting words from one language into another so people can understand each other.
Jump into concepts and practice - no test required
Imagine you have a friend who only speaks Spanish and you only speak English. You want to share a story, so you ask a bilingual friend to listen to you and then tell the story in Spanish to your friend. This way, both of you understand the story even though you speak different languages.
┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │ Source Text │──────▶│ Translation │──────▶│ Target Text │ │ (English) │ │ Process │ │ (Spanish) │ └───────────────┘ └───────────────┘ └───────────────┘
from transformers import pipeline
translator = pipeline('translation_en_to_de')
result = translator('Hello, how are you?')
print(result[0]['translation_text'])from transformers import pipeline
translator = pipeline('translation_en_to_es')
result = translator('Good morning')
print(result['translation_text'])
What is the error and how to fix it?