jhtonyKoo commited on
Commit
3635837
1 Parent(s): e6453cd

modify app

Browse files
Files changed (1) hide show
  1. app.py +20 -8
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 output_audio.shape[1] > output_audio.shape[0]:
91
- output_audio = output_audio.transpose(1,0)
 
 
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
- return perform_ito(
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,