erl-j commited on
Commit
1c45a6c
·
1 Parent(s): bf8488d

css fix lightmode/darkmode

Browse files
Files changed (5) hide show
  1. app.py +33 -24
  2. custom.css +18 -51
  3. custom.js +1 -1
  4. hero.html +0 -18
  5. intro.md +15 -0
app.py CHANGED
@@ -18,16 +18,15 @@ decoder_path = "erl-j/soundfont-generator-assets/decoder.pt"
18
  model_path = "erl-j/soundfont-generator-assets/synth_lfm_modern_bfloat16.pt"
19
  # Download models from Hugging Face Hub
20
  decoder_path = hf_hub_download("erl-j/soundfont-generator-assets", "decoder.pt")
21
- model_path = hf_hub_download("erl-j/soundfont-generator-assets", "synth_lfm_modern_bfloat16.pt")
 
 
22
 
23
  # Load models once at startup
24
  device = "cuda"
25
  decoder = torch.load(decoder_path, map_location=device).half().eval()
26
- model = (
27
- torch.load(model_path, map_location=device)
28
- .half()
29
- .eval()
30
- )
31
 
32
  @spaces.GPU
33
  def generate_and_export_soundfont(text, steps=20, instrument_name=None):
@@ -104,24 +103,25 @@ def generate_and_export_soundfont(text, steps=20, instrument_name=None):
104
  f"Generation took {total_time:.2f}s\nFiles saved in {output_dir}",
105
  zip_path,
106
  wav_files,
107
- )
 
108
 
109
  custom_js = open("custom.js").read()
110
  custom_css = open("custom.css").read()
111
 
112
- demo = gr.Blocks(title="Erl-j's Soundfont Generator",
113
- theme = gr.themes.Default(
114
- primary_hue="green",
115
- font=[gr.themes.GoogleFont("Inconsolata"), "Arial", "sans-serif"]
116
- ),
117
- js=custom_js,
118
- css = custom_css)
119
-
120
- with demo:
121
- hero_html = open("hero.html").read()
122
-
123
- gr.HTML(hero_html)
124
-
125
  with gr.Row():
126
  steps = gr.Slider(
127
  minimum=1, maximum=50, value=20, step=1, label="Generation steps"
@@ -134,7 +134,6 @@ with demo:
134
  lines=2,
135
  )
136
 
137
-
138
  with gr.Row():
139
  generate_btn = gr.Button("Generate Soundfont", variant="primary")
140
 
@@ -143,11 +142,16 @@ with demo:
143
  status_output = gr.Textbox(label="Status", lines=2, visible=False)
144
 
145
  with gr.Row():
146
- wav_files = gr.File(label="Individual WAV Files", file_count="multiple", visible=False, elem_id="individual-wav-files")
 
 
 
 
 
147
 
148
  html = """
149
  <div id="custom-player"
150
- style="width: 100%; height: 600px; background-color: "white"; border: 1px solid #f8f9fa; border-radius: 5px; margin-top: 10px;"
151
  ></div>
152
  """
153
 
@@ -155,7 +159,12 @@ with demo:
155
 
156
  gr.Markdown("## Download Soundfont Package here:")
157
  with gr.Row():
158
- sf = gr.File(label="Download SFZ Soundfont Package", type="filepath", visible=True, elem_id="sfz")
 
 
 
 
 
159
 
160
  gr.Markdown("""
161
  # About
 
18
  model_path = "erl-j/soundfont-generator-assets/synth_lfm_modern_bfloat16.pt"
19
  # Download models from Hugging Face Hub
20
  decoder_path = hf_hub_download("erl-j/soundfont-generator-assets", "decoder.pt")
21
+ model_path = hf_hub_download(
22
+ "erl-j/soundfont-generator-assets", "synth_lfm_modern_bfloat16.pt"
23
+ )
24
 
25
  # Load models once at startup
26
  device = "cuda"
27
  decoder = torch.load(decoder_path, map_location=device).half().eval()
28
+ model = torch.load(model_path, map_location=device).half().eval()
29
+
 
 
 
30
 
31
  @spaces.GPU
32
  def generate_and_export_soundfont(text, steps=20, instrument_name=None):
 
103
  f"Generation took {total_time:.2f}s\nFiles saved in {output_dir}",
104
  zip_path,
105
  wav_files,
106
+ )
107
+
108
 
109
  custom_js = open("custom.js").read()
110
  custom_css = open("custom.css").read()
111
 
112
+ demo = gr.Blocks(
113
+ title="Erl-j's Soundfont Generator",
114
+ theme=gr.themes.Default(
115
+ primary_hue="green",
116
+ font=[gr.themes.GoogleFont("Inconsolata"), "Arial", "sans-serif"],
117
+ ),
118
+ js=custom_js,
119
+ css=custom_css,
120
+ )
121
+
122
+ with demo:
123
+ gr.Markdown(open("intro.md").read())
124
+
125
  with gr.Row():
126
  steps = gr.Slider(
127
  minimum=1, maximum=50, value=20, step=1, label="Generation steps"
 
134
  lines=2,
135
  )
136
 
 
137
  with gr.Row():
138
  generate_btn = gr.Button("Generate Soundfont", variant="primary")
139
 
 
142
  status_output = gr.Textbox(label="Status", lines=2, visible=False)
143
 
144
  with gr.Row():
145
+ wav_files = gr.File(
146
+ label="Individual WAV Files",
147
+ file_count="multiple",
148
+ visible=False,
149
+ elem_id="individual-wav-files",
150
+ )
151
 
152
  html = """
153
  <div id="custom-player"
154
+ style="width: 100%; height: 600px; border: 1px solid #f8f9fa; border-radius: 5px; margin-top: 10px;"
155
  ></div>
156
  """
157
 
 
159
 
160
  gr.Markdown("## Download Soundfont Package here:")
161
  with gr.Row():
162
+ sf = gr.File(
163
+ label="Download SFZ Soundfont Package",
164
+ type="filepath",
165
+ visible=True,
166
+ elem_id="sfz",
167
+ )
168
 
169
  gr.Markdown("""
170
  # About
custom.css CHANGED
@@ -1,43 +1,14 @@
1
  /* CSS Variables */
2
  :root {
3
- /* Light mode */
4
- --background-color: #f5f5f5;
5
- --container-background: #fafafa;
6
- --key-background: white;
7
- --key-hover-background: #f5f5f5;
8
  --border-color: #e5e5e5;
9
- --text-primary: #333;
10
- --text-secondary: #666;
11
  --slider-track: #393a39;
12
  --slider-thumb: #000000;
13
- --button-background: #015131;
14
- --button-hover: #002114;
15
- --button-text: white;
16
- --keyboard-bg: #fafafa;
17
- --inactive-key-bg: #e0e0e0;
18
- }
19
-
20
- @media (prefers-color-scheme: dark) {
21
- :root {
22
- --background-color: #121212;
23
- --container-background: #1e1e1e;
24
- --key-background: #2d2d2d;
25
- --key-hover-background: #3d3d3d;
26
- --border-color: #404040;
27
- --text-primary: #e0e0e0;
28
- --text-secondary: #a0a0a0;
29
- --slider-track: #666666;
30
- --slider-thumb: #015131;
31
- --button-background: #015131;
32
- --button-hover: #026b41;
33
- --keyboard-bg: #1e1e1e;
34
- --inactive-key-bg: #2d2d2d;
35
- }
36
  }
37
 
38
  /* Base styles */
39
  html, body, #root, .wrapper, main, .main-container {
40
- background-color: var(--background-color);
41
  min-height: 100vh;
42
  margin: 0;
43
  padding: 0;
@@ -49,12 +20,10 @@ body {
49
  font-family: 'Roboto', sans-serif;
50
  font-size: 1rem;
51
  line-height: 1.5;
52
- color: var(--text-primary);
53
  overflow-x: hidden;
54
  transition: background-color 0.2s ease;
55
  }
56
 
57
-
58
  /* Keyboard layout */
59
  .keyboard-container {
60
  width: 100%;
@@ -63,6 +32,7 @@ body {
63
  border: 1px solid var(--border-color);
64
  border-radius: 4px;
65
  user-select: none;
 
66
  }
67
 
68
  .keyboard-row {
@@ -79,9 +49,8 @@ body {
79
  min-width: 40px;
80
  flex: none;
81
  padding: 0.5rem;
82
- border: 1px solid var(--border-color);
83
  border-radius: 4px;
84
- background: var(--key-background);
85
  cursor: pointer;
86
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
87
  display: flex;
@@ -91,7 +60,6 @@ body {
91
  }
92
 
93
  .key:hover {
94
- background: var(--key-hover-background);
95
  transform: translateY(-1px);
96
  }
97
 
@@ -107,13 +75,13 @@ body {
107
  .key-label {
108
  font-size: 0.875rem;
109
  font-weight: 500;
110
- color: var(--text-primary);
111
  }
112
 
113
  .note-label {
114
  font-size: 0.75rem;
115
- color: var(--text-secondary);
116
  margin-top: 0.25rem;
 
117
  }
118
 
119
  /* Controls section */
@@ -143,7 +111,7 @@ h3 {
143
  display: block;
144
  margin-bottom: 0.5em;
145
  font-size: 0.9em;
146
- color: var(--text-primary);
147
  }
148
 
149
  h3 {
@@ -152,17 +120,6 @@ h3 {
152
  font-weight: 500;
153
  }
154
 
155
- .slider-value,
156
- .master-value,
157
- .release-value,
158
- .reverb-mix-value,
159
- .root-value,
160
- .column-value,
161
- .row-value {
162
- color: var(--text-secondary);
163
- font-weight: 500;
164
- }
165
-
166
  /* Range inputs */
167
  input[type="range"] {
168
  width: 100%;
@@ -229,4 +186,14 @@ input[type="range"]::-moz-range-track {
229
  width: 28px;
230
  height: 28px;
231
  }
232
- }
 
 
 
 
 
 
 
 
 
 
 
1
  /* CSS Variables */
2
  :root {
3
+ --keyboard-bg: #fafafa;
4
+ --inactive-key-bg: #e0e0e0;
 
 
 
5
  --border-color: #e5e5e5;
 
 
6
  --slider-track: #393a39;
7
  --slider-thumb: #000000;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  }
9
 
10
  /* Base styles */
11
  html, body, #root, .wrapper, main, .main-container {
 
12
  min-height: 100vh;
13
  margin: 0;
14
  padding: 0;
 
20
  font-family: 'Roboto', sans-serif;
21
  font-size: 1rem;
22
  line-height: 1.5;
 
23
  overflow-x: hidden;
24
  transition: background-color 0.2s ease;
25
  }
26
 
 
27
  /* Keyboard layout */
28
  .keyboard-container {
29
  width: 100%;
 
32
  border: 1px solid var(--border-color);
33
  border-radius: 4px;
34
  user-select: none;
35
+ color: #333;
36
  }
37
 
38
  .keyboard-row {
 
49
  min-width: 40px;
50
  flex: none;
51
  padding: 0.5rem;
52
+ border: 2px solid var(--border-color);
53
  border-radius: 4px;
 
54
  cursor: pointer;
55
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
56
  display: flex;
 
60
  }
61
 
62
  .key:hover {
 
63
  transform: translateY(-1px);
64
  }
65
 
 
75
  .key-label {
76
  font-size: 0.875rem;
77
  font-weight: 500;
78
+ color: #333;
79
  }
80
 
81
  .note-label {
82
  font-size: 0.75rem;
 
83
  margin-top: 0.25rem;
84
+ color: #666;
85
  }
86
 
87
  /* Controls section */
 
111
  display: block;
112
  margin-bottom: 0.5em;
113
  font-size: 0.9em;
114
+ color: #333;
115
  }
116
 
117
  h3 {
 
120
  font-weight: 500;
121
  }
122
 
 
 
 
 
 
 
 
 
 
 
 
123
  /* Range inputs */
124
  input[type="range"] {
125
  width: 100%;
 
186
  width: 28px;
187
  height: 28px;
188
  }
189
+ }
190
+
191
+
192
+ .release-value,
193
+ .reverb-mix-value,
194
+ .master-value,
195
+ .root-value,
196
+ .column-value,
197
+ .row-value {
198
+ color: black;
199
+ }
custom.js CHANGED
@@ -371,4 +371,4 @@ function previewPlayer() {
371
  document.body.appendChild(container);
372
  }
373
  new KeyboardPlayer('custom-player');
374
- }
 
371
  document.body.appendChild(container);
372
  }
373
  new KeyboardPlayer('custom-player');
374
+ }
hero.html DELETED
@@ -1,18 +0,0 @@
1
- <div>
2
- <h1>Erl-j's Soundfont Generator</h1>
3
- Generate soundfonts from text descriptions using latent flow matching. You can then download the complete SFZ
4
- soundfont
5
- package to use the instrument locally.
6
- <h2>Instructions</h2>
7
- 1. Enter a text prompt to describe the audio you want to generate. For example, *"hard bass"* or *"dark analog lead
8
- flute flute flute soft"*.
9
- <br>
10
- 2. Adjust the number of generation steps to tradeoff between quality and speed (kindof).
11
- <br>
12
- 3. Click the "Generate Soundfont" button to generate the audio and soundfont.
13
- <br>
14
- 4. Preview the generated instrument with the keyboard.
15
- <br>
16
- 5. Export the soundfont by clicking the "Download SFZ Soundfont Package" button. You can then use the soundfont in a
17
- SFZ-compatible sampler. See [this list](https://sfzformat.com/software/players/) for a list of SFZ players.
18
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
intro.md ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Erl-j's Soundfont Generator
2
+
3
+ Generate soundfonts from text descriptions using latent flow matching. You can then download the complete SFZ soundfont package to use the instrument locally.
4
+
5
+ ## Instructions
6
+
7
+ 1. Enter a text prompt to describe the audio you want to generate. For example, *"hard bass"* or *"dark analog lead flute flute flute soft"*.
8
+
9
+ 2. Adjust the number of generation steps to tradeoff between quality and speed (kindof).
10
+
11
+ 3. Click the "Generate Soundfont" button to generate the audio and soundfont.
12
+
13
+ 4. Preview the generated instrument with the keyboard.
14
+
15
+ 5. Export the soundfont by clicking the "Download SFZ Soundfont Package" button. You can then use the soundfont in a SFZ-compatible sampler. See [this list](https://sfzformat.com/software/players/) for a list of SFZ players.