Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
4f864e1
1
Parent(s):
8ae81eb
tuple and str i guess
Browse files
app.py
CHANGED
@@ -121,16 +121,17 @@ def generate_midi(seed, use_chords, chord_progression, bpm):
|
|
121 |
|
122 |
@spaces.GPU(duration=120)
|
123 |
def generate_music(midi_audio, prompt_duration, musicgen_model, num_iterations, bpm):
|
124 |
-
|
125 |
|
126 |
-
#
|
127 |
-
song =
|
|
|
128 |
|
129 |
# Use the user-provided BPM value for duration calculation
|
130 |
duration = calculate_duration(bpm)
|
131 |
|
132 |
# Create slices from the song using the user-provided BPM value
|
133 |
-
slices = create_slices(song,
|
134 |
|
135 |
# Load the model
|
136 |
model_name = musicgen_model.split(" ")[0]
|
|
|
121 |
|
122 |
@spaces.GPU(duration=120)
|
123 |
def generate_music(midi_audio, prompt_duration, musicgen_model, num_iterations, bpm):
|
124 |
+
wav_filename, sample_rate = midi_audio
|
125 |
|
126 |
+
# Load the generated audio
|
127 |
+
song, sr = torchaudio.load(wav_filename)
|
128 |
+
song = song.to(device)
|
129 |
|
130 |
# Use the user-provided BPM value for duration calculation
|
131 |
duration = calculate_duration(bpm)
|
132 |
|
133 |
# Create slices from the song using the user-provided BPM value
|
134 |
+
slices = create_slices(song, sr, 35, bpm, num_slices=5)
|
135 |
|
136 |
# Load the model
|
137 |
model_name = musicgen_model.split(" ")[0]
|