Download app.py from tspsram/emoji: direct link, hf CLI and curl.
- Browser
- Download file 653 Bytes
-
https://huggingface.co/tspsram/emoji/resolve/main/app.py
- Command line
-
hf download hf://tspsram/emoji/app.py
-
curl -L -o app.py https://huggingface.co/tspsram/emoji/resolve/main/app.py
653 Bytes
| # 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) |