Spaces:
Sleeping
Sleeping
File size: 914 Bytes
783a256 9645123 783a256 9645123 783a256 9645123 783a256 a8cd17d 9645123 e6d2bc0 783a256 9645123 783a256 9645123 e6d2bc0 |
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 27 28 29 30 |
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() |