Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import BarkModel, AutoProcessor | |
import torch | |
from scipy.io.wavfile import write as write_wav | |
import os | |
device = "cpu" | |
model = BarkModel.from_pretrained("suno/bark-small").to(device) | |
processor = AutoProcessor.from_pretrained("suno/bark") | |
def generate_audio(text): | |
file_name = "output_file_name.wav" | |
inputs = processor(text) | |
audio_array = model.generate(**inputs) | |
audio_array = audio_array.cpu().numpy().squeeze() | |
sample_rate = model.generation_config.sample_rate | |
write_wav(file_name,sample_rate,audio_array) | |
return file_name | |
iface = gr.Interface(fn=generate_audio,inputs="text",outputs="audio") | |
iface.launch() |