Chowza / app.py
Samuel L Meyers
Initial test with suno/bark-small
fa52b2c
raw
history blame
569 Bytes
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()