Spaces:
Build error
Build error
| import streamlit as st | |
| # Define a dictionary mapping words to emojis | |
| emoji_mapping = { | |
| "happy": "π", | |
| "sad": "π’", | |
| "love": "β€οΈ", | |
| "angry": "π‘", | |
| "sun": "βοΈ", | |
| "star": "β", | |
| "fire": "π₯", | |
| "cool": "π", | |
| "cat": "π±", | |
| "dog": "πΆ", | |
| } | |
| # Function to convert text to emojis | |
| def text_to_emoji(text): | |
| words = text.split() | |
| converted_text = [] | |
| for word in words: | |
| # Replace word with emoji if it exists in the mapping | |
| converted_text.append(emoji_mapping.get(word.lower(), word)) | |
| return " ".join(converted_text) | |
| # Streamlit UI | |
| st.set_page_config(page_title="Emoji Magic", page_icon="β¨") | |
| # Title and Big Emoji | |
| st.title("Emoji Magic") | |
| st.markdown("<div style='text-align: center; font-size: 100px;'>πβ¨π</div>", unsafe_allow_html=True) | |
| st.write("Turn your text into emoji-filled fun! Type below to transform your words into emojis. π") | |
| # User input | |
| user_input = st.text_input("Enter your text here:", placeholder="e.g., I am happy and love the sun!") | |
| # Convert and display the result with big emojis | |
| if user_input: | |
| output = text_to_emoji(user_input) | |
| st.markdown("<h2 style='text-align: center;'>Your Emoji-fied Text:</h2>", unsafe_allow_html=True) | |
| st.markdown(f"<div style='text-align: center; font-size: 70px;'>{output}</div>", unsafe_allow_html=True) | |
| st.markdown("<div style='text-align: center; font-size: 60px;'>πβ¨ Enjoy! β¨π</div>", unsafe_allow_html=True) | |
| st.write("---") | |
| st.write("Built with β€οΈ using [Streamlit](https://streamlit.io/) and hosted on [Hugging Face Spaces](https://huggingface.co/spaces).") | |