self.window = torch.from_numpy(get_window(window, win_length, fftbins=True).astype(np.float32))??? #2910
Unanswered
AutumnRoom
asked this question in
Q&A
Replies: 1 comment
-
Not familiar with this scipy function, but turns out there is also a pytorch equivalent. You can implement it with Burn given the formula. fn hann_window<B: Backend>(
mut win_length: usize,
periodic: bool,
device: &B::Device,
) -> Tensor<B, 1> {
// Tensor::<B, 1>::arang
let n = Tensor::arange(0..win_length as i64, device).float();
if periodic {
win_length += 1;
}
// 0.5 - 0.5 * cos(2 * PI * n / (win_length - 1)))
n.mul_scalar(2. * core::f32::consts::PI / (win_length - 1) as f32)
.cos()
.mul_scalar(-0.5)
.add_scalar(0.5)
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
How can a STFT be defined in the Burn like this one:
class TorchSTFT(nn.Module):
def init(self, filter_length=800, hop_length=200, win_length=800, window='hann'):
super().init()
self.filter_length = filter_length
self.hop_length = hop_length
self.win_length = win_length
self.window = torch.from_numpy(get_window(window, win_length, fftbins=True).astype(np.float32))
Beta Was this translation helpful? Give feedback.
All reactions