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

Function separate_audiosep

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

Source from the content-addressed store, hash-verified

163
164
165def separate_audiosep(audio_path, text):
166 device = get_runtime_device()
167 model = load_audiosep()
168 mixture, _ = librosa.load(audio_path, sr=AUDIOSEP_SR, mono=True)
169 input_len = mixture.shape[0]
170
171 with torch.no_grad():
172 conditions = model.query_encoder.get_query_embed(
173 modality='text', text=[text], device=device
174 )
175 input_dict = {
176 "mixture": torch.Tensor(mixture)[None, None, :].to(device),
177 "condition": conditions,
178 }
179 if input_len > AUDIOSEP_SR * 10:
180 sep_audio = model.ss_model.chunk_inference(input_dict)
181 sep_audio = sep_audio.squeeze()
182 else:
183 sep_segment = model.ss_model(input_dict)["waveform"]
184 sep_audio = sep_segment.squeeze(0).squeeze(0).data.cpu().numpy()
185 sep_audio = sep_audio[:input_len]
186
187 return (AUDIOSEP_SR, sep_audio)
188
189
190def _flowsep_process_chunk(model, preprocessor, chunk_wav, text):

Callers 2

inferenceFunction · 0.85
run_debugFunction · 0.85

Calls 5

get_runtime_deviceFunction · 0.85
load_audiosepFunction · 0.85
get_query_embedMethod · 0.80
chunk_inferenceMethod · 0.80
toMethod · 0.45

Tested by

no test coverage detected