File size: 925 Bytes
5d8ba63
2d1af42
 
 
 
55a312f
2d1af42
 
 
 
55a312f
 
 
2d1af42
 
 
 
55a312f
 
 
 
 
2d1af42
55a312f
 
 
 
 
 
 
 
 
 
 
 
 
eb0d07d
 
 
 
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
31
32
33
34
35
36
37
38
39
40
import gradio as gr
from transformers import BarkModel, AutoProcessor
import torch
import scipy.io.wavfile as wav

# Load Bark model
processor = AutoProcessor.from_pretrained("suno/bark")
model = BarkModel.from_pretrained("suno/bark")

def generate(text):
    if not text:
        return None

    inputs = processor(text, return_tensors="pt")
    audio = model.generate(**inputs)
    audio = audio.cpu().numpy().squeeze()

    output_path = "output.wav"
    wav.write(output_path, 22050, audio)
    return output_path

demo = gr.Interface(
    fn=generate,
    inputs=gr.Textbox(
        label="Text",
        placeholder="Type something to speak..."
    ),
    outputs=gr.Audio(
        label="AI Voice",
        type="filepath"
    ),
    title="AI Voice Generator (HF Stable)",
    description="Hugging Face compatible AI voice generator"
)

demo.launch(
    server_name="0.0.0.0",
    server_port=7860,
    share=False
)