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}) # scipy.io.wavfile.write("musicgen_out2.wav", rate=music["sampling_rate"], data=music["audio"]) 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)