diffsptk 3.0.1__tar.gz → 3.0.2__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.0.1 → diffsptk-3.0.2}/PKG-INFO +4 -4
- {diffsptk-3.0.1 → diffsptk-3.0.2}/README.md +2 -2
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/dfs.py +1 -1
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/drc.py +1 -1
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/imdct.py +43 -10
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/imdst.py +14 -4
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/mdct.py +48 -9
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/mdst.py +14 -4
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/window.py +10 -2
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/utils/private.py +7 -1
- diffsptk-3.0.2/diffsptk/version.py +1 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/pyproject.toml +1 -1
- diffsptk-3.0.1/diffsptk/version.py +0 -1
- {diffsptk-3.0.1 → diffsptk-3.0.2}/.gitignore +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/CITATION.cff +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/LICENSE +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/__init__.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/functional.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/__init__.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/acorr.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/acr2csm.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/alaw.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/ap.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/b2mc.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/base.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/c2acr.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/c2mpir.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/c2ndps.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/cdist.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/chroma.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/cqt.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/csm2acr.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/dct.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/decimate.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/delay.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/delta.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/dequantize.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/df2.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/dht.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/dst.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/entropy.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/excite.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/fbank.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/fftcep.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/flux.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/frame.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/freqt.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/freqt2.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/gammatone.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/gmm.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/gnorm.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/grpdelay.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/hilbert.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/hilbert2.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/histogram.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/ialaw.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/ica.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/icqt.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/idct.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/idht.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/idst.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/ifreqt2.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/igammatone.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/ignorm.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/imglsadf.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/imsvq.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/interpolate.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/ipnorm.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/ipqmf.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/is2par.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/istft.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/iulaw.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/ivq.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/lar2par.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/lbg.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/levdur.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/linear_intpl.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/lpc.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/lpc2lsp.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/lpc2par.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/lpccheck.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/lsp2lpc.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/lsp2sp.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/lspcheck.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/magic_intpl.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/mc2b.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/mcep.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/mcpf.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/mfcc.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/mgc2mgc.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/mgc2sp.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/mgcep.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/mglsadf.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/mlpg.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/mlsacheck.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/mpir2c.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/msvq.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/ndps2c.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/nmf.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/norm0.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/par2is.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/par2lar.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/par2lpc.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/pca.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/phase.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/pitch.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/pitch_spec.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/plp.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/pnorm.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/pol_root.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/poledf.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/pqmf.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/quantize.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/rlevdur.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/rmse.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/root_pol.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/smcep.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/snr.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/spec.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/stft.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/ulaw.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/unframe.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/vq.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/wht.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/yingram.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/zcross.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/modules/zerodf.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/signals.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/third_party/librosa/LICENSE +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/third_party/librosa/__init__.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/third_party/librosa/constantq.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/third_party/librosa/filters.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/third_party/librosa/util.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/third_party/world/LICENSE +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/third_party/world/__init__.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/third_party/world/common.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/typing.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/utils/__init__.py +0 -0
- {diffsptk-3.0.1 → diffsptk-3.0.2}/diffsptk/utils/public.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: diffsptk
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.2
|
|
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/
|
|
@@ -19,7 +19,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.13
|
|
20
20
|
Requires-Python: >=3.10
|
|
21
21
|
Requires-Dist: numpy>=1.23.0
|
|
22
|
-
Requires-Dist: penn
|
|
22
|
+
Requires-Dist: penn<1.0.0,>=0.0.1
|
|
23
23
|
Requires-Dist: pylstraight>=0.1.0
|
|
24
24
|
Requires-Dist: scipy>=1.12.0
|
|
25
25
|
Requires-Dist: soundfile>=0.10.2
|
|
@@ -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.0.
|
|
50
|
+
[](https://sp-nitech.github.io/diffsptk/3.0.2/)
|
|
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.0.
|
|
68
|
+
- See [this page](https://sp-nitech.github.io/diffsptk/3.0.2/) 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.0.
|
|
5
|
+
[](https://sp-nitech.github.io/diffsptk/3.0.2/)
|
|
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.0.
|
|
23
|
+
- See [this page](https://sp-nitech.github.io/diffsptk/3.0.2/) 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
|
|
@@ -53,7 +53,7 @@ class InfiniteImpulseResponseDigitalFilter(BaseFunctionalModule):
|
|
|
53
53
|
) -> None:
|
|
54
54
|
super().__init__()
|
|
55
55
|
|
|
56
|
-
_, _, tensors = self._precompute(*get_values(locals()
|
|
56
|
+
_, _, tensors = self._precompute(*get_values(locals()))
|
|
57
57
|
if learnable and b is not None:
|
|
58
58
|
self.b = nn.Parameter(tensors[0])
|
|
59
59
|
else:
|
|
@@ -74,7 +74,7 @@ class DynamicRangeCompression(BaseFunctionalModule):
|
|
|
74
74
|
) -> None:
|
|
75
75
|
super().__init__()
|
|
76
76
|
|
|
77
|
-
self.values, _, tensors = self._precompute(*get_values(locals()
|
|
77
|
+
self.values, _, tensors = self._precompute(*get_values(locals()))
|
|
78
78
|
if learnable:
|
|
79
79
|
self.params = nn.Parameter(tensors[0])
|
|
80
80
|
else:
|
|
@@ -20,7 +20,7 @@ from torch import nn
|
|
|
20
20
|
from ..typing import Callable, Precomputed
|
|
21
21
|
from ..utils.private import check_size, get_layer, get_values
|
|
22
22
|
from .base import BaseFunctionalModule
|
|
23
|
-
from .mdct import ModifiedDiscreteTransform
|
|
23
|
+
from .mdct import LEARNABLES, ModifiedDiscreteCosineTransform, ModifiedDiscreteTransform
|
|
24
24
|
from .unframe import Unframe
|
|
25
25
|
from .window import Window
|
|
26
26
|
|
|
@@ -36,12 +36,22 @@ class InverseModifiedDiscreteCosineTransform(BaseFunctionalModule):
|
|
|
36
36
|
window : ['sine', 'vorbis', 'kbd', 'rectangular']
|
|
37
37
|
The window type.
|
|
38
38
|
|
|
39
|
+
learnable : bool or list[str]
|
|
40
|
+
Indicates whether the parameters are learnable. If a boolean, it specifies
|
|
41
|
+
whether all parameters are learnable. If a list, it contains the keys of the
|
|
42
|
+
learnable parameters, which can only be "basis" and "window".
|
|
43
|
+
|
|
39
44
|
"""
|
|
40
45
|
|
|
41
|
-
def __init__(
|
|
46
|
+
def __init__(
|
|
47
|
+
self,
|
|
48
|
+
frame_length: int,
|
|
49
|
+
window: str = "sine",
|
|
50
|
+
learnable: bool | list[str] = False,
|
|
51
|
+
) -> None:
|
|
42
52
|
super().__init__()
|
|
43
53
|
|
|
44
|
-
self.values, layers, _ = self._precompute(*get_values(locals()))
|
|
54
|
+
self.values, layers, _ = self._precompute(*get_values(locals(), full=True))
|
|
45
55
|
self.layers = nn.ModuleList(layers)
|
|
46
56
|
|
|
47
57
|
def forward(self, y: torch.Tensor, out_length: int | None = None) -> torch.Tensor:
|
|
@@ -89,16 +99,25 @@ class InverseModifiedDiscreteCosineTransform(BaseFunctionalModule):
|
|
|
89
99
|
return False
|
|
90
100
|
|
|
91
101
|
@staticmethod
|
|
92
|
-
def _check() -> None:
|
|
93
|
-
|
|
102
|
+
def _check(*args, **kwargs) -> None:
|
|
103
|
+
ModifiedDiscreteCosineTransform._check(*args, **kwargs)
|
|
94
104
|
|
|
95
105
|
@staticmethod
|
|
96
106
|
def _precompute(
|
|
97
|
-
frame_length: int,
|
|
107
|
+
frame_length: int,
|
|
108
|
+
window: str,
|
|
109
|
+
learnable: bool = False,
|
|
110
|
+
transform: str = "cosine",
|
|
111
|
+
module: bool = True,
|
|
98
112
|
) -> Precomputed:
|
|
99
|
-
InverseModifiedDiscreteCosineTransform._check()
|
|
113
|
+
InverseModifiedDiscreteCosineTransform._check(learnable)
|
|
100
114
|
frame_period = frame_length // 2
|
|
101
115
|
|
|
116
|
+
if learnable is True:
|
|
117
|
+
learnable = LEARNABLES
|
|
118
|
+
elif learnable is False:
|
|
119
|
+
learnable = ()
|
|
120
|
+
|
|
102
121
|
imdt = get_layer(
|
|
103
122
|
module,
|
|
104
123
|
InverseModifiedDiscreteTransform,
|
|
@@ -106,6 +125,7 @@ class InverseModifiedDiscreteCosineTransform(BaseFunctionalModule):
|
|
|
106
125
|
length=frame_length,
|
|
107
126
|
window=window,
|
|
108
127
|
transform=transform,
|
|
128
|
+
learnable="basis" in learnable,
|
|
109
129
|
),
|
|
110
130
|
)
|
|
111
131
|
window_ = get_layer(
|
|
@@ -116,6 +136,7 @@ class InverseModifiedDiscreteCosineTransform(BaseFunctionalModule):
|
|
|
116
136
|
out_length=None,
|
|
117
137
|
window=window,
|
|
118
138
|
norm="none",
|
|
139
|
+
learnable="window" in learnable,
|
|
119
140
|
),
|
|
120
141
|
)
|
|
121
142
|
unframe = get_layer(
|
|
@@ -157,15 +178,27 @@ class InverseModifiedDiscreteTransform(BaseFunctionalModule):
|
|
|
157
178
|
transform : ['cosine', 'sine']
|
|
158
179
|
The transform type.
|
|
159
180
|
|
|
181
|
+
learnable : bool
|
|
182
|
+
Whether to make the DCT matrix learnable.
|
|
183
|
+
|
|
160
184
|
"""
|
|
161
185
|
|
|
162
|
-
def __init__(
|
|
186
|
+
def __init__(
|
|
187
|
+
self,
|
|
188
|
+
length: int,
|
|
189
|
+
window: str,
|
|
190
|
+
transform: str = "cosine",
|
|
191
|
+
learnable: bool = False,
|
|
192
|
+
) -> None:
|
|
163
193
|
super().__init__()
|
|
164
194
|
|
|
165
195
|
self.in_dim = length // 2
|
|
166
196
|
|
|
167
197
|
_, _, tensors = self._precompute(*get_values(locals()))
|
|
168
|
-
|
|
198
|
+
if learnable:
|
|
199
|
+
self.W = nn.Parameter(tensors[0])
|
|
200
|
+
else:
|
|
201
|
+
self.register_buffer("W", tensors[0])
|
|
169
202
|
|
|
170
203
|
def forward(self, y: torch.Tensor) -> torch.Tensor:
|
|
171
204
|
"""Apply inverse MDCT/MDST to the input.
|
|
@@ -182,7 +215,7 @@ class InverseModifiedDiscreteTransform(BaseFunctionalModule):
|
|
|
182
215
|
|
|
183
216
|
"""
|
|
184
217
|
check_size(y.size(-1), self.in_dim, "dimension of input")
|
|
185
|
-
return self._forward(y, **self._buffers)
|
|
218
|
+
return self._forward(y, **self._buffers, **self._parameters)
|
|
186
219
|
|
|
187
220
|
@staticmethod
|
|
188
221
|
def _func(y: torch.Tensor, *args, **kwargs) -> torch.Tensor:
|
|
@@ -34,12 +34,22 @@ class InverseModifiedDiscreteSineTransform(BaseFunctionalModule):
|
|
|
34
34
|
window : ['sine', 'vorbis', 'kbd', 'rectangular']
|
|
35
35
|
The window type.
|
|
36
36
|
|
|
37
|
+
learnable : bool or list[str]
|
|
38
|
+
Indicates whether the parameters are learnable. If a boolean, it specifies
|
|
39
|
+
whether all parameters are learnable. If a list, it contains the keys of the
|
|
40
|
+
learnable parameters, which can only be "basis" and "window".
|
|
41
|
+
|
|
37
42
|
"""
|
|
38
43
|
|
|
39
|
-
def __init__(
|
|
44
|
+
def __init__(
|
|
45
|
+
self,
|
|
46
|
+
frame_length: int,
|
|
47
|
+
window: str = "sine",
|
|
48
|
+
learnable: bool | list[str] = False,
|
|
49
|
+
):
|
|
40
50
|
super().__init__()
|
|
41
51
|
|
|
42
|
-
self.values, layers, _ = self._precompute(*get_values(locals()))
|
|
52
|
+
self.values, layers, _ = self._precompute(*get_values(locals(), full=True))
|
|
43
53
|
self.layers = nn.ModuleList(layers)
|
|
44
54
|
|
|
45
55
|
def forward(self, y: torch.Tensor, out_length: int | None = None) -> torch.Tensor:
|
|
@@ -86,8 +96,8 @@ class InverseModifiedDiscreteSineTransform(BaseFunctionalModule):
|
|
|
86
96
|
raise NotImplementedError
|
|
87
97
|
|
|
88
98
|
@staticmethod
|
|
89
|
-
def _precompute(
|
|
90
|
-
return IMDCT._precompute(
|
|
99
|
+
def _precompute(*args, **kwargs) -> Precomputed:
|
|
100
|
+
return IMDCT._precompute(*args, **kwargs, transform="sine")
|
|
91
101
|
|
|
92
102
|
@staticmethod
|
|
93
103
|
def _forward(*args, **kwargs) -> torch.Tensor:
|
|
@@ -24,6 +24,8 @@ from .base import BaseFunctionalModule
|
|
|
24
24
|
from .frame import Frame
|
|
25
25
|
from .window import Window
|
|
26
26
|
|
|
27
|
+
LEARNABLES = ("basis", "window")
|
|
28
|
+
|
|
27
29
|
|
|
28
30
|
class ModifiedDiscreteCosineTransform(BaseFunctionalModule):
|
|
29
31
|
"""This module is a simple cascade of framing, windowing, and modified DCT.
|
|
@@ -36,12 +38,22 @@ class ModifiedDiscreteCosineTransform(BaseFunctionalModule):
|
|
|
36
38
|
window : ['sine', 'vorbis', 'kbd', 'rectangular']
|
|
37
39
|
The window type.
|
|
38
40
|
|
|
41
|
+
learnable : bool or list[str]
|
|
42
|
+
Indicates whether the parameters are learnable. If a boolean, it specifies
|
|
43
|
+
whether all parameters are learnable. If a list, it contains the keys of the
|
|
44
|
+
learnable parameters, which can only be "basis" and "window".
|
|
45
|
+
|
|
39
46
|
"""
|
|
40
47
|
|
|
41
|
-
def __init__(
|
|
48
|
+
def __init__(
|
|
49
|
+
self,
|
|
50
|
+
frame_length: int,
|
|
51
|
+
window: str = "sine",
|
|
52
|
+
learnable: bool | list[str] = False,
|
|
53
|
+
) -> None:
|
|
42
54
|
super().__init__()
|
|
43
55
|
|
|
44
|
-
self.values, layers, _ = self._precompute(*get_values(locals()))
|
|
56
|
+
self.values, layers, _ = self._precompute(*get_values(locals(), full=True))
|
|
45
57
|
self.layers = nn.ModuleList(layers)
|
|
46
58
|
|
|
47
59
|
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
@@ -84,16 +96,29 @@ class ModifiedDiscreteCosineTransform(BaseFunctionalModule):
|
|
|
84
96
|
return False
|
|
85
97
|
|
|
86
98
|
@staticmethod
|
|
87
|
-
def _check() -> None:
|
|
88
|
-
|
|
99
|
+
def _check(learnable: bool | list[str]) -> None:
|
|
100
|
+
if isinstance(learnable, (tuple, list)):
|
|
101
|
+
if any(x not in LEARNABLES for x in learnable):
|
|
102
|
+
raise ValueError("An unsupported key is found in learnable.")
|
|
103
|
+
elif not isinstance(learnable, bool):
|
|
104
|
+
raise ValueError("learnable must be boolean or list.")
|
|
89
105
|
|
|
90
106
|
@staticmethod
|
|
91
107
|
def _precompute(
|
|
92
|
-
frame_length: int,
|
|
108
|
+
frame_length: int,
|
|
109
|
+
window: str,
|
|
110
|
+
learnable: bool | list[str] = False,
|
|
111
|
+
transform: str = "cosine",
|
|
112
|
+
module: bool = True,
|
|
93
113
|
) -> Precomputed:
|
|
94
|
-
ModifiedDiscreteCosineTransform._check()
|
|
114
|
+
ModifiedDiscreteCosineTransform._check(learnable)
|
|
95
115
|
frame_period = frame_length // 2
|
|
96
116
|
|
|
117
|
+
if learnable is True:
|
|
118
|
+
learnable = LEARNABLES
|
|
119
|
+
elif learnable is False:
|
|
120
|
+
learnable = ()
|
|
121
|
+
|
|
97
122
|
frame = get_layer(
|
|
98
123
|
module,
|
|
99
124
|
Frame,
|
|
@@ -110,6 +135,7 @@ class ModifiedDiscreteCosineTransform(BaseFunctionalModule):
|
|
|
110
135
|
out_length=None,
|
|
111
136
|
window=window,
|
|
112
137
|
norm="none",
|
|
138
|
+
learnable="window" in learnable,
|
|
113
139
|
),
|
|
114
140
|
)
|
|
115
141
|
mdt = get_layer(
|
|
@@ -119,6 +145,7 @@ class ModifiedDiscreteCosineTransform(BaseFunctionalModule):
|
|
|
119
145
|
length=frame_length,
|
|
120
146
|
window=window,
|
|
121
147
|
transform=transform,
|
|
148
|
+
learnable="basis" in learnable,
|
|
122
149
|
),
|
|
123
150
|
)
|
|
124
151
|
return (frame_period,), (frame, window_, mdt), None
|
|
@@ -150,15 +177,27 @@ class ModifiedDiscreteTransform(BaseFunctionalModule):
|
|
|
150
177
|
transform : ['cosine', 'sine']
|
|
151
178
|
The transform type.
|
|
152
179
|
|
|
180
|
+
learnable : bool
|
|
181
|
+
Whether to make the DCT matrix learnable.
|
|
182
|
+
|
|
153
183
|
"""
|
|
154
184
|
|
|
155
|
-
def __init__(
|
|
185
|
+
def __init__(
|
|
186
|
+
self,
|
|
187
|
+
length: int,
|
|
188
|
+
window: str,
|
|
189
|
+
transform: str = "cosine",
|
|
190
|
+
learnable: bool = False,
|
|
191
|
+
) -> None:
|
|
156
192
|
super().__init__()
|
|
157
193
|
|
|
158
194
|
self.in_dim = length
|
|
159
195
|
|
|
160
196
|
_, _, tensors = self._precompute(*get_values(locals()))
|
|
161
|
-
|
|
197
|
+
if learnable:
|
|
198
|
+
self.W = nn.Parameter(tensors[0])
|
|
199
|
+
else:
|
|
200
|
+
self.register_buffer("W", tensors[0])
|
|
162
201
|
|
|
163
202
|
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
164
203
|
"""Apply MDCT/MDST to the input.
|
|
@@ -175,7 +214,7 @@ class ModifiedDiscreteTransform(BaseFunctionalModule):
|
|
|
175
214
|
|
|
176
215
|
"""
|
|
177
216
|
check_size(x.size(-1), self.in_dim, "dimension of input")
|
|
178
|
-
return self._forward(x, **self._buffers)
|
|
217
|
+
return self._forward(x, **self._buffers, **self._parameters)
|
|
179
218
|
|
|
180
219
|
@staticmethod
|
|
181
220
|
def _func(x: torch.Tensor, *args, **kwargs) -> torch.Tensor:
|
|
@@ -34,12 +34,22 @@ class ModifiedDiscreteSineTransform(BaseFunctionalModule):
|
|
|
34
34
|
window : ['sine', 'vorbis', 'kbd', 'rectangular']
|
|
35
35
|
The window type.
|
|
36
36
|
|
|
37
|
+
learnable : bool or list[str]
|
|
38
|
+
Indicates whether the parameters are learnable. If a boolean, it specifies
|
|
39
|
+
whether all parameters are learnable. If a list, it contains the keys of the
|
|
40
|
+
learnable parameters, which can only be "basis" and "window".
|
|
41
|
+
|
|
37
42
|
"""
|
|
38
43
|
|
|
39
|
-
def __init__(
|
|
44
|
+
def __init__(
|
|
45
|
+
self,
|
|
46
|
+
frame_length: int,
|
|
47
|
+
window: str = "sine",
|
|
48
|
+
learnable: bool | list[str] = False,
|
|
49
|
+
) -> None:
|
|
40
50
|
super().__init__()
|
|
41
51
|
|
|
42
|
-
self.values, layers, _ = self._precompute(*get_values(locals()))
|
|
52
|
+
self.values, layers, _ = self._precompute(*get_values(locals(), full=True))
|
|
43
53
|
self.layers = nn.ModuleList(layers)
|
|
44
54
|
|
|
45
55
|
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
@@ -83,8 +93,8 @@ class ModifiedDiscreteSineTransform(BaseFunctionalModule):
|
|
|
83
93
|
raise NotImplementedError
|
|
84
94
|
|
|
85
95
|
@staticmethod
|
|
86
|
-
def _precompute(
|
|
87
|
-
return MDCT._precompute(
|
|
96
|
+
def _precompute(*args, **kwargs) -> Precomputed:
|
|
97
|
+
return MDCT._precompute(*args, **kwargs, transform="sine")
|
|
88
98
|
|
|
89
99
|
@staticmethod
|
|
90
100
|
def _forward(*args, **kwargs) -> torch.Tensor:
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import torch
|
|
18
18
|
import torch.nn.functional as F
|
|
19
|
+
from torch import nn
|
|
19
20
|
|
|
20
21
|
from ..typing import Precomputed
|
|
21
22
|
from ..utils.private import check_size, get_values, to
|
|
@@ -42,6 +43,9 @@ class Window(BaseFunctionalModule):
|
|
|
42
43
|
norm : ['none', 'power', 'magnitude']
|
|
43
44
|
The normalization type of the window.
|
|
44
45
|
|
|
46
|
+
learnable : bool
|
|
47
|
+
Whether to make the window learnable.
|
|
48
|
+
|
|
45
49
|
"""
|
|
46
50
|
|
|
47
51
|
def __init__(
|
|
@@ -51,13 +55,17 @@ class Window(BaseFunctionalModule):
|
|
|
51
55
|
*,
|
|
52
56
|
window: str | int = "blackman",
|
|
53
57
|
norm: str | int = "power",
|
|
58
|
+
learnable: bool = False,
|
|
54
59
|
) -> None:
|
|
55
60
|
super().__init__()
|
|
56
61
|
|
|
57
62
|
self.in_dim = in_length
|
|
58
63
|
|
|
59
64
|
self.values, _, tensors = self._precompute(*get_values(locals()))
|
|
60
|
-
|
|
65
|
+
if learnable:
|
|
66
|
+
self.window = nn.Parameter(tensors[0])
|
|
67
|
+
else:
|
|
68
|
+
self.register_buffer("window", tensors[0])
|
|
61
69
|
|
|
62
70
|
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
63
71
|
"""Apply a window function to the given waveform.
|
|
@@ -82,7 +90,7 @@ class Window(BaseFunctionalModule):
|
|
|
82
90
|
|
|
83
91
|
"""
|
|
84
92
|
check_size(x.size(-1), self.in_dim, "input length")
|
|
85
|
-
return self._forward(x, *self.values, **self._buffers)
|
|
93
|
+
return self._forward(x, *self.values, **self._buffers, **self._parameters)
|
|
86
94
|
|
|
87
95
|
@staticmethod
|
|
88
96
|
def _func(x: torch.Tensor, *args, **kwargs) -> torch.Tensor:
|
|
@@ -49,6 +49,8 @@ def get_layer(
|
|
|
49
49
|
|
|
50
50
|
if module._takes_input_size():
|
|
51
51
|
params = dict(islice(params.items(), 1, None))
|
|
52
|
+
if "learnable" in params:
|
|
53
|
+
params.pop("learnable")
|
|
52
54
|
|
|
53
55
|
def layer(*args, **kwargs):
|
|
54
56
|
return module._func(*args, **params, **kwargs)
|
|
@@ -56,7 +58,11 @@ def get_layer(
|
|
|
56
58
|
return layer
|
|
57
59
|
|
|
58
60
|
|
|
59
|
-
def get_values(
|
|
61
|
+
def get_values(
|
|
62
|
+
dictionary: dict[str, Any], begin: int = 1, end: int = -1, full: bool = False
|
|
63
|
+
) -> list[Any]:
|
|
64
|
+
if not full and "learnable" in dictionary:
|
|
65
|
+
dictionary.pop("learnable")
|
|
60
66
|
return list(dictionary.values())[begin:end]
|
|
61
67
|
|
|
62
68
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "3.0.2"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "3.0.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|