(chunk_wav)
| 141 | input_len = full_wav.shape[0] |
| 142 | |
| 143 | def _process_chunk(chunk_wav): |
| 144 | chunk_wav = preprocessor.preprocess_chunk(chunk_wav) |
| 145 | if len(chunk_wav) < FLOWSEP_CHUNK_IN: |
| 146 | pad = np.zeros(FLOWSEP_CHUNK_IN - len(chunk_wav), dtype=np.float32) |
| 147 | chunk_wav = np.concatenate([chunk_wav, pad]) |
| 148 | chunk_wav = chunk_wav[:FLOWSEP_CHUNK_IN] |
| 149 | mixed_mel, _ = preprocessor.wav_feature_extraction(chunk_wav.reshape(1, -1)) |
| 150 | batch = { |
| 151 | "fname": [str(audio_file)], |
| 152 | "text": [args.text], |
| 153 | "caption": [args.text], |
| 154 | "waveform": torch.rand(1, 1, FLOWSEP_CHUNK_IN).to(device), |
| 155 | "log_mel_spec": torch.rand(1, 1024, 64).to(device), |
| 156 | "sampling_rate": torch.tensor([FLOWSEP_SR]).to(device), |
| 157 | "label_vector": torch.rand(1, 527).to(device), |
| 158 | "stft": torch.rand(1, 1024, 512).to(device), |
| 159 | "mixed_waveform": torch.from_numpy( |
| 160 | chunk_wav.reshape(1, 1, FLOWSEP_CHUNK_IN) |
| 161 | ).to(device), |
| 162 | "mixed_mel": mixed_mel.reshape( |
| 163 | 1, mixed_mel.shape[0], mixed_mel.shape[1] |
| 164 | ).to(device), |
| 165 | } |
| 166 | result = latent_diffusion.generate_sample( |
| 167 | [batch], |
| 168 | name="temp_result", |
| 169 | unconditional_guidance_scale=1.0, |
| 170 | ddim_steps=20, |
| 171 | n_gen=1, |
| 172 | save=False, |
| 173 | save_mixed=False, |
| 174 | ) |
| 175 | if isinstance(result, np.ndarray): |
| 176 | out = result.squeeze() |
| 177 | else: |
| 178 | out = result.squeeze().cpu().numpy() |
| 179 | return out[:FLOWSEP_CHUNK_OUT] |
| 180 | |
| 181 | if input_len <= FLOWSEP_CHUNK_IN: |
| 182 | sep_audio = _process_chunk(full_wav.copy()) |
no test coverage detected