Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,27 @@
|
|
| 1 |
import os
|
| 2 |
import torch
|
| 3 |
import gradio as gr
|
| 4 |
-
from
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
tts.to("cuda" if torch.cuda.is_available() else "cpu")
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import torch
|
| 3 |
import gradio as gr
|
| 4 |
+
from bark import generate_audio, preload_models
|
| 5 |
+
from scipy.io.wavfile import write as write_wav
|
| 6 |
|
| 7 |
+
# Load Bark models
|
| 8 |
+
preload_models()
|
|
|
|
| 9 |
|
| 10 |
+
def generate(text):
|
| 11 |
+
# Inject horror style: creepy pauses, gasping
|
| 12 |
+
text = f"[clears throat]{text} [laughs creepily] [breathing heavily]"
|
| 13 |
|
| 14 |
+
audio_array = generate_audio(text)
|
| 15 |
+
out_path = "output.wav"
|
| 16 |
+
write_wav(out_path, rate=24000, data=audio_array)
|
| 17 |
+
return out_path
|
| 18 |
+
|
| 19 |
+
demo = gr.Interface(
|
| 20 |
+
fn=generate,
|
| 21 |
+
inputs=gr.Textbox(label="💀 Type something cursed"),
|
| 22 |
+
outputs=gr.Audio(type="filepath"),
|
| 23 |
+
title="Bark Horror Voice Generator",
|
| 24 |
+
description="👹 Type scary text. Get glitchy cursed voice. Powered by Bark AI."
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
demo.launch()
|