Spaces:
Running
Running
admin
commited on
Commit
Β·
816d023
1
Parent(s):
c74f66c
fix filename output
Browse files- app.py +12 -12
- tutorial.mp4 β demo.mp4 +0 -0
app.py
CHANGED
@@ -66,7 +66,7 @@ def get_args(parser: argparse.ArgumentParser):
|
|
66 |
"-template",
|
67 |
type=bool,
|
68 |
default=True,
|
69 |
-
help="whether to generate by
|
70 |
)
|
71 |
return parser.parse_args()
|
72 |
|
@@ -121,7 +121,7 @@ def generate_music(
|
|
121 |
temperature = args.temperature
|
122 |
seed = args.seed
|
123 |
show_control_code = args.show_control_code
|
124 |
-
|
125 |
print(" Hyper parms ".center(60, "#"), "\n")
|
126 |
args_dict: dict = vars(args)
|
127 |
for arg in args_dict.keys():
|
@@ -130,7 +130,7 @@ def generate_music(
|
|
130 |
print("\n", " Output tunes ".center(60, "#"))
|
131 |
start_time = time.time()
|
132 |
for i in range(num_tunes):
|
133 |
-
title = f"T:{
|
134 |
artist = f"C:Generated by AI\n"
|
135 |
tune = f"X:{str(i + 1)}\n{title}{artist}{prompt}"
|
136 |
lines = re.split(r"(\n)", tune)
|
@@ -174,7 +174,7 @@ def generate_music(
|
|
174 |
tokens = None
|
175 |
if predicted_patch[0] != patchilizer.eos_token_id:
|
176 |
next_bar = patchilizer.decode([predicted_patch])
|
177 |
-
if show_control_code or next_bar[:2] not in ["S:", "B:", "E:"]:
|
178 |
print(next_bar, end="")
|
179 |
tune += next_bar
|
180 |
|
@@ -243,8 +243,8 @@ def generate_music(
|
|
243 |
fix_pitch,
|
244 |
)
|
245 |
tunes = tunes.replace(title + title, title)
|
246 |
-
os.rename(xml, f"{outdir}/[{
|
247 |
-
xml = f"{outdir}/[{
|
248 |
|
249 |
else:
|
250 |
if mode == "minor":
|
@@ -258,11 +258,11 @@ def generate_music(
|
|
258 |
offset,
|
259 |
)
|
260 |
tunes = tunes.replace(title + title, title)
|
261 |
-
os.rename(xml, f"{outdir}/[{
|
262 |
-
xml = f"{outdir}/[{
|
263 |
|
264 |
else:
|
265 |
-
xml = abc2xml(tunes, f"{outdir}/[{
|
266 |
|
267 |
audio = xml2(xml, "wav")
|
268 |
if fix_volume != None:
|
@@ -413,7 +413,7 @@ if __name__ == "__main__":
|
|
413 |
with gr.Row():
|
414 |
with gr.Column():
|
415 |
gr.Video(
|
416 |
-
"./
|
417 |
label="Video demo",
|
418 |
show_download_button=False,
|
419 |
show_share_button=False,
|
@@ -445,7 +445,7 @@ if __name__ == "__main__":
|
|
445 |
label="Generate chords (coming soon)",
|
446 |
value=False,
|
447 |
)
|
448 |
-
|
449 |
gr.Markdown("# Generate by feature control")
|
450 |
std_option = gr.Radio(["Low", "High"], label="Pitch SD", value="High")
|
451 |
mode_option = gr.Radio(["Minor", "Major"], label="Mode", value="Major")
|
@@ -516,7 +516,7 @@ if __name__ == "__main__":
|
|
516 |
allow_flagging="never",
|
517 |
)
|
518 |
|
519 |
-
|
520 |
fn=infer_by_template,
|
521 |
inputs=[dataset_option, valence_radio, arousal_radio, chord_check],
|
522 |
outputs=[
|
|
|
66 |
"-template",
|
67 |
type=bool,
|
68 |
default=True,
|
69 |
+
help="whether to generate by template",
|
70 |
)
|
71 |
return parser.parse_args()
|
72 |
|
|
|
121 |
temperature = args.temperature
|
122 |
seed = args.seed
|
123 |
show_control_code = args.show_control_code
|
124 |
+
fname_prefix = emo if args.template else "Melody"
|
125 |
print(" Hyper parms ".center(60, "#"), "\n")
|
126 |
args_dict: dict = vars(args)
|
127 |
for arg in args_dict.keys():
|
|
|
130 |
print("\n", " Output tunes ".center(60, "#"))
|
131 |
start_time = time.time()
|
132 |
for i in range(num_tunes):
|
133 |
+
title = f"T:{fname_prefix} Fragment\n"
|
134 |
artist = f"C:Generated by AI\n"
|
135 |
tune = f"X:{str(i + 1)}\n{title}{artist}{prompt}"
|
136 |
lines = re.split(r"(\n)", tune)
|
|
|
174 |
tokens = None
|
175 |
if predicted_patch[0] != patchilizer.eos_token_id:
|
176 |
next_bar = patchilizer.decode([predicted_patch])
|
177 |
+
if show_control_code or next_bar[:2] not in ["S:", "B:", "E:", "D:"]:
|
178 |
print(next_bar, end="")
|
179 |
tune += next_bar
|
180 |
|
|
|
243 |
fix_pitch,
|
244 |
)
|
245 |
tunes = tunes.replace(title + title, title)
|
246 |
+
os.rename(xml, f"{outdir}/[{fname_prefix}]{timestamp}.musicxml")
|
247 |
+
xml = f"{outdir}/[{fname_prefix}]{timestamp}.musicxml"
|
248 |
|
249 |
else:
|
250 |
if mode == "minor":
|
|
|
258 |
offset,
|
259 |
)
|
260 |
tunes = tunes.replace(title + title, title)
|
261 |
+
os.rename(xml, f"{outdir}/[{fname_prefix}]{timestamp}.musicxml")
|
262 |
+
xml = f"{outdir}/[{fname_prefix}]{timestamp}.musicxml"
|
263 |
|
264 |
else:
|
265 |
+
xml = abc2xml(tunes, f"{outdir}/[{fname_prefix}]{timestamp}.musicxml")
|
266 |
|
267 |
audio = xml2(xml, "wav")
|
268 |
if fix_volume != None:
|
|
|
413 |
with gr.Row():
|
414 |
with gr.Column():
|
415 |
gr.Video(
|
416 |
+
"./demo.mp4",
|
417 |
label="Video demo",
|
418 |
show_download_button=False,
|
419 |
show_share_button=False,
|
|
|
445 |
label="Generate chords (coming soon)",
|
446 |
value=False,
|
447 |
)
|
448 |
+
gen_btn_1 = gr.Button("Generate")
|
449 |
gr.Markdown("# Generate by feature control")
|
450 |
std_option = gr.Radio(["Low", "High"], label="Pitch SD", value="High")
|
451 |
mode_option = gr.Radio(["Minor", "Major"], label="Mode", value="Major")
|
|
|
516 |
allow_flagging="never",
|
517 |
)
|
518 |
|
519 |
+
gen_btn_1.click(
|
520 |
fn=infer_by_template,
|
521 |
inputs=[dataset_option, valence_radio, arousal_radio, chord_check],
|
522 |
outputs=[
|
tutorial.mp4 β demo.mp4
RENAMED
File without changes
|