Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,28 @@
|
|
1 |
-
import gradio as gr
|
|
|
|
|
|
|
2 |
|
3 |
-
Cargar el modelo MusicGen
|
4 |
|
5 |
model = MusicGen.get_pretrained('facebook/musicgen-small')
|
6 |
|
7 |
-
Funci贸n para generar m煤sica
|
8 |
|
9 |
-
def generar_musica(descripcion):
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
-
demo = gr.Interface(
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
-
if name == "main":
|
|
|
14 |
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import torch
|
3 |
+
from transformers import AutoProcessor
|
4 |
+
from audiocraft.models import MusicGen
|
5 |
|
6 |
+
#Cargar el modelo MusicGen
|
7 |
|
8 |
model = MusicGen.get_pretrained('facebook/musicgen-small')
|
9 |
|
10 |
+
#Funci贸n para generar m煤sica
|
11 |
|
12 |
+
def generar_musica(descripcion):
|
13 |
+
model.set_generation_params(duration=10) # Duraci贸n en segundos
|
14 |
+
output = model.generate(descriptions=[descripcion])
|
15 |
+
output_path = "output.wav"
|
16 |
+
model.save_wav(output[0], output_path)
|
17 |
+
return output_path
|
18 |
|
19 |
+
demo = gr.Interface(
|
20 |
+
fn=generar_musica,
|
21 |
+
inputs=gr.Textbox(label="Descripci贸n de la m煤sica"),
|
22 |
+
outputs=gr.Audio(label="M煤sica Generada"),
|
23 |
+
title="Generador de M煤sica AI",
|
24 |
+
description="Introduce una descripci贸n y genera una pista de m煤sica." )
|
25 |
|
26 |
+
if name == "main":
|
27 |
+
demo.launch()
|
28 |
|