File size: 619 Bytes
d09b0b5
 
 
 
 
 
 
 
 
 
d1fd3ad
 
 
d09b0b5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from transformers import pipeline
import scipy
import gradio as gr
synthesiser = pipeline("text-to-audio", "facebook/musicgen-small")
def generate_music(Prompt):
 music = synthesiser(Prompt, forward_params={"do_sample": True, "max_new_tokens":100})
 rate = music["sampling_rate"]
 mus = music["audio"][0].reshape(-1)
 return rate,mus

inf = gr.Interface(generate_music,title = "Mashdemy Demo Music Generator App", description = """Type in the kind
of music you prefer and click submit""", inputs =["text"], outputs=["audio"], examples = ["""lo-fi music with a soothing
melody""", "pop music"])
inf.launch(share = True)