Spaces:
Build error
Build error
| # ๐ง SoberUp: Drunk-to-Sober Text Translator (Gradio Edition) | |
| ## Install Gemini API & Gradio | |
| ```bash | |
| pip install -q -U google-genai gradio | |
| ``` | |
| --- | |
| ## ๐ฆ `app.py`: The Gradio Interface | |
| ```python | |
| import gradio as gr | |
| from google import genai | |
| import os | |
| # Correct Gemini API setup | |
| client = genai.Client(api_key=os.getenv("GEMINI_API_KEY")) | |
| model = client.models.get("models/gemini-2.0-flash") | |
| def sober_up(drunk_text): | |
| if not drunk_text.strip(): | |
| return "Please enter a message." | |
| prompt = f"Translate this drunk message into a sober, coherent version: '{drunk_text}'" | |
| try: | |
| response = model.generate_content(contents=prompt) | |
| return response.text | |
| except Exception as e: | |
| return f"Error: {e}" | |
| # Gradio UI | |
| demo = gr.Interface( | |
| fn=sober_up, | |
| inputs=gr.Textbox(lines=4, placeholder="Type or paste your drunk text here..."), | |
| outputs="text", | |
| title="๐บ SoberUp Translator", | |
| description="Paste your chaotic, drunk ramblings and get a polished, sober version." | |
| ) | |
| demo.launch() | |
| ``` | |
| --- | |
| ## ๐งช Example Prompt: | |
| ```text | |
| oh mannn i just met a guy at tha taco bell drivethru named jason and weโre startin a band called laser lizards ๐๐ธ๐ฎ | |
| ``` | |
| **Output:** | |
| ```text | |
| I just met a guy named Jason at Taco Bell. We're starting a band called Laser Lizards. | |
| ``` | |
| --- | |
| ## ๐ Security Tips | |
| - Use `os.getenv("GEMINI_API_KEY")` from Hugging Face secrets panel | |
| - Optionally add profanity filtering or moderation layer | |
| Want it hosted on Hugging Face or deployed as a mobile app? Just say the word: `> DEPLOY TO CLOUD` or `> MAKE MOBILE VERSION`. | |