Spaces:
Runtime error
Runtime error
add examples
Browse files- app.py +27 -2
- examples/input_1.mp3 +0 -0
- examples/reference_1.mp3 +0 -0
app.py
CHANGED
|
@@ -156,6 +156,16 @@ def update_ito_output(all_results, selected_step):
|
|
| 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")
|
|
@@ -172,7 +182,13 @@ with gr.Blocks() as demo:
|
|
| 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 |
|
| 177 |
with gr.Row():
|
| 178 |
with gr.Column():
|
|
@@ -180,9 +196,16 @@ with gr.Blocks() as demo:
|
|
| 180 |
normalized_input = gr.Audio(label="Normalized Source Audio", type='numpy')
|
| 181 |
param_output = gr.Textbox(label="Predicted Parameters", lines=5)
|
| 182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
process_button.click(
|
| 184 |
-
|
| 185 |
-
inputs=[input_audio, reference_audio],
|
| 186 |
outputs=[output_audio, param_output, normalized_input]
|
| 187 |
)
|
| 188 |
|
|
@@ -195,6 +218,7 @@ with gr.Blocks() as demo:
|
|
| 195 |
reference_audio_yt = gr.Audio(label="Reference Style Audio (Do not put when using YouTube URL)")
|
| 196 |
|
| 197 |
process_button_yt = gr.Button("Process Mastering Style Transfer")
|
|
|
|
| 198 |
|
| 199 |
with gr.Row():
|
| 200 |
output_audio_yt = gr.Audio(label="Output Audio", type='numpy')
|
|
@@ -260,6 +284,7 @@ with gr.Blocks() as demo:
|
|
| 260 |
)
|
| 261 |
|
| 262 |
ito_button = gr.Button("Perform ITO")
|
|
|
|
| 263 |
|
| 264 |
with gr.Row():
|
| 265 |
with gr.Column():
|
|
|
|
| 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")
|
|
|
|
| 182 |
input_audio = gr.Audio(label="Source Audio $x_{in}$")
|
| 183 |
reference_audio = gr.Audio(label="Reference Style Audio $x_{ref}$")
|
| 184 |
|
| 185 |
+
# Dropdowns for selecting example files
|
| 186 |
+
with gr.Row():
|
| 187 |
+
input_example_dropdown = gr.Dropdown(label="Select Input Example", choices=input_examples)
|
| 188 |
+
reference_example_dropdown = gr.Dropdown(label="Select Reference Example", choices=reference_examples)
|
| 189 |
+
|
| 190 |
process_button = gr.Button("Process Mastering Style Transfer")
|
| 191 |
+
gr.Markdown('<span style="color: lightgray; font-style: italic;">all output samples are normalized to -12dB</span>')
|
| 192 |
|
| 193 |
with gr.Row():
|
| 194 |
with gr.Column():
|
|
|
|
| 196 |
normalized_input = gr.Audio(label="Normalized Source Audio", type='numpy')
|
| 197 |
param_output = gr.Textbox(label="Predicted Parameters", lines=5)
|
| 198 |
|
| 199 |
+
def process_audio_with_examples(input_audio, reference_audio, input_example, reference_example):
|
| 200 |
+
if input_example:
|
| 201 |
+
input_audio = sf.read(os.path.join(EXAMPLES_DIR, input_example))[0]
|
| 202 |
+
if reference_example:
|
| 203 |
+
reference_audio = sf.read(os.path.join(EXAMPLES_DIR, reference_example))[0]
|
| 204 |
+
return process_audio(input_audio, reference_audio)
|
| 205 |
+
|
| 206 |
process_button.click(
|
| 207 |
+
process_audio_with_examples,
|
| 208 |
+
inputs=[input_audio, reference_audio, input_example_dropdown, reference_example_dropdown],
|
| 209 |
outputs=[output_audio, param_output, normalized_input]
|
| 210 |
)
|
| 211 |
|
|
|
|
| 218 |
reference_audio_yt = gr.Audio(label="Reference Style Audio (Do not put when using YouTube URL)")
|
| 219 |
|
| 220 |
process_button_yt = gr.Button("Process Mastering Style Transfer")
|
| 221 |
+
gr.Markdown('<span style="color: lightgray; font-style: italic;">all output samples are normalized to -12dB</span>')
|
| 222 |
|
| 223 |
with gr.Row():
|
| 224 |
output_audio_yt = gr.Audio(label="Output Audio", type='numpy')
|
|
|
|
| 284 |
)
|
| 285 |
|
| 286 |
ito_button = gr.Button("Perform ITO")
|
| 287 |
+
gr.Markdown('<span style="color: lightgray; font-style: italic;">all output samples are normalized to -12dB</span>')
|
| 288 |
|
| 289 |
with gr.Row():
|
| 290 |
with gr.Column():
|
examples/input_1.mp3
ADDED
|
Binary file (652 kB). View file
|
|
|
examples/reference_1.mp3
ADDED
|
Binary file (566 kB). View file
|
|
|