OMGJ commited on
Commit
41ce7f0
1 Parent(s): 813f3c5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import BarkModel, AutoProcessor
3
+ import torch
4
+ from scipy.io.wavfile import write as write_wav
5
+ import os
6
+
7
+ device = "cpu"
8
+ model = BarkModel.from_pretrained("suno/bark-small").to(device)
9
+ processor = AutoProcessor.from_pretrained("suno/bark")
10
+
11
+ def generate_audio(text):
12
+ file_name = "output_file_name.wav"
13
+ inputs = processor(text)
14
+ audio_array = model.generate(**inputs)
15
+ audio_array = audio_array.cpu().numpy().squeeze()
16
+ sample_rate = model.generation_config.sample_rate
17
+ write_wav(file_name,sample_rate,audio_array)
18
+ return file_name
19
+
20
+
21
+ iface = gr.Interface(fn=generate_audio,inputs="text",outputs="audio")
22
+ iface.launch()