mattricesound commited on
Commit
93ba80d
1 Parent(s): ab6f776

Fix processing of stereo clips

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -42,14 +42,14 @@ def load_models():
42
  def audio_classification(audio_file):
43
  audio, sr = torchaudio.load(audio_file)
44
  audio = torchaudio.transforms.Resample(sr, cfg.sample_rate)(audio)
45
- # Add dimension for batch
46
- audio = audio.unsqueeze(0)
47
  # Convert to mono
48
  audio = audio.mean(0, keepdim=True)
 
 
49
  audio = audio.to(device)
50
 
51
  with torch.no_grad():
52
- # Classifiy
53
  print("Detecting effects")
54
  labels = torch.tensor(classifier(audio))
55
  labels_dict = {
@@ -62,10 +62,10 @@ def audio_classification(audio_file):
62
  def audio_removal(audio_file, labels, threshold):
63
  audio, sr = torchaudio.load(audio_file)
64
  audio = torchaudio.transforms.Resample(sr, cfg.sample_rate)(audio)
65
- # Add dimension for batch
66
- audio = audio.unsqueeze(0)
67
  # Convert to mono
68
  audio = audio.mean(0, keepdim=True)
 
 
69
  audio = audio.to(device)
70
 
71
  label_names = [f"RandomPedalboard{lab['label']}" for lab in labels["confidences"]]
 
42
  def audio_classification(audio_file):
43
  audio, sr = torchaudio.load(audio_file)
44
  audio = torchaudio.transforms.Resample(sr, cfg.sample_rate)(audio)
 
 
45
  # Convert to mono
46
  audio = audio.mean(0, keepdim=True)
47
+ # Add dimension for batch
48
+ audio = audio.unsqueeze(0)
49
  audio = audio.to(device)
50
 
51
  with torch.no_grad():
52
+ # Classify
53
  print("Detecting effects")
54
  labels = torch.tensor(classifier(audio))
55
  labels_dict = {
 
62
  def audio_removal(audio_file, labels, threshold):
63
  audio, sr = torchaudio.load(audio_file)
64
  audio = torchaudio.transforms.Resample(sr, cfg.sample_rate)(audio)
 
 
65
  # Convert to mono
66
  audio = audio.mean(0, keepdim=True)
67
+ # Add dimension for batch
68
+ audio = audio.unsqueeze(0)
69
  audio = audio.to(device)
70
 
71
  label_names = [f"RandomPedalboard{lab['label']}" for lab in labels["confidences"]]