Skip to content

Commit 398335e

Browse files
committed
Updates Round 2
1 parent 5a39faf commit 398335e

3 files changed

Lines changed: 15 additions & 10 deletions

File tree

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ include audiocraft/py.typed
88
include assets/*.mp3
99
include assets/*.ico
1010
include assets/*.png
11+
include assets/*.ttf
12+
include assets/*.svg
13+
include assets/*.gif

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Check your video's generative metadata with https://mediaarea.net/en/MediaInfo
3535
Also note that I wrote an extension to Gradio for the waveform in the video after v4.48.0 removed it.
3636

3737
The key update here is in the extend utility. We segment melody input and then condition the next segment with current tensors and tensors from the current time in the conditioning melody file.
38-
This allows us to make entire songs that follow the same arraigement of the original.
38+
This allows us to follow the same arraingement of the original melody.
3939

4040
**Thank you Huggingface for the community grant to run this project**!!
4141

app.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ def git_tag():
132132
except Exception:
133133
return "<none>"
134134

135-
def load_melody_filepath(melody_filepath, title):
135+
def load_melody_filepath(melody_filepath, title, assigned_model):
136136
# get melody filename
137137
#$Union[str, os.PathLike]
138138
symbols = ['_', '.', '-']
139139
if (melody_filepath is None) or (melody_filepath == ""):
140-
return title, gr.update(maximum=0, value=0) , gr.update(value="melody-large", interactive=True)
140+
return title, gr.update(maximum=0, value=0) , gr.update(value="medium", interactive=True)
141141

142142
if (title is None) or ("MusicGen" in title) or (title == ""):
143143
melody_name, melody_extension = get_filename_from_filepath(melody_filepath)
@@ -147,7 +147,10 @@ def load_melody_filepath(melody_filepath, title):
147147
else:
148148
melody_name = title
149149

150-
print(f"Melody name: {melody_name}, Melody Filepath: {melody_filepath}\n")
150+
if ("melody" not in assigned_model):
151+
assigned_model = "melody-large"
152+
153+
print(f"Melody name: {melody_name}, Melody Filepath: {melody_filepath}, Model: {assigned_model}\n")
151154

152155
# get melody length in number of segments and modify the UI
153156
melody = get_melody(melody_filepath)
@@ -157,7 +160,7 @@ def load_melody_filepath(melody_filepath, title):
157160
print(f"Melody length: {len(melody_data)}, Melody segments: {total_melodys}\n")
158161
MAX_PROMPT_INDEX = total_melodys
159162

160-
return gr.update(value=melody_name), gr.update(maximum=MAX_PROMPT_INDEX, value=0), gr.update(value="melody", interactive=True)
163+
return gr.update(value=melody_name), gr.update(maximum=MAX_PROMPT_INDEX, value=0), gr.update(value=assigned_model, interactive=True)
161164

162165
def predict(model, text, melody_filepath, duration, dimension, topk, topp, temperature, cfg_coef, background, title, settings_font, settings_font_color, seed, overlap=1, prompt_index = 0, include_title = True, include_settings = True, harmony_only = False):
163166
global MODEL, INTERRUPTED, INTERRUPTING, MOVE_TO_CPU
@@ -441,7 +444,7 @@ def ui(**kwargs):
441444
text = gr.Text(label="Describe your music", interactive=True, value="4/4 100bpm 320kbps 48khz, Industrial/Electronic Soundtrack, Dark, Intense, Sci-Fi")
442445
with gr.Column():
443446
duration = gr.Slider(minimum=1, maximum=720, value=10, label="Duration (s)", interactive=True)
444-
model = gr.Radio(["melody", "medium", "small", "large", "melody-large", "stereo-small", "stereo-medium", "stereo-large", "stereo-melody", "stereo-melody-large"], label="AI Model", value="melody", interactive=True)
447+
model = gr.Radio(["melody", "medium", "small", "large", "melody-large", "stereo-small", "stereo-medium", "stereo-large", "stereo-melody", "stereo-melody-large"], label="AI Model", value="medium", interactive=True)
445448
with gr.Row():
446449
submit = gr.Button("Generate", elem_id="btn-generate")
447450
# Adapted from https://github.com/rkfg/audiocraft/blob/long/app.py, MIT license.
@@ -482,22 +485,21 @@ def ui(**kwargs):
482485
seed_used = gr.Number(label='Seed used', value=-1, interactive=False)
483486

484487
radio.change(toggle_audio_src, radio, [melody_filepath], queue=False, show_progress=False)
485-
melody_filepath.change(load_melody_filepath, inputs=[melody_filepath, title], outputs=[title, prompt_index , model], api_name="melody_filepath_change", queue=False)
488+
melody_filepath.change(load_melody_filepath, inputs=[melody_filepath, title, model], outputs=[title, prompt_index , model], api_name="melody_filepath_change", queue=False)
486489
reuse_seed.click(fn=lambda x: x, inputs=[seed_used], outputs=[seed], queue=False, api_name="reuse_seed")
487490
submit.click(predict, inputs=[model, text,melody_filepath, duration, dimension, topk, topp, temperature, cfg_coef, background, title, settings_font, settings_font_color, seed, overlap, prompt_index, include_title, include_settings, harmony_only], outputs=[output, wave_file, seed_used], api_name="submit")
488491
gr.Examples(
489-
fn=predict,
490492
examples=[
491493
[
492494
"4/4 120bpm 320kbps 48khz, An 80s driving pop song with heavy drums and synth pads in the background",
493495
"./assets/bach.mp3",
494-
"stereo-melody-large",
496+
"melody",
495497
"80s Pop Synth"
496498
],
497499
[
498500
"4/4 120bpm 320kbps 48khz, A cheerful country song with acoustic guitars",
499501
"./assets/bolero_ravel.mp3",
500-
"melody",
502+
"stereo-melody-large",
501503
"Country Guitar"
502504
],
503505
[

0 commit comments

Comments
 (0)