Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with uploading mono files. Add missing aimless-logo-crop.png #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/aimless-logo-crop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 9 additions & 2 deletions scripts/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from torchaudio.pipelines import HDEMUCS_HIGH_MUSDB_PLUS
from torchaudio.transforms import Fade


st.set_page_config(page_title="aimless-splitter")
st.image("docs/aimless-logo-crop.png", use_column_width="always")

Expand Down Expand Up @@ -118,6 +117,13 @@ def process_file(file, model: torch.nn.Module, device: torch.device):
plot_spectrogram(x_numpy, sample_rate=sample_rate)
st.audio(x_numpy, sample_rate=sample_rate)

# If mono, make stereo
if x.shape[0] == 1:
x = x.repeat(2, 1)
# Otherwise just take first 2 channnels
elif x.shape[0] > 2:
x = x[:2]

waveform = x.to(device)

# split into 10.0 sec chunks
Expand Down Expand Up @@ -150,4 +156,5 @@ def process_file(file, model: torch.nn.Module, device: torch.device):

if uploaded_file is not None:
# split with hdemucs
hdemucs_sources = process_file(uploaded_file, hdemucs, "cuda:0")
device = "cuda:0" if torch.cuda.is_available() else "cpu"
hdemucs_sources = process_file(uploaded_file, hdemucs, device)