diffsptk 3.1.0__tar.gz → 3.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {diffsptk-3.1.0 → diffsptk-3.2.0}/PKG-INFO +3 -3
- {diffsptk-3.1.0 → diffsptk-3.2.0}/README.md +2 -2
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/functional.py +95 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/__init__.py +1 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/fbank.py +11 -3
- diffsptk-3.2.0/diffsptk/modules/griffin.py +272 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/imdct.py +4 -2
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/istft.py +2 -2
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/lpc.py +1 -1
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/mcep.py +1 -1
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/mcpf.py +1 -1
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/mdct.py +4 -4
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/mfcc.py +7 -1
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/mgc2mgc.py +1 -1
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/mgc2sp.py +1 -1
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/plp.py +7 -1
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/pnorm.py +1 -1
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/smcep.py +1 -1
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/spec.py +1 -1
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/stft.py +1 -1
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/unframe.py +4 -5
- diffsptk-3.2.0/diffsptk/version.py +1 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/pyproject.toml +1 -0
- diffsptk-3.1.0/diffsptk/version.py +0 -1
- {diffsptk-3.1.0 → diffsptk-3.2.0}/.gitignore +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/CITATION.cff +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/LICENSE +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/__init__.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/acorr.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/acr2csm.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/alaw.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/ap.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/b2mc.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/base.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/c2acr.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/c2mpir.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/c2ndps.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/cdist.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/chroma.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/cqt.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/csm2acr.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/dct.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/decimate.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/delay.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/delta.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/dequantize.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/df2.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/dfs.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/dht.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/drc.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/dst.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/entropy.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/excite.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/fftcep.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/fftr.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/flux.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/frame.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/freqt.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/freqt2.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/gammatone.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/gmm.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/gnorm.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/grpdelay.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/hilbert.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/hilbert2.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/histogram.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/ialaw.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/ica.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/icqt.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/idct.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/idht.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/idst.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/ifftr.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/ifreqt2.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/igammatone.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/ignorm.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/imdst.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/imglsadf.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/imsvq.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/interpolate.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/ipnorm.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/ipqmf.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/is2par.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/iulaw.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/ivq.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/lar2par.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/lbg.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/levdur.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/linear_intpl.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/lpc2lsp.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/lpc2par.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/lpccheck.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/lsp2lpc.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/lsp2sp.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/lspcheck.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/magic_intpl.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/mc2b.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/mdst.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/mgcep.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/mglsadf.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/mlpg.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/mlsacheck.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/mpir2c.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/msvq.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/ndps2c.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/nmf.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/norm0.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/par2is.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/par2lar.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/par2lpc.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/pca.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/phase.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/pitch.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/pitch_spec.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/pol_root.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/poledf.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/pqmf.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/quantize.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/rlevdur.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/rmse.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/root_pol.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/snr.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/ulaw.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/vq.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/wht.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/window.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/world_synth.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/yingram.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/zcross.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/modules/zerodf.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/signals.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/third_party/librosa/LICENSE +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/third_party/librosa/__init__.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/third_party/librosa/constantq.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/third_party/librosa/filters.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/third_party/librosa/typing.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/third_party/librosa/util.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/third_party/world/LICENSE +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/third_party/world/__init__.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/third_party/world/common.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/typing.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/utils/__init__.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/utils/private.py +0 -0
- {diffsptk-3.1.0 → diffsptk-3.2.0}/diffsptk/utils/public.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: diffsptk
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.2.0
|
|
4
4
|
Summary: Speech signal processing modules for machine learning
|
|
5
5
|
Project-URL: Homepage, https://sp-tk.sourceforge.net/
|
|
6
6
|
Project-URL: Documentation, https://sp-nitech.github.io/diffsptk/latest/
|
|
@@ -47,7 +47,7 @@ Description-Content-Type: text/markdown
|
|
|
47
47
|
|
|
48
48
|
*diffsptk* is a differentiable version of [SPTK](https://github.com/sp-nitech/SPTK) based on the PyTorch framework.
|
|
49
49
|
|
|
50
|
-
[](https://sp-nitech.github.io/diffsptk/3.
|
|
50
|
+
[](https://sp-nitech.github.io/diffsptk/3.2.0/)
|
|
51
51
|
[](https://pepy.tech/project/diffsptk)
|
|
52
52
|
[](https://clickpy.clickhouse.com/dashboard/diffsptk)
|
|
53
53
|
[](https://pypi.python.org/pypi/diffsptk)
|
|
@@ -65,7 +65,7 @@ Description-Content-Type: text/markdown
|
|
|
65
65
|
|
|
66
66
|
## Documentation
|
|
67
67
|
|
|
68
|
-
- See [this page](https://sp-nitech.github.io/diffsptk/3.
|
|
68
|
+
- See [this page](https://sp-nitech.github.io/diffsptk/3.2.0/) for the reference manual.
|
|
69
69
|
- Our [paper](https://www.isca-speech.org/archive/ssw_2023/yoshimura23_ssw.html) is available on the ISCA Archive.
|
|
70
70
|
|
|
71
71
|
## Installation
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
*diffsptk* is a differentiable version of [SPTK](https://github.com/sp-nitech/SPTK) based on the PyTorch framework.
|
|
4
4
|
|
|
5
|
-
[](https://sp-nitech.github.io/diffsptk/3.
|
|
5
|
+
[](https://sp-nitech.github.io/diffsptk/3.2.0/)
|
|
6
6
|
[](https://pepy.tech/project/diffsptk)
|
|
7
7
|
[](https://clickpy.clickhouse.com/dashboard/diffsptk)
|
|
8
8
|
[](https://pypi.python.org/pypi/diffsptk)
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
## Documentation
|
|
22
22
|
|
|
23
|
-
- See [this page](https://sp-nitech.github.io/diffsptk/3.
|
|
23
|
+
- See [this page](https://sp-nitech.github.io/diffsptk/3.2.0/) for the reference manual.
|
|
24
24
|
- Our [paper](https://www.isca-speech.org/archive/ssw_2023/yoshimura23_ssw.html) is available on the ISCA Archive.
|
|
25
25
|
|
|
26
26
|
## Installation
|
|
@@ -864,6 +864,101 @@ def gnorm(x: Tensor, gamma: float = 0, c: int | None = None) -> Tensor:
|
|
|
864
864
|
return nn.GeneralizedCepstrumGainNormalization._func(x, gamma=gamma, c=c)
|
|
865
865
|
|
|
866
866
|
|
|
867
|
+
def griffin(
|
|
868
|
+
y: Tensor,
|
|
869
|
+
*,
|
|
870
|
+
out_length: int | None = None,
|
|
871
|
+
frame_length: int = 400,
|
|
872
|
+
frame_period: int = 80,
|
|
873
|
+
fft_length: int = 512,
|
|
874
|
+
center: bool = True,
|
|
875
|
+
mode: str = "constant",
|
|
876
|
+
window: str = "blackman",
|
|
877
|
+
norm: str = "power",
|
|
878
|
+
symmetric: bool = True,
|
|
879
|
+
n_iter: int = 100,
|
|
880
|
+
alpha: float = 0.99,
|
|
881
|
+
beta: float = 0.99,
|
|
882
|
+
gamma: float = 1.1,
|
|
883
|
+
init_phase: str = "random",
|
|
884
|
+
verbose: bool = False,
|
|
885
|
+
) -> Tensor:
|
|
886
|
+
"""Reconstruct a waveform from the spectrum using the Griffin-Lim algorithm.
|
|
887
|
+
|
|
888
|
+
Parameters
|
|
889
|
+
----------
|
|
890
|
+
y : Tensor [shape=(..., T/P, N/2+1)]
|
|
891
|
+
The power spectrum.
|
|
892
|
+
|
|
893
|
+
out_length : int > 0 or None
|
|
894
|
+
The length of the output waveform.
|
|
895
|
+
|
|
896
|
+
frame_length : int >= 1
|
|
897
|
+
The frame length in samples, :math:`L`.
|
|
898
|
+
|
|
899
|
+
frame_period : int >= 1
|
|
900
|
+
The frame period in samples, :math:`P`.
|
|
901
|
+
|
|
902
|
+
fft_length : int >= L
|
|
903
|
+
The number of FFT bins, :math:`N`.
|
|
904
|
+
|
|
905
|
+
center : bool
|
|
906
|
+
If True, pad the input on both sides so that the frame is centered.
|
|
907
|
+
|
|
908
|
+
window : ['blackman', 'hamming', 'hanning', 'bartlett', 'trapezoidal', \
|
|
909
|
+
'rectangular', 'nuttall']
|
|
910
|
+
The window type.
|
|
911
|
+
|
|
912
|
+
norm : ['none', 'power', 'magnitude']
|
|
913
|
+
The normalization type of the window.
|
|
914
|
+
|
|
915
|
+
symmetric : bool
|
|
916
|
+
If True, the window is symmetric, otherwise periodic.
|
|
917
|
+
|
|
918
|
+
n_iter : int >= 1
|
|
919
|
+
The number of iterations for phase reconstruction.
|
|
920
|
+
|
|
921
|
+
alpha : float >= 0
|
|
922
|
+
The momentum factor, :math:`\\alpha`.
|
|
923
|
+
|
|
924
|
+
beta : float >= 0
|
|
925
|
+
The momentum factor, :math:`\\beta`.
|
|
926
|
+
|
|
927
|
+
gamma : float >= 0
|
|
928
|
+
The smoothing factor, :math:`\\gamma`.
|
|
929
|
+
|
|
930
|
+
init_phase : ['zeros', 'random']
|
|
931
|
+
The initial phase for the reconstruction.
|
|
932
|
+
|
|
933
|
+
verbose : bool
|
|
934
|
+
If True, print the SNR at each iteration.
|
|
935
|
+
|
|
936
|
+
Returns
|
|
937
|
+
-------
|
|
938
|
+
out : Tensor [shape=(..., T)]
|
|
939
|
+
The reconstructed waveform.
|
|
940
|
+
|
|
941
|
+
"""
|
|
942
|
+
return nn.GriffinLim._func(
|
|
943
|
+
y,
|
|
944
|
+
out_length=out_length,
|
|
945
|
+
frame_length=frame_length,
|
|
946
|
+
frame_period=frame_period,
|
|
947
|
+
fft_length=fft_length,
|
|
948
|
+
center=center,
|
|
949
|
+
mode=mode,
|
|
950
|
+
window=window,
|
|
951
|
+
norm=norm,
|
|
952
|
+
symmetric=symmetric,
|
|
953
|
+
n_iter=n_iter,
|
|
954
|
+
alpha=alpha,
|
|
955
|
+
beta=beta,
|
|
956
|
+
gamma=gamma,
|
|
957
|
+
init_phase=init_phase,
|
|
958
|
+
verbose=verbose,
|
|
959
|
+
)
|
|
960
|
+
|
|
961
|
+
|
|
867
962
|
def grpdelay(
|
|
868
963
|
b: Tensor | None = None,
|
|
869
964
|
a: Tensor | None = None,
|
|
@@ -56,6 +56,7 @@ from .gammatone import GammatoneFilterBankAnalysis
|
|
|
56
56
|
from .gmm import GaussianMixtureModeling
|
|
57
57
|
from .gmm import GaussianMixtureModeling as GMM
|
|
58
58
|
from .gnorm import GeneralizedCepstrumGainNormalization
|
|
59
|
+
from .griffin import GriffinLim
|
|
59
60
|
from .grpdelay import GroupDelay
|
|
60
61
|
from .hilbert import HilbertTransform
|
|
61
62
|
from .hilbert2 import TwoDimensionalHilbertTransform
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import numpy as np
|
|
18
18
|
import torch
|
|
19
|
+
from torch import nn
|
|
19
20
|
|
|
20
21
|
from ..typing import Callable, Precomputed
|
|
21
22
|
from ..utils.private import check_size, get_values, to
|
|
@@ -56,6 +57,9 @@ class MelFilterBankAnalysis(BaseFunctionalModule):
|
|
|
56
57
|
`y` is mel filber bank output and `E` is energy. If this is `yE`, the two output
|
|
57
58
|
tensors are concatenated and return the tensor instead of the tuple.
|
|
58
59
|
|
|
60
|
+
learnable : bool
|
|
61
|
+
Whether to make the basis learnable.
|
|
62
|
+
|
|
59
63
|
References
|
|
60
64
|
----------
|
|
61
65
|
.. [1] S. Young et al., "The HTK Book," *Cambridge University Press*, 2006.
|
|
@@ -74,13 +78,17 @@ class MelFilterBankAnalysis(BaseFunctionalModule):
|
|
|
74
78
|
gamma: float = 0,
|
|
75
79
|
use_power: bool = False,
|
|
76
80
|
out_format: str | int = "y",
|
|
81
|
+
learnable: bool = False,
|
|
77
82
|
) -> None:
|
|
78
83
|
super().__init__()
|
|
79
84
|
|
|
80
85
|
self.in_dim = fft_length // 2 + 1
|
|
81
86
|
|
|
82
|
-
self.values, _, tensors = self._precompute(*get_values(locals()))
|
|
83
|
-
|
|
87
|
+
self.values, _, tensors = self._precompute(*get_values(locals(), drop=1))
|
|
88
|
+
if learnable:
|
|
89
|
+
self.H = nn.Parameter(tensors[0])
|
|
90
|
+
else:
|
|
91
|
+
self.register_buffer("H", tensors[0])
|
|
84
92
|
|
|
85
93
|
def forward(
|
|
86
94
|
self, x: torch.Tensor
|
|
@@ -114,7 +122,7 @@ class MelFilterBankAnalysis(BaseFunctionalModule):
|
|
|
114
122
|
|
|
115
123
|
"""
|
|
116
124
|
check_size(x.size(-1), self.in_dim, "dimension of spectrum")
|
|
117
|
-
return self._forward(x, *self.values, **self._buffers)
|
|
125
|
+
return self._forward(x, *self.values, **self._buffers, **self._parameters)
|
|
118
126
|
|
|
119
127
|
@staticmethod
|
|
120
128
|
def _func(
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# ------------------------------------------------------------------------ #
|
|
2
|
+
# Copyright 2022 SPTK Working Group #
|
|
3
|
+
# #
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); #
|
|
5
|
+
# you may not use this file except in compliance with the License. #
|
|
6
|
+
# You may obtain a copy of the License at #
|
|
7
|
+
# #
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
|
9
|
+
# #
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software #
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
|
13
|
+
# See the License for the specific language governing permissions and #
|
|
14
|
+
# limitations under the License. #
|
|
15
|
+
# ------------------------------------------------------------------------ #
|
|
16
|
+
|
|
17
|
+
import inspect
|
|
18
|
+
import logging
|
|
19
|
+
|
|
20
|
+
import torch
|
|
21
|
+
from torch import nn
|
|
22
|
+
|
|
23
|
+
from ..typing import Callable, Precomputed
|
|
24
|
+
from ..utils.private import TAU, get_layer, get_logger, get_values
|
|
25
|
+
from .base import BaseFunctionalModule
|
|
26
|
+
from .istft import InverseShortTimeFourierTransform
|
|
27
|
+
from .stft import ShortTimeFourierTransform
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class GriffinLim(BaseFunctionalModule):
|
|
31
|
+
"""Griffin-Lim phase reconstruction module.
|
|
32
|
+
|
|
33
|
+
Parameters
|
|
34
|
+
----------
|
|
35
|
+
frame_length : int >= 1
|
|
36
|
+
The frame length in samples, :math:`L`.
|
|
37
|
+
|
|
38
|
+
frame_period : int >= 1
|
|
39
|
+
The frame period in samples, :math:`P`.
|
|
40
|
+
|
|
41
|
+
fft_length : int >= L
|
|
42
|
+
The number of FFT bins, :math:`N`.
|
|
43
|
+
|
|
44
|
+
center : bool
|
|
45
|
+
If True, pad the input on both sides so that the frame is centered.
|
|
46
|
+
|
|
47
|
+
window : ['blackman', 'hamming', 'hanning', 'bartlett', 'trapezoidal', \
|
|
48
|
+
'rectangular', 'nuttall']
|
|
49
|
+
The window type.
|
|
50
|
+
|
|
51
|
+
norm : ['none', 'power', 'magnitude']
|
|
52
|
+
The normalization type of the window.
|
|
53
|
+
|
|
54
|
+
symmetric : bool
|
|
55
|
+
If True, the window is symmetric, otherwise periodic.
|
|
56
|
+
|
|
57
|
+
n_iter : int >= 1
|
|
58
|
+
The number of iterations for phase reconstruction.
|
|
59
|
+
|
|
60
|
+
alpha : float >= 0
|
|
61
|
+
The momentum factor, :math:`\\alpha`.
|
|
62
|
+
|
|
63
|
+
beta : float >= 0
|
|
64
|
+
The momentum factor, :math:`\\beta`.
|
|
65
|
+
|
|
66
|
+
gamma : float >= 0
|
|
67
|
+
The smoothing factor, :math:`\\gamma`.
|
|
68
|
+
|
|
69
|
+
init_phase : ['zeros', 'random']
|
|
70
|
+
The initial phase for the reconstruction.
|
|
71
|
+
|
|
72
|
+
verbose : bool
|
|
73
|
+
If True, print the SNR at each iteration.
|
|
74
|
+
|
|
75
|
+
References
|
|
76
|
+
----------
|
|
77
|
+
.. [1] R. Nenov et al., "Faster than fast: Accelerating the Griffin-Lim algorithm,"
|
|
78
|
+
*Proceedings of ICASSP*, 2023.
|
|
79
|
+
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
def __init__(
|
|
83
|
+
self,
|
|
84
|
+
frame_length: int,
|
|
85
|
+
frame_period: int,
|
|
86
|
+
fft_length: int,
|
|
87
|
+
*,
|
|
88
|
+
center: bool = True,
|
|
89
|
+
mode: str = "constant",
|
|
90
|
+
window: str = "blackman",
|
|
91
|
+
norm: str = "power",
|
|
92
|
+
symmetric: bool = True,
|
|
93
|
+
n_iter: int = 100,
|
|
94
|
+
alpha: float = 0.99,
|
|
95
|
+
beta: float = 0.99,
|
|
96
|
+
gamma: float = 1.1,
|
|
97
|
+
init_phase: str = "random",
|
|
98
|
+
verbose: bool = False,
|
|
99
|
+
) -> None:
|
|
100
|
+
super().__init__()
|
|
101
|
+
|
|
102
|
+
self.values, layers, _ = self._precompute(*get_values(locals()))
|
|
103
|
+
self.layers = nn.ModuleList(layers)
|
|
104
|
+
|
|
105
|
+
def forward(self, y: torch.Tensor, out_length: int | None = None) -> torch.Tensor:
|
|
106
|
+
"""Reconstruct a waveform from the spectrum using the Griffin-Lim algorithm.
|
|
107
|
+
|
|
108
|
+
Parameters
|
|
109
|
+
----------
|
|
110
|
+
y : Tensor [shape=(..., T/P, N/2+1)]
|
|
111
|
+
The power spectrum.
|
|
112
|
+
|
|
113
|
+
out_length : int > 0 or None
|
|
114
|
+
The length of the output waveform.
|
|
115
|
+
|
|
116
|
+
Returns
|
|
117
|
+
-------
|
|
118
|
+
out : Tensor [shape=(..., T)]
|
|
119
|
+
The reconstructed waveform.
|
|
120
|
+
|
|
121
|
+
Examples
|
|
122
|
+
--------
|
|
123
|
+
>>> x = diffsptk.ramp(1, 3)
|
|
124
|
+
>>> x
|
|
125
|
+
tensor([1., 2., 3.])
|
|
126
|
+
>>> stft_params = {"frame_length": 3, "frame_period": 1, "fft_length": 8}
|
|
127
|
+
>>> stft = diffsptk.STFT(**stft_params, out_format="power")
|
|
128
|
+
>>> griffin = diffsptk.GriffinLim(**stft_params, n_iter=10, init_phase="zeros")
|
|
129
|
+
>>> y = griffin(stft(x), out_length=3)
|
|
130
|
+
>>> y
|
|
131
|
+
tensor([ 1.0000, 2.0000, -3.0000])
|
|
132
|
+
|
|
133
|
+
"""
|
|
134
|
+
return self._forward(y, out_length, *self.values, *self.layers)
|
|
135
|
+
|
|
136
|
+
@staticmethod
|
|
137
|
+
def _func(y: torch.Tensor, out_length: int | None, *args, **kwargs) -> torch.Tensor:
|
|
138
|
+
values, layers, _ = GriffinLim._precompute(*args, **kwargs)
|
|
139
|
+
return GriffinLim._forward(y, out_length, *values, *layers)
|
|
140
|
+
|
|
141
|
+
@staticmethod
|
|
142
|
+
def _takes_input_size() -> bool:
|
|
143
|
+
return False
|
|
144
|
+
|
|
145
|
+
@staticmethod
|
|
146
|
+
def _check(
|
|
147
|
+
n_iter: int,
|
|
148
|
+
alpha: float,
|
|
149
|
+
beta: float,
|
|
150
|
+
gamma: float,
|
|
151
|
+
) -> None:
|
|
152
|
+
if n_iter <= 0:
|
|
153
|
+
raise ValueError("n_iter must be positive.")
|
|
154
|
+
if alpha < 0:
|
|
155
|
+
raise ValueError("alpha must be non-negative.")
|
|
156
|
+
if beta < 0:
|
|
157
|
+
raise ValueError("beta must be non-negative.")
|
|
158
|
+
if gamma < 0:
|
|
159
|
+
raise ValueError("gamma must be non-negative.")
|
|
160
|
+
|
|
161
|
+
@staticmethod
|
|
162
|
+
def _precompute(
|
|
163
|
+
frame_length: int,
|
|
164
|
+
frame_period: int,
|
|
165
|
+
fft_length: int,
|
|
166
|
+
center: bool,
|
|
167
|
+
mode: str,
|
|
168
|
+
window: str,
|
|
169
|
+
norm: str,
|
|
170
|
+
symmetric: bool,
|
|
171
|
+
n_iter: int,
|
|
172
|
+
alpha: float,
|
|
173
|
+
beta: float,
|
|
174
|
+
gamma: float,
|
|
175
|
+
init_phase: str,
|
|
176
|
+
verbose: bool,
|
|
177
|
+
) -> Precomputed:
|
|
178
|
+
GriffinLim._check(n_iter, alpha, beta, gamma)
|
|
179
|
+
module = inspect.stack()[1].function != "_func"
|
|
180
|
+
|
|
181
|
+
if init_phase == "zeros":
|
|
182
|
+
phase_generator = lambda x: torch.zeros_like(x)
|
|
183
|
+
elif init_phase == "random":
|
|
184
|
+
phase_generator = lambda x: TAU * torch.rand_like(x)
|
|
185
|
+
else:
|
|
186
|
+
raise ValueError(f"init_phase: {init_phase} is not supported.")
|
|
187
|
+
|
|
188
|
+
if verbose:
|
|
189
|
+
logger = get_logger("griffin")
|
|
190
|
+
else:
|
|
191
|
+
logger = None
|
|
192
|
+
|
|
193
|
+
stft = get_layer(
|
|
194
|
+
module,
|
|
195
|
+
ShortTimeFourierTransform,
|
|
196
|
+
dict(
|
|
197
|
+
frame_length=frame_length,
|
|
198
|
+
frame_period=frame_period,
|
|
199
|
+
fft_length=fft_length,
|
|
200
|
+
center=center,
|
|
201
|
+
zmean=False,
|
|
202
|
+
mode=mode,
|
|
203
|
+
window=window,
|
|
204
|
+
norm=norm,
|
|
205
|
+
symmetric=symmetric,
|
|
206
|
+
eps=0,
|
|
207
|
+
relative_floor=None,
|
|
208
|
+
out_format="complex",
|
|
209
|
+
),
|
|
210
|
+
)
|
|
211
|
+
istft = get_layer(
|
|
212
|
+
module,
|
|
213
|
+
InverseShortTimeFourierTransform,
|
|
214
|
+
dict(
|
|
215
|
+
frame_length=frame_length,
|
|
216
|
+
frame_period=frame_period,
|
|
217
|
+
fft_length=fft_length,
|
|
218
|
+
center=center,
|
|
219
|
+
window=window,
|
|
220
|
+
norm=norm,
|
|
221
|
+
symmetric=symmetric,
|
|
222
|
+
),
|
|
223
|
+
)
|
|
224
|
+
return (
|
|
225
|
+
(n_iter, alpha, beta, gamma, phase_generator, logger),
|
|
226
|
+
(stft, istft),
|
|
227
|
+
None,
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
@staticmethod
|
|
231
|
+
def _forward(
|
|
232
|
+
y: torch.Tensor,
|
|
233
|
+
out_length: int | None,
|
|
234
|
+
n_iter: int,
|
|
235
|
+
alpha: float,
|
|
236
|
+
beta: float,
|
|
237
|
+
gamma: float,
|
|
238
|
+
phase_generator: Callable,
|
|
239
|
+
logger: logging.Logger | None,
|
|
240
|
+
stft: Callable,
|
|
241
|
+
istft: Callable,
|
|
242
|
+
) -> torch.Tensor:
|
|
243
|
+
if logger is not None:
|
|
244
|
+
logger.info(f"alpha: {alpha}, beta: {beta}, gamma: {gamma}")
|
|
245
|
+
|
|
246
|
+
s = torch.sqrt(y)
|
|
247
|
+
angle = torch.exp(1j * phase_generator(s))
|
|
248
|
+
|
|
249
|
+
t_prev = d_prev = 0 # This suppresses F821 and F841.
|
|
250
|
+
for n in range(n_iter):
|
|
251
|
+
t = stft(istft(s * angle, out_length=out_length))
|
|
252
|
+
t = t[..., : s.shape[-2], :]
|
|
253
|
+
|
|
254
|
+
if 0 == n:
|
|
255
|
+
c = d = t
|
|
256
|
+
else:
|
|
257
|
+
t = (1 - gamma) * d_prev + gamma * t
|
|
258
|
+
diff = t - t_prev
|
|
259
|
+
c = t + alpha * diff
|
|
260
|
+
d = t + beta * diff
|
|
261
|
+
|
|
262
|
+
angle = c / (c.abs() + 1e-16)
|
|
263
|
+
t_prev = t
|
|
264
|
+
d_prev = d
|
|
265
|
+
|
|
266
|
+
if logger is not None:
|
|
267
|
+
snr = -10 * torch.log10(
|
|
268
|
+
torch.linalg.norm(c.abs() - s) / torch.linalg.norm(s)
|
|
269
|
+
)
|
|
270
|
+
logger.info(f" iter {n + 1:5d}: SNR = {snr:g}")
|
|
271
|
+
|
|
272
|
+
return istft(s * angle, out_length=out_length)
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
# limitations under the License. #
|
|
15
15
|
# ------------------------------------------------------------------------ #
|
|
16
16
|
|
|
17
|
+
import inspect
|
|
18
|
+
|
|
17
19
|
import torch
|
|
18
20
|
from torch import nn
|
|
19
21
|
|
|
@@ -88,7 +90,7 @@ class InverseModifiedDiscreteCosineTransform(BaseFunctionalModule):
|
|
|
88
90
|
@staticmethod
|
|
89
91
|
def _func(y: torch.Tensor, out_length: int | None, *args, **kwargs) -> torch.Tensor:
|
|
90
92
|
values, layers, _ = InverseModifiedDiscreteCosineTransform._precompute(
|
|
91
|
-
*args, **kwargs
|
|
93
|
+
*args, **kwargs
|
|
92
94
|
)
|
|
93
95
|
return InverseModifiedDiscreteCosineTransform._forward(
|
|
94
96
|
y, out_length, *values, *layers
|
|
@@ -108,9 +110,9 @@ class InverseModifiedDiscreteCosineTransform(BaseFunctionalModule):
|
|
|
108
110
|
window: str,
|
|
109
111
|
learnable: bool | list[str] = False,
|
|
110
112
|
transform: str = "cosine",
|
|
111
|
-
module: bool = True,
|
|
112
113
|
) -> Precomputed:
|
|
113
114
|
InverseModifiedDiscreteCosineTransform._check(learnable)
|
|
115
|
+
module = inspect.stack()[1].function != "_func"
|
|
114
116
|
frame_period = frame_length // 2
|
|
115
117
|
|
|
116
118
|
if learnable is True:
|
|
@@ -134,7 +134,7 @@ class InverseShortTimeFourierTransform(BaseFunctionalModule):
|
|
|
134
134
|
learnable: bool | list[str] = False,
|
|
135
135
|
) -> Precomputed:
|
|
136
136
|
InverseShortTimeFourierTransform._check(learnable)
|
|
137
|
-
module = inspect.stack()[1].function
|
|
137
|
+
module = inspect.stack()[1].function != "_func"
|
|
138
138
|
|
|
139
139
|
if learnable is True:
|
|
140
140
|
learnable = LEARNABLES
|
|
@@ -172,4 +172,4 @@ class InverseShortTimeFourierTransform(BaseFunctionalModule):
|
|
|
172
172
|
ifftr: Callable,
|
|
173
173
|
unframe: Callable,
|
|
174
174
|
) -> torch.Tensor:
|
|
175
|
-
return unframe(ifftr(y), out_length)
|
|
175
|
+
return unframe(ifftr(y), out_length=out_length)
|
|
@@ -98,7 +98,7 @@ class LinearPredictiveCodingAnalysis(BaseFunctionalModule):
|
|
|
98
98
|
dtype: torch.dtype | None = None,
|
|
99
99
|
) -> Precomputed:
|
|
100
100
|
LinearPredictiveCodingAnalysis._check()
|
|
101
|
-
module = inspect.stack()[1].function
|
|
101
|
+
module = inspect.stack()[1].function != "_func"
|
|
102
102
|
|
|
103
103
|
acorr = get_layer(
|
|
104
104
|
module,
|
|
@@ -127,7 +127,7 @@ class MelCepstralAnalysis(BaseFunctionalModule):
|
|
|
127
127
|
dtype: torch.dtype | None = None,
|
|
128
128
|
):
|
|
129
129
|
MelCepstralAnalysis._check(fft_length, cep_order, alpha, n_iter)
|
|
130
|
-
module = inspect.stack()[1].function
|
|
130
|
+
module = inspect.stack()[1].function != "_func"
|
|
131
131
|
|
|
132
132
|
freqt = get_layer(
|
|
133
133
|
module,
|
|
@@ -128,7 +128,7 @@ class MelCepstrumPostfiltering(BaseFunctionalModule):
|
|
|
128
128
|
dtype: torch.dtype | None = None,
|
|
129
129
|
) -> Precomputed:
|
|
130
130
|
MelCepstrumPostfiltering._check(onset)
|
|
131
|
-
module = inspect.stack()[1].function
|
|
131
|
+
module = inspect.stack()[1].function != "_func"
|
|
132
132
|
|
|
133
133
|
freqt = get_layer(
|
|
134
134
|
module,
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
# limitations under the License. #
|
|
15
15
|
# ------------------------------------------------------------------------ #
|
|
16
16
|
|
|
17
|
+
import inspect
|
|
18
|
+
|
|
17
19
|
import torch
|
|
18
20
|
import torch.nn.functional as F
|
|
19
21
|
from torch import nn
|
|
@@ -86,9 +88,7 @@ class ModifiedDiscreteCosineTransform(BaseFunctionalModule):
|
|
|
86
88
|
|
|
87
89
|
@staticmethod
|
|
88
90
|
def _func(x: torch.Tensor, *args, **kwargs) -> torch.Tensor:
|
|
89
|
-
values, layers, _ = ModifiedDiscreteCosineTransform._precompute(
|
|
90
|
-
*args, **kwargs, module=False
|
|
91
|
-
)
|
|
91
|
+
values, layers, _ = ModifiedDiscreteCosineTransform._precompute(*args, **kwargs)
|
|
92
92
|
return ModifiedDiscreteCosineTransform._forward(x, *values, *layers)
|
|
93
93
|
|
|
94
94
|
@staticmethod
|
|
@@ -109,9 +109,9 @@ class ModifiedDiscreteCosineTransform(BaseFunctionalModule):
|
|
|
109
109
|
window: str,
|
|
110
110
|
learnable: bool | list[str] = False,
|
|
111
111
|
transform: str = "cosine",
|
|
112
|
-
module: bool = True,
|
|
113
112
|
) -> Precomputed:
|
|
114
113
|
ModifiedDiscreteCosineTransform._check(learnable)
|
|
114
|
+
module = inspect.stack()[1].function != "_func"
|
|
115
115
|
frame_period = frame_length // 2
|
|
116
116
|
|
|
117
117
|
if learnable is True:
|
|
@@ -62,6 +62,9 @@ class MelFrequencyCepstralCoefficientsAnalysis(BaseFunctionalModule):
|
|
|
62
62
|
out_format : ['y', 'yE', 'yc', 'ycE']
|
|
63
63
|
`y` is MFCC, `c` is C0, and `E` is energy.
|
|
64
64
|
|
|
65
|
+
learnable : bool
|
|
66
|
+
Whether to make the mel basis learnable.
|
|
67
|
+
|
|
65
68
|
References
|
|
66
69
|
----------
|
|
67
70
|
.. [1] S. Young et al., "The HTK Book," *Cambridge University Press*, 2006.
|
|
@@ -84,6 +87,7 @@ class MelFrequencyCepstralCoefficientsAnalysis(BaseFunctionalModule):
|
|
|
84
87
|
floor: float = 1e-5,
|
|
85
88
|
gamma: float = 0,
|
|
86
89
|
out_format: str | int = "y",
|
|
90
|
+
learnable: bool = False,
|
|
87
91
|
) -> None:
|
|
88
92
|
super().__init__()
|
|
89
93
|
|
|
@@ -159,11 +163,12 @@ class MelFrequencyCepstralCoefficientsAnalysis(BaseFunctionalModule):
|
|
|
159
163
|
floor: float,
|
|
160
164
|
gamma: float,
|
|
161
165
|
out_format: str | int,
|
|
166
|
+
learnable: bool = False,
|
|
162
167
|
device: torch.device | None = None,
|
|
163
168
|
dtype: torch.dtype | None = None,
|
|
164
169
|
) -> Precomputed:
|
|
165
170
|
MelFrequencyCepstralCoefficientsAnalysis._check(mfcc_order, n_channel, lifter)
|
|
166
|
-
module = inspect.stack()[1].function
|
|
171
|
+
module = inspect.stack()[1].function != "_func"
|
|
167
172
|
|
|
168
173
|
if out_format in (0, "y"):
|
|
169
174
|
formatter = lambda y, c, E: y
|
|
@@ -189,6 +194,7 @@ class MelFrequencyCepstralCoefficientsAnalysis(BaseFunctionalModule):
|
|
|
189
194
|
gamma=gamma,
|
|
190
195
|
use_power=False,
|
|
191
196
|
out_format="y,E",
|
|
197
|
+
learnable=learnable,
|
|
192
198
|
),
|
|
193
199
|
)
|
|
194
200
|
dct = get_layer(
|
|
@@ -187,7 +187,7 @@ class MelGeneralizedCepstrumToMelGeneralizedCepstrum(BaseFunctionalModule):
|
|
|
187
187
|
MelGeneralizedCepstrumToMelGeneralizedCepstrum._check(
|
|
188
188
|
in_order, out_order, in_alpha, out_alpha, in_gamma, out_gamma, in_mul, n_fft
|
|
189
189
|
)
|
|
190
|
-
module = inspect.stack()[1].function
|
|
190
|
+
module = inspect.stack()[1].function != "_func"
|
|
191
191
|
|
|
192
192
|
seq = []
|
|
193
193
|
if not in_norm and in_mul:
|
|
@@ -158,7 +158,7 @@ class MelGeneralizedCepstrumToSpectrum(BaseFunctionalModule):
|
|
|
158
158
|
raise ValueError(f"out_format {out_format} is not supported.")
|
|
159
159
|
|
|
160
160
|
mgc2c = get_layer(
|
|
161
|
-
inspect.stack()[1].function
|
|
161
|
+
inspect.stack()[1].function != "_func",
|
|
162
162
|
MelGeneralizedCepstrumToMelGeneralizedCepstrum,
|
|
163
163
|
dict(
|
|
164
164
|
in_order=cep_order,
|
|
@@ -71,6 +71,9 @@ class PerceptualLinearPredictiveCoefficientsAnalysis(BaseFunctionalModule):
|
|
|
71
71
|
out_format : ['y', 'yE', 'yc', 'ycE']
|
|
72
72
|
`y` is PLP, `c` is C0, and `E` is energy.
|
|
73
73
|
|
|
74
|
+
learnable : bool
|
|
75
|
+
Whether to make the mel basis learnable.
|
|
76
|
+
|
|
74
77
|
References
|
|
75
78
|
----------
|
|
76
79
|
.. [1] S. Young et al., "The HTK Book," *Cambridge University Press*, 2006.
|
|
@@ -92,6 +95,7 @@ class PerceptualLinearPredictiveCoefficientsAnalysis(BaseFunctionalModule):
|
|
|
92
95
|
gamma: float = 0,
|
|
93
96
|
n_fft: int = 512,
|
|
94
97
|
out_format: str | int = "y",
|
|
98
|
+
learnable: bool = False,
|
|
95
99
|
) -> None:
|
|
96
100
|
super().__init__()
|
|
97
101
|
|
|
@@ -176,13 +180,14 @@ class PerceptualLinearPredictiveCoefficientsAnalysis(BaseFunctionalModule):
|
|
|
176
180
|
gamma: float,
|
|
177
181
|
n_fft: int,
|
|
178
182
|
out_format: str | int,
|
|
183
|
+
learnable: bool = False,
|
|
179
184
|
device: torch.device | None = None,
|
|
180
185
|
dtype: torch.dtype | None = None,
|
|
181
186
|
) -> Precomputed:
|
|
182
187
|
PerceptualLinearPredictiveCoefficientsAnalysis._check(
|
|
183
188
|
plp_order, n_channel, compression_factor, lifter
|
|
184
189
|
)
|
|
185
|
-
module = inspect.stack()[1].function
|
|
190
|
+
module = inspect.stack()[1].function != "_func"
|
|
186
191
|
|
|
187
192
|
if out_format in (0, "y"):
|
|
188
193
|
formatter = lambda y, c, E: y
|
|
@@ -208,6 +213,7 @@ class PerceptualLinearPredictiveCoefficientsAnalysis(BaseFunctionalModule):
|
|
|
208
213
|
gamma=gamma,
|
|
209
214
|
use_power=True,
|
|
210
215
|
out_format="y,E",
|
|
216
|
+
learnable=learnable,
|
|
211
217
|
),
|
|
212
218
|
)
|
|
213
219
|
levdur = get_layer(
|