File size: 1,006 Bytes
cfd58c5
2a5abe3
cfd58c5
 
 
 
 
 
 
a2597a8
 
f4e63b7
 
a2597a8
 
 
cfd58c5
 
 
f4e63b7
cfd58c5
c370655
 
cfd58c5
 
 
 
a2597a8
cfd58c5
 
 
a2597a8
cfd58c5
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import gradio as gr
import torch
from transformers import AutoProcessor, AutoModel
import scipy


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


def run_bark(text, lang="en", n=1):
    #history_prompt = []
    semantic_prompt=(f"v2/{lang}_speaker_{n}")

        #text=["Hello, my name is Suno. And, uh — and I like pizza. [laughs] But I also have other interests such as playing tic tac toe."],
    inputs = processor(text=text,
        return_tensors="pt",
    )
    
    speech_values = model.generate(**inputs, semantic_prompt=semantic_prompt, do_sample=True)

    #sampling_rate = model.config.sample_rate
    sampling_rate = 24000
    scipy.io.wavfile.write("bark_out.wav", rate=sampling_rate, data=speech_values.cpu().numpy().squeeze())
    return ("bark_out.wav")

with gr.Blocks() as app:
    in_text = gr.Textbox()
    out_audio = gr.Audio()
    go_btn = gr.Button()

    go_btn.click(run_bark,in_text,out_audio)

app.launch()