File size: 651 Bytes
4eb1fe5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 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)