import google.generativeai as genai import gradio as gr import os import re # Load Google AI API genai.configure(api_key=os.getenv('GEMINI_API_KEY')) # Specify model #model = genai.GenerativeModel('gemini-2.5-pro-exp-03-25') model = genai.GenerativeModel('gemini-2.0-flash') # Function to translate text into emojis def text_to_emoji(text): text_cleaned = re.sub(r"[.,!?;:]", "", text) prompt = f"Convert this sentence into an emoji-sequence of the same meaning and return only the emojis, no explanation:\n\n\"{text_cleaned}\"" response = model.generate_content(prompt) return response.text.strip() # Gradio UI iface = gr.Interface( fn=text_to_emoji, inputs=gr.Textbox(lines=2, placeholder="Enter a sentence..."), outputs="text", title="AI-Powered Emoji Translator", description="Enter a sentence, and the AI will transform it into an emoji-version 🥳" ) iface.launch()