Commit 000d7526 authored by nateanl's avatar nateanl Committed by Facebook GitHub Bot
Browse files

Fix fading in hybrid demucs tutorial (#2769)

Summary:
The separation applies on chunks of audios to avoid OOM. The combination of consecutive chunks is described in the graph:

![image](https://user-images.githubusercontent.com/8653221/195691886-002844e6-4ec5-41de-8910-df8046553998.png)

In the last audio chunk, there is no future chunk to be combined, hence the overlap on the right side doesn't need to be faded.

Pull Request resolved: https://github.com/pytorch/audio/pull/2769

Reviewed By: carolineechen

Differential Revision: D40358382

Pulled By: nateanl

fbshipit-source-id: ec8be895d7a67acb257e2693b64922397163ed5e
parent 3e4b961d
...@@ -161,7 +161,7 @@ def separate_sources( ...@@ -161,7 +161,7 @@ def separate_sources(
final = torch.zeros(batch, len(model.sources), channels, length, device=device) final = torch.zeros(batch, len(model.sources), channels, length, device=device)
while start < length: while start < length - overlap_frames:
chunk = mix[:, :, start:end] chunk = mix[:, :, start:end]
with torch.no_grad(): with torch.no_grad():
out = model.forward(chunk) out = model.forward(chunk)
...@@ -173,6 +173,8 @@ def separate_sources( ...@@ -173,6 +173,8 @@ def separate_sources(
else: else:
start += chunk_len start += chunk_len
end += chunk_len end += chunk_len
if end >= length:
fade.fade_out_len = 0
return final return final
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment