File size: 569 Bytes
fa52b2c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import gradio as gr
from transformers import AutoProcessor, AutoModel
import scipy

processor = AutoProcessor.from_pretrained("suno/bark-small")
model = AutoModel.from_pretrained("suno/bark-small")

def greet(text):
    inputs = processor(
        text=[text],
        return_tensors="pt",
    )
    speech_values = model.generate(**inputs, do_sample=True)
    scipy.io.wavfile.write("tmp.wav", rate=24000, data=speech_values.cpu().numpy().squeeze())
    return open("tmp.wav", "rb").read()

iface = gr.Interface(fn=greet, inputs="text", outputs="audio")
iface.launch()