# Install the required library if not already installed | |
!pip install transformers | |
from transformers import pipeline | |
# Initialize the emoji generation pipeline | |
emoji_generator = pipeline("text2emoji") | |
def translate_to_emojis(text): | |
""" | |
Translates input text into a sequence of emojis. | |
""" | |
try: | |
emojis = emoji_generator(text) | |
return " ".join(emojis) | |
except Exception as e: | |
return f"Oops! Something went wrong: {str(e)}" | |
# Get user input | |
user_text = input("Enter your text: ") | |
# Translate to emojis | |
translated_emojis = translate_to_emojis(user_text) | |
print("\nTranslated Emojis:") | |
print(translated_emojis) |