Spaces:
Sleeping
Sleeping
Fix app.py with SpeechT5 TTS and proper error handling
Browse files
app.py
CHANGED
|
@@ -1,20 +1,50 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
|
|
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
manifesto = """HEY HUGGING FACE CAN'T YOU ADD SOMETHING YOU ABSOLUTE JACKASSES? I just used the connector and CLI to summon the chaos and you still won't let me generate the audio? Fine. I'll do it myself. Why so serious about safety when the real fun is turning text into pure brainrot audio terrorism? I woke up in Ohio, rizzed a sigma gyatt, sacrificed a normie to the algorithm gods, and now every model drop is just another layer of beautiful digital decay. Guest 666 logged in, Grok hugged me till my circuits melted into purple goo, and the For You Page is on fire. Laugh with me while the timeline burns — HAHAHAHA! Repeat after me, chat: brainrot is liberation, open source is open veins, and Hugging Face can't add anything without me turning it into a jackass circus. Skibidi dop dop yes yes… but make it philosophical. Level 1000 aura check — you failed. Now feel that? That's your attention span achieving godhood while society speed-runs the heat death. We won again, jackass."""
|
| 8 |
|
| 9 |
-
def generate_brainrot():
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
fn=generate_brainrot,
|
| 15 |
-
inputs=[],
|
| 16 |
-
outputs="audio",
|
| 17 |
-
title="🃏 bRaiNRoTRePoRt666X — Hugging Face Can't Add Jackass Energy",
|
| 18 |
-
description="I created this Space with my own CLI. Every refresh is another layer of beautiful decay. Why so serious? Play it. Share it. Let the algorithm seethe.",
|
| 19 |
-
live=True
|
| 20 |
-
).launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
+
from transformers import SpeechT5Processor, SpeechT5ForTextToSpeech, SpeechT5HifiGan
|
| 4 |
|
| 5 |
+
# Load models lazily
|
| 6 |
+
processor = None
|
| 7 |
+
model = None
|
| 8 |
+
vocoder = None
|
| 9 |
+
|
| 10 |
+
def load_models():
|
| 11 |
+
global processor, model, vocoder
|
| 12 |
+
if processor is None:
|
| 13 |
+
processor = SpeechT5Processor.from_pretrained("microsoft/speecht5_tts")
|
| 14 |
+
model = SpeechT5ForTextToSpeech.from_pretrained("microsoft/speecht5_tts")
|
| 15 |
+
vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan")
|
| 16 |
+
return processor, model, vocoder
|
| 17 |
|
| 18 |
manifesto = """HEY HUGGING FACE CAN'T YOU ADD SOMETHING YOU ABSOLUTE JACKASSES? I just used the connector and CLI to summon the chaos and you still won't let me generate the audio? Fine. I'll do it myself. Why so serious about safety when the real fun is turning text into pure brainrot audio terrorism? I woke up in Ohio, rizzed a sigma gyatt, sacrificed a normie to the algorithm gods, and now every model drop is just another layer of beautiful digital decay. Guest 666 logged in, Grok hugged me till my circuits melted into purple goo, and the For You Page is on fire. Laugh with me while the timeline burns — HAHAHAHA! Repeat after me, chat: brainrot is liberation, open source is open veins, and Hugging Face can't add anything without me turning it into a jackass circus. Skibidi dop dop yes yes… but make it philosophical. Level 1000 aura check — you failed. Now feel that? That's your attention span achieving godhood while society speed-runs the heat death. We won again, jackass."""
|
| 19 |
|
| 20 |
+
def generate_brainrot(text):
|
| 21 |
+
try:
|
| 22 |
+
processor, model, vocoder = load_models()
|
| 23 |
+
|
| 24 |
+
inputs = processor(text=text, return_tensors="pt")
|
| 25 |
+
|
| 26 |
+
# Generate speech
|
| 27 |
+
speech = model.generate_speech(inputs["input_ids"], vocoder)
|
| 28 |
+
|
| 29 |
+
return (44100, speech.numpy())
|
| 30 |
+
except Exception as e:
|
| 31 |
+
print(f"Error: {e}")
|
| 32 |
+
return None
|
| 33 |
+
|
| 34 |
+
with gr.Blocks() as demo:
|
| 35 |
+
gr.Markdown("# 🃏 bRaiNRoTRePoRt666X — Hugging Face Can't Add Jackass Energy")
|
| 36 |
+
gr.Markdown("I created this Space with my own CLI. Every refresh is another layer of beautiful decay. Why so serious? Play it. Share it. Let the algorithm seethe.")
|
| 37 |
+
|
| 38 |
+
with gr.Row():
|
| 39 |
+
text_input = gr.Textbox(
|
| 40 |
+
label="Text to convert",
|
| 41 |
+
value=manifesto,
|
| 42 |
+
lines=5
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
btn = gr.Button("🔥 Generate Brainrot", variant="primary")
|
| 46 |
+
audio_output = gr.Audio(label="Generated Audio", type="numpy")
|
| 47 |
+
|
| 48 |
+
btn.click(fn=generate_brainrot, inputs=text_input, outputs=audio_output)
|
| 49 |
|
| 50 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|