CoolFace
Apppublic

Ghmustafa11/EmojiMagic

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes
app.py42 linesDownload Raw Back to root
1import streamlit as st2 3# Define a dictionary mapping words to emojis4emoji_mapping = {5    "happy": "๐Ÿ˜Š",6    "sad": "๐Ÿ˜ข",7    "love": "โค๏ธ",8    "angry": "๐Ÿ˜ก",9    "sun": "โ˜€๏ธ",10    "star": "โญ",11    "fire": "๐Ÿ”ฅ",12    "cool": "๐Ÿ˜Ž",13    "cat": "๐Ÿฑ",14    "dog": "๐Ÿถ",15}16 17# Function to convert text to emojis18def text_to_emoji(text):19    words = text.split()20    converted_text = []21    for word in words:22        # Replace word with emoji if it exists in the mapping23        converted_text.append(emoji_mapping.get(word.lower(), word))24    return " ".join(converted_text)25 26# Streamlit UI27st.title("Text to Emoji Converter")28st.write("Convert your sentences into emojis! Type some text below and see the magic. ๐Ÿ˜ƒ")29 30# User input31user_input = st.text_input("Enter your text here:", placeholder="e.g., I am happy and love the sun!")32 33# Convert and display the result34if user_input:35    output = text_to_emoji(user_input)36    st.write("### Converted Text:")37    st.write(output)38    st.write("โœจ Enjoy your emojis!")39 40st.write("---")41st.write("Built with โค๏ธ using [Streamlit](https://streamlit.io/) and hosted on [Hugging Face Spaces](https://huggingface.co/spaces).")42