HoneyTian commited on
Commit
4633f64
·
1 Parent(s): 66bf794
toolbox/torchaudio/models/frcrn/inference_frcrn.py CHANGED
@@ -61,7 +61,9 @@ class InferenceFRCRN(object):
61
 
62
  # noisy_audio shape: [batch_size, n_samples]
63
  enhanced_audio = self.enhancement_by_tensor(noisy_audio)
64
- # noisy_audio shape: [n_samples,]
 
 
65
  return enhanced_audio.cpu().numpy()
66
 
67
  def enhancement_by_tensor(self, noisy_audio: torch.Tensor) -> torch.Tensor:
@@ -79,8 +81,7 @@ class InferenceFRCRN(object):
79
  # shape: [batch_size, 1, num_samples]
80
 
81
  enhanced_audio = enhanced_audio[0]
82
-
83
- # enhanced_audio shape: [channels, num_samples]
84
  return enhanced_audio
85
 
86
 
 
61
 
62
  # noisy_audio shape: [batch_size, n_samples]
63
  enhanced_audio = self.enhancement_by_tensor(noisy_audio)
64
+ # enhanced_audio shape: [channels, num_samples]
65
+ enhanced_audio = enhanced_audio[0]
66
+ # enhanced_audio shape: [num_samples]
67
  return enhanced_audio.cpu().numpy()
68
 
69
  def enhancement_by_tensor(self, noisy_audio: torch.Tensor) -> torch.Tensor:
 
81
  # shape: [batch_size, 1, num_samples]
82
 
83
  enhanced_audio = enhanced_audio[0]
84
+ # shape: [channels, num_samples]
 
85
  return enhanced_audio
86
 
87
 
toolbox/torchaudio/models/mpnet/inference_mpnet.py CHANGED
@@ -60,7 +60,9 @@ class InferenceMPNet(object):
60
 
61
  # noisy_audio shape: [batch_size, n_samples]
62
  enhanced_audio = self.enhancement_by_tensor(noisy_audio)
63
- # noisy_audio shape: [n_samples,]
 
 
64
  return enhanced_audio.cpu().numpy()
65
 
66
  def enhancement_by_tensor(self, noisy_audio: torch.Tensor) -> torch.Tensor:
@@ -81,7 +83,12 @@ class InferenceMPNet(object):
81
  )
82
  enhanced_audio = audio_g.detach()
83
 
 
 
 
 
84
  enhanced_audio = enhanced_audio[0]
 
85
  return enhanced_audio
86
 
87
 
 
60
 
61
  # noisy_audio shape: [batch_size, n_samples]
62
  enhanced_audio = self.enhancement_by_tensor(noisy_audio)
63
+ # enhanced_audio shape: [channels, num_samples]
64
+ enhanced_audio = enhanced_audio[0]
65
+ # enhanced_audio shape: [num_samples]
66
  return enhanced_audio.cpu().numpy()
67
 
68
  def enhancement_by_tensor(self, noisy_audio: torch.Tensor) -> torch.Tensor:
 
83
  )
84
  enhanced_audio = audio_g.detach()
85
 
86
+ # shape: [batch_size, num_samples]
87
+ enhanced_audio = torch.unsqueeze(enhanced_audio, dim=1)
88
+ # shape: [batch_size, 1, num_samples]
89
+
90
  enhanced_audio = enhanced_audio[0]
91
+ # shape: [channels, num_samples]
92
  return enhanced_audio
93
 
94