Update app.py
Browse files
app.py
CHANGED
|
@@ -1,45 +1,21 @@
|
|
| 1 |
-
import os
|
| 2 |
import gradio as gr
|
| 3 |
-
from
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
)
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
language=language,
|
| 24 |
-
file_path=output_path
|
| 25 |
-
)
|
| 26 |
-
return output_path, "✅ Audio ready!"
|
| 27 |
-
|
| 28 |
-
with gr.Blocks(title="Deepak AI Voice Studio") as demo:
|
| 29 |
-
gr.Markdown("# 🎙️ Deepak AI Voice Studio")
|
| 30 |
-
gr.Markdown("Apni awaaz se AI voice generate karein (XTTS-v2)")
|
| 31 |
-
|
| 32 |
-
with gr.Row():
|
| 33 |
-
with gr.Column():
|
| 34 |
-
text = gr.Textbox(label="Text", lines=3)
|
| 35 |
-
voice = gr.Audio(type="filepath", label="Voice sample (5–10 sec)")
|
| 36 |
-
lang = gr.Dropdown(["hi", "en"], value="hi", label="Language")
|
| 37 |
-
btn = gr.Button("Generate")
|
| 38 |
-
|
| 39 |
-
with gr.Column():
|
| 40 |
-
out = gr.Audio(label="Output")
|
| 41 |
-
status = gr.Textbox(label="Status")
|
| 42 |
-
|
| 43 |
-
btn.click(generate_voice, [text, voice, lang], [out, status])
|
| 44 |
-
|
| 45 |
-
demo.launch()
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import BarkModel, AutoProcessor
|
| 3 |
+
import torch
|
| 4 |
+
import scipy.io.wavfile as wav
|
| 5 |
+
|
| 6 |
+
processor = AutoProcessor.from_pretrained("suno/bark")
|
| 7 |
+
model = BarkModel.from_pretrained("suno/bark")
|
| 8 |
+
|
| 9 |
+
def generate(text):
|
| 10 |
+
inputs = processor(text, return_tensors="pt")
|
| 11 |
+
audio = model.generate(**inputs)
|
| 12 |
+
audio = audio.cpu().numpy().squeeze()
|
| 13 |
+
wav.write("out.wav", 22050, audio)
|
| 14 |
+
return "out.wav"
|
| 15 |
+
|
| 16 |
+
gr.Interface(
|
| 17 |
+
fn=generate,
|
| 18 |
+
inputs=gr.Textbox(label="Text"),
|
| 19 |
+
outputs=gr.Audio(type="filepath"),
|
| 20 |
+
title="AI Voice Generator (HF Stable)"
|
| 21 |
+
).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|