-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathcdmf_template.py
More file actions
2205 lines (2022 loc) · 92.8 KB
/
cdmf_template.py
File metadata and controls
2205 lines (2022 loc) · 92.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# C:\AceForge\cdmf_template.py
#
# HTML template for AceForge.
# Refactored so CSS/JS live in static files instead of a giant inline blob.
HTML = r"""
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>AceForge{% if version %} ({{ version }}){% endif %}</title>
<link rel="icon" type="image/png" href="{{ url_for('static', filename='aceforge_logo.png') }}">
<!-- External CSS instead of inline <style> -->
<link rel="stylesheet" href="{{ url_for('static', filename='scripts/cdmf.css') }}">
<!-- MIDIjs library for MIDI file playback -->
<script type='text/javascript' src='//www.midijs.net/lib/midi.js'></script>
</head>
<body>
<div class="page">
<div class="cd-titlebar">
<div class="cd-titlewrap">
<span class="cd-logo">
<img
src="{{ url_for('static', filename='aceforge_logo.png') }}"
alt="AceForge logo"
>
</span>
</div>
<div style="display:flex;align-items:center;gap:8px;">
<span class="cd-alpha">{{ version or 'dev' }}</span>
<button type="button" class="btn danger exit" id="btnExitApp" title="Exit AceForge">
<span class="icon">🚪</span><span class="label">Exit</span>
</button>
</div>
</div>
<!-- Two-column layout container -->
<div class="two-column-layout">
<!-- Left column: Generation and Training -->
<div class="column-left">
<!-- Mode tabs: Generate vs Training vs Voice Cloning ---------------------------------- -->
<div class="tab-row" style="margin-top:16px;">
<button
type="button"
class="tab-btn tab-btn-active mode-tab-btn"
data-mode="generate"
onclick="window.CDMF && CDMF.switchMode && CDMF.switchMode('generate');">
Generate
</button>
<button
type="button"
class="tab-btn mode-tab-btn"
data-mode="train"
onclick="window.CDMF && CDMF.switchMode && CDMF.switchMode('train');">
Training
</button>
<button
type="button"
class="tab-btn mode-tab-btn"
data-mode="voice_clone"
onclick="window.CDMF && CDMF.switchMode && CDMF.switchMode('voice_clone');">
Voice Cloning
</button>
<button
type="button"
class="tab-btn mode-tab-btn"
data-mode="stem_split"
onclick="window.CDMF && CDMF.switchMode && CDMF.switchMode('stem_split');">
Stem Splitting
</button>
<button
type="button"
class="tab-btn mode-tab-btn"
data-mode="midi_gen"
onclick="window.CDMF && CDMF.switchMode && CDMF.switchMode('midi_gen');">
MIDI Generation
</button>
</div>
<!-- Generation form card (mode: generate) ----------------------------- -->
<form
id="generateForm"
class="card card-mode"
data-mode="generate"
method="post"
action="{{ url_for('cdmf_generation.generate') }}"
target="generation_frame"
enctype="multipart/form-data"
onsubmit="return CDMF.onSubmitForm(event)">
<div class="card-header-row">
<div style="flex:1;min-width:0;">
<h2>Generate Track</h2>
<div id="loadingBar" class="loading-bar">
<div class="loading-bar-inner"></div>
</div>
</div>
<div style="display:flex;gap:8px;align-items:center;">
<button id="generateButton" type="submit" class="btn primary">
<span class="icon">🎧</span><span>Generate</span>
</button>
</div>
</div>
<div
id="modelStatusNotice"
class="toast"
style="margin-top:8px; {{ 'display:none;' if models_ready else 'display:block;' }}">
{% if not models_ready %}
ACE-Step model is not downloaded yet. Click "Download Models" to start the download.
This is a large download (multiple GB) and may take several minutes. Keep the console
window open; it will show detailed progress.
{% endif %}
</div>
<!-- Hidden preset metadata used to auto-tag generated tracks -->
<input id="preset_id" name="preset_id" type="hidden" value="">
<input id="preset_category" name="preset_category" type="hidden" value="">
<!-- Core vs Advanced control tabs -->
<div class="tab-row">
<button
type="button"
id="tab_core"
class="tab-btn tab-btn-active"
onclick="CDMF.switchKnobTab('core')">
Core
</button>
<button
type="button"
id="tab_advanced"
class="tab-btn"
onclick="CDMF.switchKnobTab('advanced')">
Advanced
</button>
</div>
<!-- Core knobs: everything you already had -->
<div id="coreKnobs">
<div class="row">
<label for="basename">Base filename</label>
<input id="basename" name="basename" type="text" value="{{ basename or 'Candy Dreams' }}" required>
<div class="small">Required. Used as the base name for the generated track file (e.g. My Track.wav).</div>
</div>
<div class="row" id="autoPromptLyricsRow">
<label>Auto prompt / lyrics</label>
<div style="flex:1;display:flex;flex-wrap:wrap;align-items:center;gap:8px;min-width:0%;">
<button
type="button"
class="btn"
id="btnAutoPromptLyrics"
onclick="CDMF.onAutoPromptLyricsButtonClick()">
<span class="icon">✨</span><span class="label">Generate prompt / lyrics…</span>
</button>
</div>
</div>
<div class="small" style="margin-top:-4px;margin-bottom:8px;">
Opens a small dialog where you can type a song concept and choose whether to
generate a <strong>prompt</strong>, <strong>lyrics</strong>, or <strong>both</strong>.
Lyrics only affect audio when <strong>Instrumental</strong> is <em>unchecked</em>.
</div>
<div class="row">
<label for="prompt">Genre / Style Prompt</label>
<textarea id="prompt" name="prompt" placeholder="Describe the genre, mood, instruments, and vibe...">{{ prompt or "" }}</textarea>
</div>
<!-- Preset banks: instrumental vs vocal (toggled by Instrumental checkbox) -->
<div>
<!-- Instrumental presets -->
<div class="preset-buttons" id="presetGroupInstrumental">
{% for p in presets.instrumental %}
<button type="button" class="btn" onclick="CDMF.setPreset('{{ p.id }}')">
<span class="icon">{{ p.icon }}</span><span>{{ p.label }}</span>
</button>
{% endfor %}
<button type="button" class="btn" onclick="CDMF.setPreset('random_instrumental')">
<span class="icon">🎲</span><span>Random</span>
</button>
</div>
<!-- Vocal presets -->
<div class="preset-buttons" id="presetGroupVocal" style="display:none;">
{% for p in presets.vocal %}
<button type="button" class="btn" onclick="CDMF.setPreset('{{ p.id }}')">
<span class="icon">{{ p.icon }}</span><span>{{ p.label }}</span>
</button>
{% endfor %}
<button type="button" class="btn" onclick="CDMF.setPreset('random_vocal')">
<span class="icon">🎲</span><span>Random Vocal</span>
</button>
</div>
</div>
<div class="row">
<label for="instrumental">Instrumental</label>
<div style="display:flex;align-items:center;gap:8px;flex:1;">
<input id="instrumental"
name="instrumental"
type="checkbox"
autocomplete="off"
{% if instrumental is defined and instrumental %}checked{% endif %}
onchange="CDMF.onInstrumentalToggle()">
<span class="small">
Instrumental only (no vocals, no lyrics, no spoken word). Turn off to allow lyrics.
</span>
</div>
</div>
<div class="row" id="lyricsRow" style="display:none; flex-direction:column; align-items:stretch;">
<div style="display:flex;align-items:center;justify-content:space-between;gap:8px;width:100%;">
<label for="lyrics" style="margin:0;">Lyrics (optional)</label>
<button type="button" class="btn" id="btnClearLyrics">
<span class="icon">🧹</span><span class="label">Clear</span>
</button>
</div>
<textarea id="lyrics"
name="lyrics"
placeholder="Add lyrics here when Instrumental is off. You can use [verse], [chorus], [solo], [outro] markers. For instrumentals the backend automatically uses [inst].">{{ lyrics or "" }}</textarea>
</div>
<!-- Negative prompt is currently unused by ACE-Step.
Keep a hidden, always-empty field so the form stays stable. -->
<input id="negative_prompt" name="negative_prompt" type="hidden" value="">
<hr style="border:none;border-top:1px solid #111827;margin:12px 0;">
<!-- Seed vibe is now an internal knob (used by presets only).
Keep it as a hidden field so JS and the backend can still use it. -->
<input
id="seed_vibe"
name="seed_vibe"
type="hidden"
value="{{ seed_vibe or 'any' }}"
>
<div class="slider-row">
<label for="target_seconds">Target length (seconds)</label>
<input id="target_seconds_range" type="range" min="15" max="240" step="5"
value="{{ target_seconds or UI_DEFAULT_TARGET_SECONDS }}" oninput="CDMF.syncRange('target_seconds', 'target_seconds_range')">
<input id="target_seconds" name="target_seconds" type="number" min="15" max="240" step="5"
value="{{ target_seconds or UI_DEFAULT_TARGET_SECONDS }}" oninput="CDMF.syncNumber('target_seconds', 'target_seconds_range')">
</div>
<div class="small">
ACE-Step is asked for this length; the actual duration can be approximate.
</div>
<div class="slider-row">
<label for="fade_in">Fade in (seconds)</label>
<input id="fade_in_range" type="range" min="0" max="5" step="0.1"
value="{{ fade_in or UI_DEFAULT_FADE_IN }}" oninput="CDMF.syncRange('fade_in', 'fade_in_range')">
<input id="fade_in" name="fade_in" type="number" min="0" max="5" step="0.1"
value="{{ fade_in or UI_DEFAULT_FADE_IN }}" oninput="CDMF.syncNumber('fade_in', 'fade_in_range')">
</div>
<div class="slider-row">
<label for="fade_out">Fade out (seconds)</label>
<input id="fade_out_range" type="range" min="0" max="5" step="0.1"
value="{{ fade_out or UI_DEFAULT_FADE_OUT }}" oninput="CDMF.syncRange('fade_out', 'fade_out_range')">
<input id="fade_out" name="fade_out" type="number" min="0" max="5" step="0.1"
value="{{ fade_out or UI_DEFAULT_FADE_OUT }}" oninput="CDMF.syncNumber('fade_out', 'fade_out_range')">
</div>
<div class="slider-row">
<label for="steps">Inference steps</label>
<input id="steps" name="steps" type="number" min="10" max="300" step="1"
value="{{ steps or UI_DEFAULT_STEPS }}">
<span class="small">50 - 125 is a good range; higher is slower but sometimes richer. Very high is likely to degrade quality/produce strange results.</span>
</div>
<div class="slider-row">
<label for="guidance_scale">Guidance scale</label>
<input id="guidance_scale" name="guidance_scale" type="number" min="0.5" max="20" step="0.5"
value="{{ guidance_scale or UI_DEFAULT_GUIDANCE }}">
<span class="small">How strongly ACE-Step follows your text tags. High values may lead to noise/artifacts.</span>
</div>
<div class="slider-row">
<label for="bpm">Beats per minute (optional)</label>
<input id="bpm" name="bpm" type="number" min="40" max="240" step="1"
value="{{ bpm or '' }}">
<span class="small">
Leave blank for auto tempo. If set, a hint like "tempo 120 bpm"
is added to the tags.
</span>
</div>
<div class="slider-row">
<label for="seed">Seed</label>
<div style="display:flex;align-items:center;gap:8px;flex:1;">
<input
id="seed"
name="seed"
type="number"
step="1"
value="{{ seed or 0 }}"
style="width:120px;"
>
<label class="small" style="display:flex;align-items:center;gap:4px;cursor:pointer;">
<input
id="seed_random"
name="seed_random"
type="checkbox"
checked
>
Random
</label>
</div>
<span class="small">
When Random is checked, a new seed is chosen each time you generate.
Uncheck to lock and reuse a specific seed.
</span>
</div>
<hr style="border:none;border-top:1px solid #111827;margin:16px 0 8px;">
<div class="small" style="font-weight:600;opacity:0.9;margin-bottom:4px;">
<b>Vocal vs. instrumental levels</b>
</div>
<div class="small">
<br>Post-mix adjustment for vocals and instrumentals after ACE-Step finishes the track.
0 dB leaves a track as-is; negative values push them back, positive values bring them forward.
<br><br><strong>Note:</strong> Be aware that adjusting track volume will require downloading a new model on the first run and that it will cause generation to take significantly longer. It is recommended to generate a song at normal volumes first, then turn off Random Seed, leave all generation settings as preferred, and THEN adjust volumes if desired.
</div>
<!-- Final mix: vocal vs instrumental levels (post-process in dB) -->
<div class="slider-row">
<label for="vocal_gain_db">Vocals level (dB)</label>
<input
id="vocal_gain_db_range"
type="range"
min="-24"
max="12"
step="0.5"
value="{{ vocal_gain_db or UI_DEFAULT_VOCAL_GAIN_DB }}"
oninput="CDMF.syncRange('vocal_gain_db', 'vocal_gain_db_range')">
<input
id="vocal_gain_db"
name="vocal_gain_db"
type="number"
min="-24"
max="12"
step="0.5"
value="{{ vocal_gain_db or UI_DEFAULT_VOCAL_GAIN_DB }}"
oninput="CDMF.syncNumber('vocal_gain_db', 'vocal_gain_db_range')">
</div>
<div class="slider-row">
<label for="instrumental_gain_db">Instrumental level (dB)</label>
<input
id="instrumental_gain_db_range"
type="range"
min="-24"
max="12"
step="0.5"
value="{{ instrumental_gain_db or UI_DEFAULT_INSTRUMENTAL_GAIN_DB }}"
oninput="CDMF.syncRange('instrumental_gain_db', 'instrumental_gain_db_range')">
<input
id="instrumental_gain_db"
name="instrumental_gain_db"
type="number"
min="-24"
max="12"
step="0.5"
value="{{ instrumental_gain_db or UI_DEFAULT_INSTRUMENTAL_GAIN_DB }}"
oninput="CDMF.syncNumber('instrumental_gain_db', 'instrumental_gain_db_range')">
</div>
<div class="small">
Post-mix adjustment for the backing track / instrumental stem.
0 dB is neutral; negative values make the backing quieter, positive values make it louder.
</div>
</div> <!-- /coreKnobs -->
<!-- Advanced ACE-Step knobs -->
<div id="advancedKnobs" style="display:none;">
<div class="small tab-hint">
Advanced ACE-Step controls. Defaults are usually fine; tweak sparingly.
</div>
<div class="row">
<label for="scheduler_type">Scheduler</label>
<select id="scheduler_type" name="scheduler_type">
<option value="euler">Euler</option>
<option value="heun">Heun</option>
<option value="pingpong">Ping-pong</option>
</select>
</div>
<div class="row">
<label for="cfg_type">CFG mode</label>
<select id="cfg_type" name="cfg_type">
<option value="apg">APG (recommended)</option>
<option value="cfg">CFG</option>
<option value="cfg_star">CFG★</option>
</select>
</div>
<div class="slider-row">
<label for="omega_scale">Omega scale</label>
<input id="omega_scale" name="omega_scale" type="number" min="1" max="30" step="0.5" value="5">
<span class="small">
Controls granularity; higher can add detail but may hurt stability.
</span>
</div>
<div class="slider-row">
<label for="guidance_interval">Guidance interval</label>
<input id="guidance_interval" name="guidance_interval" type="number" min="0" max="1" step="0.05" value="1.0">
<span class="small">
How often guidance is applied during diffusion (0–1).
</span>
</div>
<div class="slider-row">
<label for="guidance_interval_decay">Interval decay</label>
<input id="guidance_interval_decay" name="guidance_interval_decay" type="number" min="0" max="1" step="0.05" value="0.0">
<span class="small">
Lets guidance back off over time (0 = no decay).
</span>
</div>
<div class="slider-row">
<label for="min_guidance_scale">Min guidance</label>
<input id="min_guidance_scale" name="min_guidance_scale" type="number" min="0" max="20" step="0.5" value="3.0">
<span class="small">
Lower bound for guidance when using intervals/decay.
</span>
</div>
<div class="row">
<label>ERG switches</label>
<div class="checkbox-row">
<label class="small">
<input type="checkbox" id="use_erg_tag" name="use_erg_tag" checked>
Tag
</label>
<label class="small">
<input type="checkbox" id="use_erg_lyric" name="use_erg_lyric" checked>
Lyric
</label>
<label class="small">
<input type="checkbox" id="use_erg_diffusion" name="use_erg_diffusion" checked>
Diffusion
</label>
</div>
</div>
<div class="row">
<label for="oss_steps">Custom steps (optional)</label>
<input id="oss_steps" name="oss_steps" type="text"
placeholder="Comma-separated sigma steps, e.g. 0, 10, 20, 30">
</div>
<!-- Repainting / Extend subsection -------------------------------- -->
<hr style="border:none;border-top:1px solid #111827;margin:12px 0 8px;">
<div class="small" style="font-weight:600;opacity:0.9;margin-bottom:4px;">
Repainting / extend tasks -- (under construction)
</div>
<div class="row">
<label for="task">Task</label>
<select id="task" name="task">
<option value="text2music">Text → music (default)</option>
<option value="retake">Retake / variation</option>
<option value="repaint">Repaint segment</option>
<option value="extend">Extend tail</option>
</select>
</div>
<div class="slider-row">
<label for="repaint_start">Repaint start (sec)</label>
<input id="repaint_start" name="repaint_start" type="number" min="0" step="0.1" value="0">
</div>
<div class="slider-row">
<label for="repaint_end">Repaint end (sec)</label>
<input id="repaint_end" name="repaint_end" type="number" min="0" step="0.1" value="0">
</div>
<div class="slider-row">
<label for="retake_variance">Retake variance</label>
<input id="retake_variance" name="retake_variance" type="number" min="0" max="1" step="0.05" value="0.5">
</div>
<!-- Audio2Audio subsection ----------------------------------------- -->
<hr style="border:none;border-top:1px solid #111827;margin:16px 0 8px;">
<div class="small" style="font-weight:600;opacity:0.9;margin-bottom:4px;">
Audio2Audio remix (reference track)
</div>
<!-- Hidden flag; JS will flip this based on whether a ref file is provided -->
<input
type="hidden"
id="audio2audio_enable"
name="audio2audio_enable"
value=""
>
<div class="slider-row">
<label for="ref_audio_strength">Ref strength</label>
<input id="ref_audio_strength" name="ref_audio_strength" type="number" min="0" max="1" step="0.05" value="0.7">
<span class="small">
0 = mostly ignore reference, 1 = strongly follow its groove / texture.
</span>
</div>
<div class="row">
<label for="ref_audio_file">Ref audio</label>
<div style="flex:1;display:flex;flex-direction:column;gap:6px;min-width:0;">
<input
id="ref_audio_file"
name="ref_audio_file"
type="file"
accept=".wav,.mp3,audio/*"
>
<input
id="src_audio_path"
name="src_audio_path"
type="text"
placeholder="Optional manual path on disk (advanced)"
>
<span class="small">
Drop in an existing track to use as a style / groove reference.
ACE-Step will analyse the reference and blend it with your prompt.
MP3s are automatically converted to WAV before processing.
</span>
</div>
</div>
<!-- LoRA subsection ------------------------------------------------ -->
<hr style="border:none;border-top:1px solid #111827;margin:16px 0 8px;">
<div class="small" style="font-weight:600;opacity:0.9;margin-bottom:4px;">
LoRA adapter (fine-tuning)
</div>
<div class="row">
<label for="lora_select">Installed LoRAs</label>
<div style="flex:1;display:flex;align-items:center;gap:6px;min-width:0;">
<select id="lora_select" style="flex:1;min-width:0;">
<option value="">(None)</option>
{% for a in lora_adapters %}
<option value="{{ a.path }}">
{{ a.name }}{% if a.size_bytes %} ({{ "%.1f"|format(a.size_bytes / (1024*1024)) }} MB){% endif %}
</option>
{% endfor %}
</select>
<button type="button" class="btn" id="btnApplyLora">
<span class="icon">⬇</span><span class="label">Use</span>
</button>
<button type="button" class="btn" id="btnClearLora">
<span class="icon">✖</span><span class="label">Clear</span>
</button>
</div>
</div>
<div class="row">
<label>LoRA adapter</label>
<div style="flex:1;display:flex;flex-direction:column;gap:6px;min-width:0;">
<div style="display:flex;gap:8px;align-items:center;min-width:0;">
<input
id="lora_name_or_path"
name="lora_name_or_path"
type="text"
placeholder="Name of LoRA subfolder within <root>\\custom_lora"
style="flex:1;min-width:0;">
<button
type="button"
class="btn"
id="btnLoraBrowse">
<span class="icon">📂</span><span class="label">Browse…</span>
</button>
</div>
<span class="small">
Click <strong>Browse…</strong>, then select the subfolder that contains your trained LoRA.
The folder must contain a file such as
<code>pytorch_lora_weights.safetensors</code>.
If left empty, ACE-Step will use the base model only.
<br><br>
Advanced users can also type a full local folder path or a Hugging Face LoRA repository ID.
</span>
<!-- Hidden folder picker -->
<input
id="lora_folder_picker"
type="file"
name="lora_folder"
style="display:none;"
webkitdirectory
directory
multiple>
</div>
</div>
<div class="slider-row">
<label for="lora_weight">LoRA weight</label>
<input id="lora_weight" name="lora_weight" type="number" min="0" max="10" step="0.05" value="0.5">
<span class="small">
0 = disable adapter, 1 = full effect, >1 = exaggerate its effect (likely to produce artifacts at high levels).
</span>
</div>
</div> <!-- /advancedKnobs -->
<!-- Saved presets --------------------------------------------------- -->
<hr style="border:none;border-top:1px solid #111827;margin:16px 0 8px;">
<div class="small" style="font-weight:600;opacity:0.9;margin-bottom:4px;">
<b>Saved presets</b>
</div>
<div class="row">
<label for="userPresetSelect">My presets</label>
<div style="flex:1;display:flex;align-items:center;gap:6px;min-width:0;">
<select id="userPresetSelect" style="flex:1;min-width:0;">
<option value="">(No saved presets yet)</option>
</select>
<button type="button" class="btn" id="btnLoadUserPreset">
<span class="icon">⬇</span><span class="label">Load</span>
</button>
<button type="button" class="btn" id="btnSaveUserPreset">
<span class="icon">💾</span><span class="label">Save</span>
</button>
<button type="button" class="btn" id="btnDeleteUserPreset">
<span class="icon">🗑</span><span class="label">Delete</span>
</button>
</div>
</div>
<div class="small">
Save and reuse your favorite prompt / knob combinations. Select a preset and click Load,
or click Save to capture the current settings. Delete removes the selected preset.
</div>
<!-- Hidden output directory field (synced with Settings panel) -->
<input id="out_dir" name="out_dir" type="hidden" value="{{ out_dir or default_out_dir }}">
{% if short_message %}
<div class="toast {{ 'error' if error else '' }}">
{{ short_message }}
{% if details %}
<button type="button" class="btn" style="margin-left:8px;padding-inline:10px;"
onclick="CDMF.toggleDetails()">
<span class="icon">📄</span><span>Details</span>
</button>
{% endif %}
</div>
{% endif %}
{% if details %}
<div id="detailsPanel" class="details-panel" style="{{ 'display:block;' if (error and details) else 'display:none;' }}">
{{ details }}
</div>
{% endif %}
<div class="footer">
Tip: Start with 0.5–2.0s fade in/out. When “Instrumental” is checked, AceForge sends [inst] as the ACE-Step lyrics token so the model focuses on backing tracks. ACE-Step can generate up to ~4 minutes in one shot, so you don't need tiling or stitching here.
</div>
</form>
<!-- Modal: Generate prompt / lyrics from concept -->
<div
id="autoPromptLyricsModal"
style="
position:fixed;
inset:0;
display:none;
align-items:center;
justify-content:center;
background:rgba(0,0,0,0.55);
z-index:2000;
">
<div
class="card"
style="max-width:560px;width:100%;box-shadow:0 20px 45px rgba(0,0,0,0.55);">
<div class="card-header-row">
<h3>Generate prompt / lyrics</h3>
</div>
<div class="row">
<label for="apl_concept">Song concept</label>
<textarea
id="apl_concept"
rows="4"
placeholder="e.g. melancholic SNES overworld at night, soft chiptune pads, distant city lights..."></textarea>
</div>
<div class="row">
<label>Generate</label>
<div style="flex:1;display:flex;flex-wrap:wrap;gap:8px;align-items:center;min-width:0;">
<label class="small" style="display:flex;align-items:center;gap:4px;cursor:pointer;">
<input
type="radio"
name="apl_mode"
id="apl_mode_prompt"
value="prompt">
Prompt only
</label>
<label class="small" style="display:flex;align-items:center;gap:4px;cursor:pointer;">
<input
type="radio"
name="apl_mode"
id="apl_mode_lyrics"
value="lyrics">
Lyrics only
</label>
<label class="small" style="display:flex;align-items:center;gap:4px;cursor:pointer;">
<input
type="radio"
name="apl_mode"
id="apl_mode_both"
value="both">
Prompt + lyrics
</label>
</div>
</div>
<div class="small" style="margin-top:-4px;margin-bottom:8px;">
Defaults to <strong>Prompt only</strong> when <strong>Instrumental</strong> is checked,
or <strong>Prompt + lyrics</strong> when it is unchecked.
Lyrics only affect audio when <strong>Instrumental</strong> is <em>unchecked</em>.
</div>
<div class="row" style="justify-content:flex-end;gap:8px;">
<button
type="button"
class="btn"
onclick="CDMF.closeAutoPromptLyricsModal()">
<span class="icon">✖</span><span class="label">Cancel</span>
</button>
<button
type="button"
class="btn primary"
id="apl_generate"
onclick="CDMF.autoPromptLyricsFromConcept()">
<span class="icon">✨</span><span class="label">Generate</span>
</button>
</div>
</div>
</div>
<!-- Voice Cloning form card (mode: voice_clone) ----------------------------- -->
<form
id="voiceCloneForm"
class="card card-mode"
data-mode="voice_clone"
method="post"
action="{{ url_for('cdmf_voice_cloning.voice_clone') }}"
enctype="multipart/form-data"
onsubmit="return CDMF.onSubmitVoiceClone(event)"
style="display:none;">
<div class="card-header-row">
<div style="flex:1;min-width:0;">
<h2>Voice Cloning</h2>
<div id="voiceCloneLoadingBar" class="loading-bar" style="display:none;">
<div class="loading-bar-inner"></div>
</div>
</div>
<div style="display:flex;gap:8px;align-items:center;">
<button id="voiceCloneButton" type="submit" class="btn primary">
<span class="icon">🎤</span><span>Clone Voice</span>
</button>
</div>
</div>
<div class="small" style="margin-top:8px;margin-bottom:16px;">
Clone a voice from a reference audio file using XTTS v2. Upload a reference audio file (MP3/WAV) and enter text to synthesize.
</div>
<div class="row">
<label for="voice_clone_text">Text to Synthesize</label>
<textarea
id="voice_clone_text"
name="text"
rows="4"
placeholder="Enter the text you want to synthesize in the cloned voice..."
required></textarea>
</div>
<div class="row">
<label for="speaker_wav">Reference Audio File</label>
<input
id="speaker_wav"
name="speaker_wav"
type="file"
accept="audio/*,.mp3,.wav,.m4a,.flac"
required>
<div class="small">
Upload a reference audio file (MP3, WAV, M4A, or FLAC) containing the voice you want to clone.
</div>
</div>
<div class="row">
<label for="voice_clone_output_filename">Output filename</label>
<input
id="voice_clone_output_filename"
name="output_filename"
type="text"
placeholder="voice_clone_output"
value="voice_clone_output"
required>
<div class="small">
Required. Output filename (without extension). Saved as MP3 in the output directory. If the file already exists, a number is appended (-1, -2, …).
</div>
</div>
<div class="row">
<label for="voice_clone_language">Language</label>
<select id="voice_clone_language" name="language">
<option value="en" selected>English</option>
<option value="es">Spanish</option>
<option value="fr">French</option>
<option value="de">German</option>
<option value="it">Italian</option>
<option value="pt">Portuguese</option>
<option value="pl">Polish</option>
<option value="tr">Turkish</option>
<option value="ru">Russian</option>
<option value="nl">Dutch</option>
<option value="cs">Czech</option>
<option value="ar">Arabic</option>
<option value="zh-cn">Chinese (Simplified)</option>
<option value="ja">Japanese</option>
<option value="hu">Hungarian</option>
<option value="ko">Korean</option>
</select>
</div>
<div class="row">
<label for="voice_clone_device">Device</label>
<select id="voice_clone_device" name="device_preference">
<option value="auto" selected>Auto (MPS if available, else CPU)</option>
<option value="mps">Apple Silicon GPU (MPS)</option>
<option value="cpu">CPU</option>
</select>
<div class="small">
Device selection for voice cloning. On M2/M3 Macs, CPU can be surprisingly fast and may avoid MPS artifacts.
First generation is slower (compiles execution graph), subsequent generations are faster.
</div>
</div>
<hr style="border:none;border-top:1px solid #111827;margin:16px 0 8px;">
<div class="small" style="font-weight:600;opacity:0.9;margin-bottom:8px;">
Advanced Parameters
</div>
<div class="slider-row">
<label for="voice_clone_temperature">Temperature</label>
<input id="voice_clone_temperature_range" type="range" min="0.0" max="1.0" step="0.01"
value="0.75" oninput="CDMF.syncRange('voice_clone_temperature', 'voice_clone_temperature_range')">
<input id="voice_clone_temperature" name="temperature" type="number" min="0.0" max="1.0" step="0.01"
value="0.75" oninput="CDMF.syncNumber('voice_clone_temperature', 'voice_clone_temperature_range')">
<div class="small">Sampling temperature. Lower values produce more deterministic output.</div>
</div>
<div class="slider-row">
<label for="voice_clone_length_penalty">Length Penalty</label>
<input id="voice_clone_length_penalty_range" type="range" min="0.0" max="2.0" step="0.1"
value="1.0" oninput="CDMF.syncRange('voice_clone_length_penalty', 'voice_clone_length_penalty_range')">
<input id="voice_clone_length_penalty" name="length_penalty" type="number" min="0.0" max="2.0" step="0.1"
value="1.0" oninput="CDMF.syncNumber('voice_clone_length_penalty', 'voice_clone_length_penalty_range')">
<div class="small">Length penalty for generation.</div>
</div>
<div class="slider-row">
<label for="voice_clone_repetition_penalty">Repetition Penalty</label>
<input id="voice_clone_repetition_penalty_range" type="range" min="0.0" max="10.0" step="0.1"
value="5.0" oninput="CDMF.syncRange('voice_clone_repetition_penalty', 'voice_clone_repetition_penalty_range')">
<input id="voice_clone_repetition_penalty" name="repetition_penalty" type="number" min="0.0" max="10.0" step="0.1"
value="5.0" oninput="CDMF.syncNumber('voice_clone_repetition_penalty', 'voice_clone_repetition_penalty_range')">
<div class="small">Penalty for repeating tokens. Higher values reduce repetition.</div>
</div>
<div class="slider-row">
<label for="voice_clone_top_k">Top-K</label>
<input id="voice_clone_top_k" name="top_k" type="number" min="1" max="100" step="1"
value="50">
<div class="small">Top-K sampling parameter.</div>
</div>
<div class="slider-row">
<label for="voice_clone_top_p">Top-P</label>
<input id="voice_clone_top_p_range" type="range" min="0.0" max="1.0" step="0.01"
value="0.85" oninput="CDMF.syncRange('voice_clone_top_p', 'voice_clone_top_p_range')">
<input id="voice_clone_top_p" name="top_p" type="number" min="0.0" max="1.0" step="0.01"
value="0.85" oninput="CDMF.syncNumber('voice_clone_top_p', 'voice_clone_top_p_range')">
<div class="small">Nucleus sampling parameter.</div>
</div>
<div class="slider-row">
<label for="voice_clone_speed">Speed</label>
<input id="voice_clone_speed_range" type="range" min="0.25" max="4.0" step="0.05"
value="1.0" oninput="CDMF.syncRange('voice_clone_speed', 'voice_clone_speed_range')">
<input id="voice_clone_speed" name="speed" type="number" min="0.25" max="4.0" step="0.05"
value="1.0" oninput="CDMF.syncNumber('voice_clone_speed', 'voice_clone_speed_range')">
<div class="small">Speech speed multiplier (0.25x to 4.0x).</div>
</div>
<div class="row">
<label style="display:flex;align-items:center;gap:8px;cursor:pointer;">
<input
id="voice_clone_enable_text_splitting"
name="enable_text_splitting"
type="checkbox"
checked>
Enable Text Splitting
</label>
<div class="small">Automatically split long text into sentences for better quality.</div>
</div>
<!-- Hidden field for output directory (synced from Settings) -->
<input id="voice_clone_out_dir" name="out_dir" type="hidden" value="{{ default_out_dir or '' }}">
</form>
<!-- Stem Splitting form card (mode: stem_split) ----------------------------- -->
<form
id="stemSplitForm"
class="card card-mode"
data-mode="stem_split"
method="post"
action="{{ url_for('cdmf_stem_splitting.stem_split') }}"
enctype="multipart/form-data"
onsubmit="return CDMF.onSubmitStemSplit(event)"
style="display:none;">
<div class="card-header-row">
<div style="flex:1;min-width:0;">
<h2>Stem Splitting</h2>
<div id="stemSplitLoadingBar" class="loading-bar" style="display:none;">
<div class="loading-bar-inner"></div>
</div>
</div>
<div style="display:flex;gap:8px;align-items:center;">
<button id="stemSplitButton" type="submit" class="btn primary">
<span class="icon">🎚️</span><span>Split Stems</span>
</button>
<button id="stemSplitDownloadModelsBtn" type="button" class="btn secondary" style="display:none;">
<span class="icon">⬇</span><span>Download Demucs models</span>
</button>
</div>
</div>
<div class="small" style="margin-top:8px;margin-bottom:16px;">
Split audio into separate stems (vocals, drums, bass, etc.) using AI models. Upload an audio file and choose the number of stems to extract.
</div>
<div id="stemSplitModelStatusNotice" class="toast" style="margin-top:8px;margin-bottom:16px;display:none;">
Demucs model is not downloaded yet. Click "Download Demucs models" below to download it (first use only). This is a one-time download; progress is shown in the loading bar.
</div>
<div class="row">
<label for="stem_split_input_file">Input Audio File</label>
<input
id="stem_split_input_file"
name="input_file"
type="file"
accept="audio/*,.mp3,.wav,.m4a,.flac,.ogg"
required>
<div class="small">
Upload an audio file (MP3, WAV, M4A, FLAC, or OGG) to split into stems.
</div>
</div>
<div class="row">
<label for="stem_split_base_filename">Base filename (optional)</label>
<input
id="stem_split_base_filename"
name="base_filename"
type="text"
placeholder=""
value="">
<div class="small">
Optional. If set, this prefix is added to generated stem filenames (e.g. <em>myprefix</em>_song_stems_vocals.wav).
</div>
</div>
<div class="row">
<label for="stem_split_stem_count">Number of Stems</label>
<select id="stem_split_stem_count" name="stem_count">
<option value="2">2-Stem (Vocals / Instrumental)</option>
<option value="4" selected>4-Stem (Vocals, Drums, Bass, Other)</option>
<option value="6">6-Stem (Vocals, Drums, Bass, Guitar, Piano, Other)</option>
</select>
<div class="small">
Choose how many stems to extract. 2-stem splits vocals and instrumental. 4-stem and 6-stem provide more granular separation.
</div>
</div>
<div class="row">
<label for="stem_split_mode">Mode (2-Stem Only)</label>
<select id="stem_split_mode" name="mode">
<option value="" selected>Standard (All Stems)</option>
<option value="vocals_only">Acapella (Vocals Only)</option>
<option value="instrumental">Instrumental / Karaoke</option>
</select>
<div class="small">