NotProwler commited on
Commit
e82ae6d
·
verified ·
1 Parent(s): 9762ef8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -7
app.py CHANGED
@@ -1,12 +1,10 @@
1
  import streamlit as st
2
- from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
3
- import torchaudio
4
  from audiocraft.models import MusicGen
5
- from audiocraft.data.audio import audio_write
6
 
7
  @st.cache_resource
8
  def load_musicgen_model():
9
- model = MusicGen.get_pretrained('melody')
10
  model.set_generation_params(duration=10)
11
  return model
12
 
@@ -27,8 +25,6 @@ if st.button("Generate Song"):
27
 
28
  audio_output = model.generate([description])
29
 
30
- audio_write("generated_song.wav", audio_output[0].cpu(), model.sample_rate)
31
-
32
- st.audio("generated_song.wav", format="audio/wav")
33
 
34
  st.write("Enjoy your personalized music experience! 🎼")
 
1
  import streamlit as st
2
+ from transformers import AutoProcessor, AutoModelForCausalLM
 
3
  from audiocraft.models import MusicGen
 
4
 
5
  @st.cache_resource
6
  def load_musicgen_model():
7
+ model = MusicGen.get_pretrained("facebook/musicgen-large")
8
  model.set_generation_params(duration=10)
9
  return model
10
 
 
25
 
26
  audio_output = model.generate([description])
27
 
28
+ st.audio(audio_output[0].cpu().detach().numpy(), format="audio/wav")
 
 
29
 
30
  st.write("Enjoy your personalized music experience! 🎼")