DanLeBossDeESGI commited on
Commit
424928b
·
1 Parent(s): 322a712

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -3
app.py CHANGED
@@ -1,6 +1,9 @@
1
  import streamlit as st
2
  from PIL import Image, ImageDraw
3
  import numpy as np
 
 
 
4
 
5
  def greet(name):
6
  return "Saluuuuuuuut " + name + "! Monstre !"
@@ -14,10 +17,8 @@ if name:
14
  st.write("Output:")
15
  st.write(result)
16
 
17
-
18
-
19
 
20
-
21
  # Sélection de l'image
22
  uploaded_image = st.file_uploader("Sélectionnez une image", type=["jpg", "png", "jpeg"])
23
 
@@ -27,3 +28,22 @@ if name:
27
 
28
  # Afficher l'image d'origine
29
  st.image(image, caption="Image d'origine", use_column_width=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  from PIL import Image, ImageDraw
3
  import numpy as np
4
+ import torchaudio
5
+ from audiocraft.models import MusicGen
6
+ from audiocraft.data.audio import audio_write
7
 
8
  def greet(name):
9
  return "Saluuuuuuuut " + name + "! Monstre !"
 
17
  st.write("Output:")
18
  st.write(result)
19
 
 
 
20
 
21
+
22
  # Sélection de l'image
23
  uploaded_image = st.file_uploader("Sélectionnez une image", type=["jpg", "png", "jpeg"])
24
 
 
28
 
29
  # Afficher l'image d'origine
30
  st.image(image, caption="Image d'origine", use_column_width=True)
31
+
32
+
33
+
34
+
35
+
36
+
37
+ model = MusicGen.get_pretrained('melody')
38
+ model.set_generation_params(duration=8) # generate 8 seconds.
39
+
40
+ descriptions = ['happy rock', 'energetic EDM', 'sad jazz']
41
+
42
+ melody, sr = torchaudio.load('./assets/bach.mp3')
43
+ # generates using the melody from the given audio and the provided descriptions.
44
+ wav = model.generate_with_chroma(descriptions, melody[None].expand(3, -1, -1), sr)
45
+
46
+ for idx, one_wav in enumerate(wav):
47
+ # Will save under {idx}.wav, with loudness normalization at -14 db LUFS.
48
+ audio_write(f'{idx}', one_wav.cpu(), model.sample_rate, strategy="loudness")
49
+