alibabasglab commited on
Commit
af519a1
·
verified ·
1 Parent(s): b285469

fix MossFormerGAN trimming audio

Browse files
Files changed (1) hide show
  1. utils/decode.py +7 -1
utils/decode.py CHANGED
@@ -244,7 +244,13 @@ def decode_one_audio_mossformergan_se_16k(model, device, inputs, args):
244
  outputs[current_idx + give_up_length:current_idx + window - give_up_length] = tmp_output[give_up_length:-give_up_length]
245
 
246
  current_idx += stride # Move to the next segment
247
-
 
 
 
 
 
 
248
  return outputs # Return the accumulated outputs from segments
249
  else:
250
  # If no segmentation is required, process the entire input
 
244
  outputs[current_idx + give_up_length:current_idx + window - give_up_length] = tmp_output[give_up_length:-give_up_length]
245
 
246
  current_idx += stride # Move to the next segment
247
+ # Handle the remaining part of the input if it doesn't fit into a full segment
248
+ # current_idx > t - window
249
+ if current_idx < t:
250
+ last_start = current_idx - give_up_length # shift left by give_up_length
251
+ tmp_input = inputs[:, last_start:]
252
+ tmp_output = _decode_one_audio_mossformergan_se_16k(model, device, tmp_input, norm_factor, args)
253
+ outputs[current_idx:] = tmp_output[give_up_length:] # Fill the remaining part of the output
254
  return outputs # Return the accumulated outputs from segments
255
  else:
256
  # If no segmentation is required, process the entire input