Sergiosamyy commited on
Commit
228dc63
verified
1 Parent(s): 7de792f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -11
app.py CHANGED
@@ -1,18 +1,27 @@
1
- import gradio as gr
2
  import torch
3
- from transformers import AutoProcessor
4
  from audiocraft.models import MusicGen
5
 
6
- def probar_imports():
7
- return "隆Las importaciones funcionan sin errores!"
 
 
 
 
 
 
 
 
8
 
9
  demo = gr.Interface(
10
- fn=probar_imports,
11
- inputs=None,
12
- outputs="text",
13
- title="Prueba de imports",
14
- description="Si esto funciona, significa que no hay error de sintaxis."
15
  )
16
 
17
- if __name__ == "__main__":
18
- demo.launch()
 
 
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
+ model = MusicGen.get_pretrained('facebook/musicgen-small')
8
+
9
+ #Funci贸n para generar m煤sica
10
+ def generar_musica(descripcion):
11
+ model.set_generation_params(duration=10) # Duraci贸n en segundos
12
+ output = model.generate(descriptions=[descripcion])
13
+ output_path = "output.wav"
14
+ model.save_wav(output[0], output_path)
15
+ return output_path
16
 
17
  demo = gr.Interface(
18
+ fn=generar_musica,
19
+ inputs=gr.Textbox(label="Descripci贸n de la m煤sica"),
20
+ outputs=gr.Audio(label="M煤sica Generada"),
21
+ title="Generador de M煤sica AI",
22
+ description="Introduce una descripci贸n y genera una pista de m煤sica."
23
  )
24
 
25
+ if name == "main":
26
+ demo.launch()
27
+