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

Function separate_flowsep

app.py:226–252  ·  view source on GitHub ↗
(audio_path, text)

Source from the content-addressed store, hash-verified

224
225
226def separate_flowsep(audio_path, text):
227 device = get_runtime_device()
228 model, preprocessor = load_flowsep()
229 full_wav = preprocessor.load_full_audio(audio_path)
230 input_len = full_wav.shape[0]
231
232 with torch.no_grad():
233 if input_len <= FLOWSEP_CHUNK_IN:
234 sep_audio = _flowsep_process_chunk(model, preprocessor, full_wav.copy(), text)
235 else:
236 out_list = []
237 start = 0
238 while start < input_len:
239 end = min(start + FLOWSEP_CHUNK_IN, input_len)
240 chunk = full_wav[start:end]
241 out_chunk = _flowsep_process_chunk(model, preprocessor, chunk.copy(), text)
242 need = min(FLOWSEP_CHUNK_OUT, input_len - start)
243 out_list.append(out_chunk[:need])
244 start += FLOWSEP_CHUNK_OUT
245 sep_audio = np.concatenate(out_list)
246
247 if len(sep_audio) > input_len:
248 sep_audio = sep_audio[:input_len]
249 elif len(sep_audio) < input_len:
250 sep_audio = np.pad(sep_audio, (0, input_len - len(sep_audio)), mode="constant", constant_values=0)
251
252 return (FLOWSEP_SR, sep_audio)
253
254
255def inference(audio, text, model_choice):

Callers 2

inferenceFunction · 0.85
run_debugFunction · 0.85

Calls 5

get_runtime_deviceFunction · 0.85
load_flowsepFunction · 0.85
_flowsep_process_chunkFunction · 0.85
load_full_audioMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected