Spaces:
Running
Running
rollback
Browse files
app.py
CHANGED
@@ -156,16 +156,6 @@ def update_ito_output(all_results, selected_step):
|
|
156 |
return (args.sample_rate, current_output), ito_param_output, selected_result['log']
|
157 |
|
158 |
|
159 |
-
# Define the path to the examples folder
|
160 |
-
EXAMPLES_DIR = "examples/"
|
161 |
-
example_files = [f for f in os.listdir(EXAMPLES_DIR) if f.endswith('.mp3')]
|
162 |
-
|
163 |
-
# Create lists for input and reference examples
|
164 |
-
input_examples = [f"input_{i}.mp3" for i in range(1, len(example_files)//2 + 1)]
|
165 |
-
reference_examples = [f"reference_{i}.mp3" for i in range(1, len(example_files)//2 + 1)]
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
""" APP display """
|
170 |
with gr.Blocks() as demo:
|
171 |
gr.Markdown("# ITO-Master: Inference Time Optimization for Mastering Style Transfer")
|
@@ -173,26 +163,17 @@ with gr.Blocks() as demo:
|
|
173 |
gr.Markdown("Interactive demo of Inference Time Optimization (ITO) for Music Mastering Style Transfer. \
|
174 |
The mastering style transfer is performed by a differentiable audio processing model, and the predicted parameters are shown as the output. \
|
175 |
Perform mastering style transfer with an input source audio and a reference mastering style audio. On top of this result, you can perform ITO to optimize the reference embedding $z_{ref}$ to further gain control over the output mastering style.")
|
176 |
-
gr.Image("ito_snow.png", width=
|
177 |
|
178 |
gr.Markdown("## Step 1: Mastering Style Transfer")
|
179 |
|
180 |
with gr.Tab("Upload Audio"):
|
181 |
with gr.Row():
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
input_audio = gr.Audio(label="Source Audio $x_{in}$", interactive=not use_example_files.value)
|
186 |
-
reference_audio = gr.Audio(label="Reference Style Audio $x_{ref}$", interactive=not use_example_files.value)
|
187 |
-
|
188 |
-
# Dropdowns for selecting example files
|
189 |
-
with gr.Row():
|
190 |
-
input_example_dropdown = gr.Dropdown(label="Select Input Example", choices=input_examples, interactive=use_example_files.value)
|
191 |
-
reference_example_dropdown = gr.Dropdown(label="Select Reference Example", choices=reference_examples, interactive=use_example_files.value)
|
192 |
-
|
193 |
process_button = gr.Button("Process Mastering Style Transfer")
|
194 |
gr.Markdown('<span style="color: lightgray; font-style: italic;">all output samples are normalized to -12dB</span>')
|
195 |
-
gr.Markdown("all output samples are normalized to -12dB")
|
196 |
|
197 |
with gr.Row():
|
198 |
with gr.Column():
|
@@ -200,27 +181,12 @@ with gr.Blocks() as demo:
|
|
200 |
normalized_input = gr.Audio(label="Normalized Source Audio", type='numpy')
|
201 |
param_output = gr.Textbox(label="Predicted Parameters", lines=5)
|
202 |
|
203 |
-
def process_audio_with_examples(input_audio, reference_audio, input_example, reference_example, use_examples):
|
204 |
-
if use_examples:
|
205 |
-
if input_example:
|
206 |
-
input_audio = sf.read(os.path.join(EXAMPLES_DIR, input_example))[0]
|
207 |
-
if reference_example:
|
208 |
-
reference_audio = sf.read(os.path.join(EXAMPLES_DIR, reference_example))[0]
|
209 |
-
return process_audio(input_audio, reference_audio)
|
210 |
-
|
211 |
process_button.click(
|
212 |
-
|
213 |
-
inputs=[input_audio, reference_audio
|
214 |
outputs=[output_audio, param_output, normalized_input]
|
215 |
)
|
216 |
|
217 |
-
# Update the interactivity of the audio inputs and dropdowns based on the checkbox
|
218 |
-
use_example_files.change(
|
219 |
-
lambda use_examples: (not use_examples, not use_examples),
|
220 |
-
inputs=[use_example_files],
|
221 |
-
outputs=[input_audio, reference_audio]
|
222 |
-
)
|
223 |
-
|
224 |
with gr.Tab("YouTube Audio"):
|
225 |
with gr.Row():
|
226 |
input_youtube_url = gr.Textbox(label="Input YouTube URL")
|
|
|
156 |
return (args.sample_rate, current_output), ito_param_output, selected_result['log']
|
157 |
|
158 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
""" APP display """
|
160 |
with gr.Blocks() as demo:
|
161 |
gr.Markdown("# ITO-Master: Inference Time Optimization for Mastering Style Transfer")
|
|
|
163 |
gr.Markdown("Interactive demo of Inference Time Optimization (ITO) for Music Mastering Style Transfer. \
|
164 |
The mastering style transfer is performed by a differentiable audio processing model, and the predicted parameters are shown as the output. \
|
165 |
Perform mastering style transfer with an input source audio and a reference mastering style audio. On top of this result, you can perform ITO to optimize the reference embedding $z_{ref}$ to further gain control over the output mastering style.")
|
166 |
+
gr.Image("ito_snow.png", width=500, height=300, label="ITO pipeline")
|
167 |
|
168 |
gr.Markdown("## Step 1: Mastering Style Transfer")
|
169 |
|
170 |
with gr.Tab("Upload Audio"):
|
171 |
with gr.Row():
|
172 |
+
input_audio = gr.Audio(label="Source Audio $x_{in}$")
|
173 |
+
reference_audio = gr.Audio(label="Reference Style Audio $x_{ref}$")
|
174 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
process_button = gr.Button("Process Mastering Style Transfer")
|
176 |
gr.Markdown('<span style="color: lightgray; font-style: italic;">all output samples are normalized to -12dB</span>')
|
|
|
177 |
|
178 |
with gr.Row():
|
179 |
with gr.Column():
|
|
|
181 |
normalized_input = gr.Audio(label="Normalized Source Audio", type='numpy')
|
182 |
param_output = gr.Textbox(label="Predicted Parameters", lines=5)
|
183 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
process_button.click(
|
185 |
+
process_audio,
|
186 |
+
inputs=[input_audio, reference_audio],
|
187 |
outputs=[output_audio, param_output, normalized_input]
|
188 |
)
|
189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
with gr.Tab("YouTube Audio"):
|
191 |
with gr.Row():
|
192 |
input_youtube_url = gr.Textbox(label="Input YouTube URL")
|