Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
import scipy
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
synthesiser = pipeline("text-to-audio", "facebook/musicgen-small")
|
| 6 |
+
|
| 7 |
+
def generate_music(Prompt):
|
| 8 |
+
music = synthesiser(Prompt, forward_params={"do_sample": True, "max_new_tokens":50})
|
| 9 |
+
|
| 10 |
+
# scipy.io.wavfile.write("musicgen_out2.wav", rate=music["sampling_rate"], data=music["audio"])
|
| 11 |
+
rate = music["sampling_rate"]
|
| 12 |
+
mus = music["audio"][0].reshape(-1)
|
| 13 |
+
return rate,mus
|
| 14 |
+
|
| 15 |
+
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"])
|
| 16 |
+
inf.launch(debug = True)
|