Spaces:
Sleeping
Sleeping
File size: 664 Bytes
41ce7f0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
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() |