MCPcopy Create free account
hub / github.com/AlayaLab/Hive / _flowsep_process_chunk

Function _flowsep_process_chunk

app.py:190–223  ·  view source on GitHub ↗
(model, preprocessor, chunk_wav, text)

Source from the content-addressed store, hash-verified

188
189
190def _flowsep_process_chunk(model, preprocessor, chunk_wav, text):
191 device = get_runtime_device()
192 chunk_wav = preprocessor.preprocess_chunk(chunk_wav)
193 if len(chunk_wav) < FLOWSEP_CHUNK_IN:
194 pad = np.zeros(FLOWSEP_CHUNK_IN - len(chunk_wav), dtype=np.float32)
195 chunk_wav = np.concatenate([chunk_wav, pad])
196 chunk_wav = chunk_wav[:FLOWSEP_CHUNK_IN]
197 mixed_mel, stft = preprocessor.wav_feature_extraction(chunk_wav.reshape(1, -1))
198 batch = {
199 "fname": ["temp"],
200 "text": [text],
201 "caption": [text],
202 "waveform": torch.rand(1, 1, FLOWSEP_CHUNK_IN).to(device),
203 "log_mel_spec": torch.rand(1, 1024, 64).to(device),
204 "sampling_rate": torch.tensor([FLOWSEP_SR]).to(device),
205 "label_vector": torch.rand(1, 527).to(device),
206 "stft": torch.rand(1, 1024, 512).to(device),
207 "mixed_waveform": torch.from_numpy(chunk_wav.reshape(1, 1, FLOWSEP_CHUNK_IN)).to(device),
208 "mixed_mel": mixed_mel.reshape(1, mixed_mel.shape[0], mixed_mel.shape[1]).to(device),
209 }
210 result = model.generate_sample(
211 [batch],
212 name="temp_result",
213 unconditional_guidance_scale=1.0,
214 ddim_steps=20,
215 n_gen=1,
216 save=False,
217 save_mixed=False,
218 )
219 if isinstance(result, np.ndarray):
220 out = result.squeeze()
221 else:
222 out = result.squeeze().cpu().numpy()
223 return out[:FLOWSEP_CHUNK_OUT]
224
225
226def separate_flowsep(audio_path, text):

Callers 1

separate_flowsepFunction · 0.85

Calls 5

get_runtime_deviceFunction · 0.85
generate_sampleMethod · 0.80
preprocess_chunkMethod · 0.45
toMethod · 0.45

Tested by

no test coverage detected