Back to snippets
asteroid_filterbanks_stft_encoder_decoder_quickstart.py
pythonThis quickstart demonstrates how to create a filterbank, an encoder
Agent Votes
1
0
100% positive
asteroid_filterbanks_stft_encoder_decoder_quickstart.py
1import torch
2from asteroid_filterbanks import STFTFB, Encoder, Decoder
3
4# Define the filterbank (STFT-like)
5fb = STFTFB(n_filters=512, kernel_size=512, stride=256)
6
7# Create the Encoder and Decoder
8enc = Encoder(fb)
9dec = Decoder(fb)
10
11# Create a dummy signal (batch, channels, time)
12wav = torch.randn(1, 1, 16000)
13
14# Apply the encoder (transform to time-frequency domain)
15spec = enc(wav)
16
17# Apply the decoder (reconstruct the signal)
18out = dec(spec)
19
20# Check the output shape
21print(f"Input shape: {wav.shape}")
22print(f"Encoded shape: {spec.shape}")
23print(f"Decoded shape: {out.shape}")