Spaces:
Running
Running
modify app
Browse files
app.py
CHANGED
@@ -81,14 +81,11 @@ def perform_ito(input_audio, reference_audio, ito_reference_audio, num_steps, op
|
|
81 |
# Denormalize the audio to int16
|
82 |
current_output = denormalize_audio(current_output, dtype=np.int16)
|
83 |
|
84 |
-
if output_audio.ndim == 1:
|
85 |
-
output_audio = output_audio.reshape(-1, 1)
|
86 |
-
elif output_audio.ndim > 2:
|
87 |
-
output_audio = output_audio.squeeze()
|
88 |
-
|
89 |
# Ensure the audio is in the correct shape (samples, channels)
|
90 |
-
if
|
91 |
-
|
|
|
|
|
92 |
|
93 |
yield (args.sample_rate, current_output), ito_param_output, step, ito_log
|
94 |
|
@@ -135,9 +132,24 @@ with gr.Blocks() as demo:
|
|
135 |
|
136 |
def run_ito(input_audio, reference_audio, ito_reference_audio, num_steps, optimizer, learning_rate, af_weights):
|
137 |
af_weights = [float(w.strip()) for w in af_weights.split(',')]
|
138 |
-
|
139 |
input_audio, reference_audio, ito_reference_audio, num_steps, optimizer, learning_rate, af_weights
|
140 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
|
142 |
ito_button.click(
|
143 |
run_ito,
|
|
|
81 |
# Denormalize the audio to int16
|
82 |
current_output = denormalize_audio(current_output, dtype=np.int16)
|
83 |
|
|
|
|
|
|
|
|
|
|
|
84 |
# Ensure the audio is in the correct shape (samples, channels)
|
85 |
+
if current_output.ndim == 1:
|
86 |
+
current_output = current_output.reshape(-1, 1)
|
87 |
+
elif current_output.ndim > 2:
|
88 |
+
current_output = current_output.squeeze()
|
89 |
|
90 |
yield (args.sample_rate, current_output), ito_param_output, step, ito_log
|
91 |
|
|
|
132 |
|
133 |
def run_ito(input_audio, reference_audio, ito_reference_audio, num_steps, optimizer, learning_rate, af_weights):
|
134 |
af_weights = [float(w.strip()) for w in af_weights.split(',')]
|
135 |
+
ito_generator = perform_ito(
|
136 |
input_audio, reference_audio, ito_reference_audio, num_steps, optimizer, learning_rate, af_weights
|
137 |
)
|
138 |
+
|
139 |
+
# Initialize variables to store the final results
|
140 |
+
final_audio = None
|
141 |
+
final_params = None
|
142 |
+
final_steps = 0
|
143 |
+
final_log = ""
|
144 |
+
|
145 |
+
# Iterate through the generator to get the final results
|
146 |
+
for audio, params, steps, log in ito_generator:
|
147 |
+
final_audio = audio
|
148 |
+
final_params = params
|
149 |
+
final_steps = steps
|
150 |
+
final_log = log
|
151 |
+
|
152 |
+
return final_audio, final_params, final_steps, final_log
|
153 |
|
154 |
ito_button.click(
|
155 |
run_ito,
|