Skip to content

Instantly share code, notes, and snippets.

@davidmezzetti
Created July 9, 2024 11:53
Show Gist options
  • Save davidmezzetti/96dc04025760ef680047efe5b5ae82f9 to your computer and use it in GitHub Desktop.
Save davidmezzetti/96dc04025760ef680047efe5b5ae82f9 to your computer and use it in GitHub Desktop.
from txtai.pipeline import Translation
# Load pipeline
translate = Translation()
# Run translations
languages = ["fr", "es", "de", "hi", "ja"]
for language in languages:
text = translate("The sky is blue, the stars are far", language)
english = translate(text, "en")
print(f"Original Language: {language}")
print(f"Translation: {text}")
print(f"Back to English: {english}\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment