nnAudio.features.cfp.CFP¶
- class nnAudio.features.cfp.CFP(fr=2, fs=16000, hop_length=320, window_size=2049, fc=80, tc=0.001, g=[0.24, 0.6, 1], NumPerOct=48)¶
Bases:
torch.nn.modules.module.Module
This is the modified version of
Combined_Frequency_Periodicity()
. This version different from the original version by returnning onlyZ
and the number of timesteps fits with other classes.- Parameters
fr (int) – Frequency resolution. The higher the number, the lower the resolution is. Maximum frequency resolution occurs when
fr=1
. The default value is2
fs (int) – Sample rate of the input audio clips. The default value is
16000
hop_length (int) – The hop (or stride) size. The default value is
320
.window_size (str) – It is same as
n_fft
in other Spectrogram classes. The default value is2049
fc (int) – Starting frequency. For example,
fc=80
means that Z starts at 80Hz. The default value is80
.tc (int) – Inverse of ending frequency. For example
tc=1/8000
means that Z ends at 8000Hz. The default value is1/8000
.g (list) – Coefficients for non-linear activation function.
len(g)
should be the number of activation layers. Each element ing
is the activation coefficient, for example[0.24, 0.6, 1]
.device (str) – Choose which device to initialize this layer. Default value is ‘cpu’
- Returns
Z (torch.tensor) – The Combined Frequency and Period Feature. It is equivalent to
tfrLF * tfrLQ
tfrL0 (torch.tensor) – STFT output
tfrLF (torch.tensor) – Frequency Feature
tfrLQ (torch.tensor) – Period Feature
Examples
>>> spec_layer = Spectrogram.Combined_Frequency_Periodicity() >>> Z, tfrL0, tfrLF, tfrLQ = spec_layer(x)
Methods
__init__
Initializes internal Module state, shared by both nn.Module and ScriptModule.
create_logfreq_matrix
forward
nonlinear_func