Dannyar608 commited on
Commit
8486c25
·
verified ·
1 Parent(s): cd99d9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -1,12 +1,14 @@
1
  import gradio as gr
2
  from transformers import MusicGenForConditionalGeneration, MusicGenProcessor
3
  import torch
4
- import soundfile as sf # For saving audio as WAV
5
 
6
- # Load the MusicGen model and processor
 
 
7
  model_name = "facebook/musicgen-small"
8
- model = MusicGenForConditionalGeneration.from_pretrained(model_name)
9
- processor = MusicGenProcessor.from_pretrained(model_name)
10
 
11
  # Define a function to generate audio from text
12
  def generate_audio(text):
 
1
  import gradio as gr
2
  from transformers import MusicGenForConditionalGeneration, MusicGenProcessor
3
  import torch
4
+ import soundfile as sf
5
 
6
+ from transformers import AutoModel, AutoProcessor
7
+
8
+ # Use AutoModel and AutoProcessor to automatically select the correct model and processor
9
  model_name = "facebook/musicgen-small"
10
+ model = AutoModel.from_pretrained(model_name)
11
+ processor = AutoProcessor.from_pretrained(model_name)
12
 
13
  # Define a function to generate audio from text
14
  def generate_audio(text):