diffsptk 2.2.0__tar.gz → 2.4.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-2.2.0 → diffsptk-2.4.0}/.gitignore +0 -3
- {diffsptk-2.2.0 → diffsptk-2.4.0}/PKG-INFO +31 -6
- {diffsptk-2.2.0 → diffsptk-2.4.0}/README.md +27 -3
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/functional.py +204 -24
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/misc/signals.py +5 -2
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/misc/utils.py +81 -9
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/__init__.py +21 -4
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/acr2csm.py +7 -2
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/ap.py +7 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/b2mc.py +7 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/c2mpir.py +1 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/c2ndps.py +5 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/cdist.py +10 -9
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/cqt.py +9 -2
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/csm2acr.py +5 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/dct.py +32 -7
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/decimate.py +0 -3
- diffsptk-2.4.0/diffsptk/modules/dht.py +95 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/drc.py +2 -2
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/dst.py +30 -8
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/excite.py +92 -20
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/fbank.py +4 -3
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/fftcep.py +6 -1
- diffsptk-2.4.0/diffsptk/modules/flux.py +106 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/freqt.py +5 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/freqt2.py +7 -1
- diffsptk-2.4.0/diffsptk/modules/gammatone.py +225 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/gmm.py +145 -88
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/gnorm.py +6 -0
- diffsptk-2.4.0/diffsptk/modules/hilbert.py +96 -0
- diffsptk-2.4.0/diffsptk/modules/hilbert2.py +105 -0
- diffsptk-2.4.0/diffsptk/modules/ica.py +180 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/icqt.py +10 -2
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/idct.py +13 -6
- diffsptk-2.4.0/diffsptk/modules/idht.py +88 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/idst.py +13 -6
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/ifreqt2.py +7 -1
- diffsptk-2.4.0/diffsptk/modules/igammatone.py +203 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/ignorm.py +6 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/imglsadf.py +5 -2
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/imsvq.py +5 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/ipqmf.py +11 -2
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/ivq.py +5 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/lbg.py +92 -47
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/lpc2lsp.py +7 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/lsp2sp.py +8 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/lspcheck.py +2 -2
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/mc2b.py +6 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/mcpf.py +6 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/mgc2mgc.py +6 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/mglsadf.py +222 -76
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/mlpg.py +3 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/mlsacheck.py +7 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/msvq.py +5 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/ndps2c.py +5 -0
- diffsptk-2.4.0/diffsptk/modules/nmf.py +245 -0
- diffsptk-2.4.0/diffsptk/modules/pca.py +211 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/phase.py +1 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/poledf.py +1 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/pqmf.py +11 -2
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/rmse.py +7 -11
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/smcep.py +6 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/spec.py +1 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/vq.py +5 -0
- diffsptk-2.4.0/diffsptk/modules/wht.py +115 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/zcross.py +1 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/zerodf.py +2 -2
- diffsptk-2.4.0/diffsptk/version.py +1 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/pyproject.toml +13 -11
- diffsptk-2.2.0/diffsptk/modules/pca.py +0 -130
- diffsptk-2.2.0/diffsptk/version.py +0 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/CITATION.cff +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/LICENSE +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/__init__.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/misc/__init__.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/acorr.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/alaw.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/c2acr.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/chroma.py +1 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/delay.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/delta.py +1 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/dequantize.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/df2.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/dfs.py +1 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/entropy.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/frame.py +1 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/grpdelay.py +1 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/histogram.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/ialaw.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/imdct.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/imdst.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/interpolate.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/ipnorm.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/istft.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/iulaw.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/lar2par.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/levdur.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/linear_intpl.py +1 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/lpc.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/lpc2par.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/lpccheck.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/lsp2lpc.py +1 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/magic_intpl.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/mcep.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/mdct.py +1 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/mdst.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/mfcc.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/mgc2sp.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/mgcep.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/mpir2c.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/norm0.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/par2lar.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/par2lpc.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/pitch.py +1 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/plp.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/pnorm.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/pol_root.py +1 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/quantize.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/rlevdur.py +1 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/root_pol.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/snr.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/stft.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/ulaw.py +0 -0
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/unframe.py +1 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/window.py +1 -1
- {diffsptk-2.2.0 → diffsptk-2.4.0}/diffsptk/modules/yingram.py +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: diffsptk
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.4.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/
|
|
@@ -25,16 +25,17 @@ Requires-Dist: soundfile>=0.10.2
|
|
|
25
25
|
Requires-Dist: torch>=2.0.0
|
|
26
26
|
Requires-Dist: torchaudio>=2.0.1
|
|
27
27
|
Requires-Dist: torchcomp>=0.1.0
|
|
28
|
-
Requires-Dist: torchcrepe>=0.0.
|
|
28
|
+
Requires-Dist: torchcrepe>=0.0.22
|
|
29
29
|
Requires-Dist: torchlpc>=0.2.0
|
|
30
30
|
Requires-Dist: tqdm>=4.15.0
|
|
31
31
|
Requires-Dist: vector-quantize-pytorch>=1.14.9
|
|
32
32
|
Provides-Extra: dev
|
|
33
33
|
Requires-Dist: build; extra == 'dev'
|
|
34
|
+
Requires-Dist: codespell; extra == 'dev'
|
|
34
35
|
Requires-Dist: docstrfmt; extra == 'dev'
|
|
35
|
-
Requires-Dist: isort; extra == 'dev'
|
|
36
36
|
Requires-Dist: mdformat; extra == 'dev'
|
|
37
37
|
Requires-Dist: numpydoc; extra == 'dev'
|
|
38
|
+
Requires-Dist: pkginfo; extra == 'dev'
|
|
38
39
|
Requires-Dist: pydata-sphinx-theme; extra == 'dev'
|
|
39
40
|
Requires-Dist: pytest; extra == 'dev'
|
|
40
41
|
Requires-Dist: pytest-cov; extra == 'dev'
|
|
@@ -48,10 +49,10 @@ Description-Content-Type: text/markdown
|
|
|
48
49
|
*diffsptk* is a differentiable version of [SPTK](https://github.com/sp-nitech/SPTK) based on the PyTorch framework.
|
|
49
50
|
|
|
50
51
|
[](https://sp-nitech.github.io/diffsptk/latest/)
|
|
51
|
-
[](https://sp-nitech.github.io/diffsptk/2.
|
|
52
|
+
[](https://sp-nitech.github.io/diffsptk/2.4.0/)
|
|
52
53
|
[](https://pepy.tech/project/diffsptk)
|
|
53
54
|
[](https://pypi.python.org/pypi/diffsptk)
|
|
54
|
-
[](https://pypi.python.org/pypi/diffsptk)
|
|
55
56
|
[](https://pypi.python.org/pypi/diffsptk)
|
|
56
57
|
[](https://app.codecov.io/gh/sp-nitech/diffsptk)
|
|
57
58
|
[](https://github.com/sp-nitech/diffsptk/blob/master/LICENSE)
|
|
@@ -65,7 +66,7 @@ Description-Content-Type: text/markdown
|
|
|
65
66
|
|
|
66
67
|
## Documentation
|
|
67
68
|
|
|
68
|
-
- See [this page](https://sp-nitech.github.io/diffsptk/latest/) for
|
|
69
|
+
- See [this page](https://sp-nitech.github.io/diffsptk/latest/) for the reference manual.
|
|
69
70
|
- Our [paper](https://www.isca-speech.org/archive/ssw_2023/yoshimura23_ssw.html) is available on the ISCA Archive.
|
|
70
71
|
|
|
71
72
|
## Installation
|
|
@@ -247,6 +248,30 @@ error = (x_hat - x).abs().sum()
|
|
|
247
248
|
print(error)
|
|
248
249
|
```
|
|
249
250
|
|
|
251
|
+
### Gammatone filter bank analysis and synthesis
|
|
252
|
+
|
|
253
|
+
```python
|
|
254
|
+
import diffsptk
|
|
255
|
+
|
|
256
|
+
# Read waveform.
|
|
257
|
+
x, sr = diffsptk.read("assets/data.wav")
|
|
258
|
+
|
|
259
|
+
# Decompose x.
|
|
260
|
+
gammatone = diffsptk.GammatoneFilterBankAnalysis(sr)
|
|
261
|
+
y = gammatone(x)
|
|
262
|
+
|
|
263
|
+
# Reconstruct x.
|
|
264
|
+
igammatone = diffsptk.GammatoneFilterBankSynthesis(sr)
|
|
265
|
+
x_hat = igammatone(y).reshape(-1)
|
|
266
|
+
|
|
267
|
+
# Write reconstructed waveform.
|
|
268
|
+
diffsptk.write("reconst.wav", x_hat, sr)
|
|
269
|
+
|
|
270
|
+
# Compute error.
|
|
271
|
+
error = (x_hat - x).abs().sum()
|
|
272
|
+
print(error)
|
|
273
|
+
```
|
|
274
|
+
|
|
250
275
|
### Constant-Q transform
|
|
251
276
|
|
|
252
277
|
```python
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*diffsptk* is a differentiable version of [SPTK](https://github.com/sp-nitech/SPTK) based on the PyTorch framework.
|
|
4
4
|
|
|
5
5
|
[](https://sp-nitech.github.io/diffsptk/latest/)
|
|
6
|
-
[](https://sp-nitech.github.io/diffsptk/2.
|
|
6
|
+
[](https://sp-nitech.github.io/diffsptk/2.4.0/)
|
|
7
7
|
[](https://pepy.tech/project/diffsptk)
|
|
8
8
|
[](https://pypi.python.org/pypi/diffsptk)
|
|
9
|
-
[](https://pypi.python.org/pypi/diffsptk)
|
|
10
10
|
[](https://pypi.python.org/pypi/diffsptk)
|
|
11
11
|
[](https://app.codecov.io/gh/sp-nitech/diffsptk)
|
|
12
12
|
[](https://github.com/sp-nitech/diffsptk/blob/master/LICENSE)
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
## Documentation
|
|
22
22
|
|
|
23
|
-
- See [this page](https://sp-nitech.github.io/diffsptk/latest/) for
|
|
23
|
+
- See [this page](https://sp-nitech.github.io/diffsptk/latest/) 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
|
|
@@ -202,6 +202,30 @@ error = (x_hat - x).abs().sum()
|
|
|
202
202
|
print(error)
|
|
203
203
|
```
|
|
204
204
|
|
|
205
|
+
### Gammatone filter bank analysis and synthesis
|
|
206
|
+
|
|
207
|
+
```python
|
|
208
|
+
import diffsptk
|
|
209
|
+
|
|
210
|
+
# Read waveform.
|
|
211
|
+
x, sr = diffsptk.read("assets/data.wav")
|
|
212
|
+
|
|
213
|
+
# Decompose x.
|
|
214
|
+
gammatone = diffsptk.GammatoneFilterBankAnalysis(sr)
|
|
215
|
+
y = gammatone(x)
|
|
216
|
+
|
|
217
|
+
# Reconstruct x.
|
|
218
|
+
igammatone = diffsptk.GammatoneFilterBankSynthesis(sr)
|
|
219
|
+
x_hat = igammatone(y).reshape(-1)
|
|
220
|
+
|
|
221
|
+
# Write reconstructed waveform.
|
|
222
|
+
diffsptk.write("reconst.wav", x_hat, sr)
|
|
223
|
+
|
|
224
|
+
# Compute error.
|
|
225
|
+
error = (x_hat - x).abs().sum()
|
|
226
|
+
print(error)
|
|
227
|
+
```
|
|
228
|
+
|
|
205
229
|
### Constant-Q transform
|
|
206
230
|
|
|
207
231
|
```python
|
|
@@ -175,7 +175,7 @@ def c2ndps(c, fft_length):
|
|
|
175
175
|
)
|
|
176
176
|
|
|
177
177
|
|
|
178
|
-
def cdist(c1, c2, full=False, reduction="mean"
|
|
178
|
+
def cdist(c1, c2, full=False, reduction="mean"):
|
|
179
179
|
"""Calculate cepstral distance between two inputs.
|
|
180
180
|
|
|
181
181
|
Parameters
|
|
@@ -192,16 +192,13 @@ def cdist(c1, c2, full=False, reduction="mean", eps=1e-8):
|
|
|
192
192
|
reduction : ['none', 'mean', 'batchmean', 'sum']
|
|
193
193
|
Reduction type.
|
|
194
194
|
|
|
195
|
-
eps : float >= 0
|
|
196
|
-
A small value to prevent NaN.
|
|
197
|
-
|
|
198
195
|
Returns
|
|
199
196
|
-------
|
|
200
197
|
out : Tensor [shape=(...,) or scalar]
|
|
201
198
|
Cepstral distance.
|
|
202
199
|
|
|
203
200
|
"""
|
|
204
|
-
return nn.CepstralDistance._func(c1, c2, full=full, reduction=reduction
|
|
201
|
+
return nn.CepstralDistance._func(c1, c2, full=full, reduction=reduction)
|
|
205
202
|
|
|
206
203
|
|
|
207
204
|
def chroma(x, n_channel, sample_rate, norm=float("inf")):
|
|
@@ -253,7 +250,7 @@ def csm2acr(c):
|
|
|
253
250
|
return nn.CompositeSinusoidalModelCoefficientsToAutocorrelation._func(c)
|
|
254
251
|
|
|
255
252
|
|
|
256
|
-
def dct(x):
|
|
253
|
+
def dct(x, dct_type=2):
|
|
257
254
|
"""Compute DCT.
|
|
258
255
|
|
|
259
256
|
Parameters
|
|
@@ -261,13 +258,16 @@ def dct(x):
|
|
|
261
258
|
x : Tensor [shape=(..., L)]
|
|
262
259
|
Input signal.
|
|
263
260
|
|
|
261
|
+
dct_type : int in [1, 4]
|
|
262
|
+
DCT type.
|
|
263
|
+
|
|
264
264
|
Returns
|
|
265
265
|
-------
|
|
266
266
|
out : Tensor [shape=(..., L)]
|
|
267
267
|
DCT output.
|
|
268
268
|
|
|
269
269
|
"""
|
|
270
|
-
return nn.DiscreteCosineTransform._func(x)
|
|
270
|
+
return nn.DiscreteCosineTransform._func(x, dct_type=dct_type)
|
|
271
271
|
|
|
272
272
|
|
|
273
273
|
def decimate(x, period=1, start=0, dim=-1):
|
|
@@ -396,6 +396,26 @@ def dfs(x, b=None, a=None):
|
|
|
396
396
|
return nn.InfiniteImpulseResponseDigitalFilter._func(x, b=b, a=a)
|
|
397
397
|
|
|
398
398
|
|
|
399
|
+
def dht(x, dht_type=2):
|
|
400
|
+
"""Compute DHT.
|
|
401
|
+
|
|
402
|
+
Parameters
|
|
403
|
+
----------
|
|
404
|
+
x : Tensor [shape=(..., L)]
|
|
405
|
+
Input signal.
|
|
406
|
+
|
|
407
|
+
dht_type : int in [1, 4]
|
|
408
|
+
DHT type.
|
|
409
|
+
|
|
410
|
+
Returns
|
|
411
|
+
-------
|
|
412
|
+
out : Tensor [shape=(..., L)]
|
|
413
|
+
DHT output.
|
|
414
|
+
|
|
415
|
+
"""
|
|
416
|
+
return nn.DiscreteHartleyTransform._func(x, dht_type=dht_type)
|
|
417
|
+
|
|
418
|
+
|
|
399
419
|
def drc(
|
|
400
420
|
x,
|
|
401
421
|
threshold,
|
|
@@ -452,7 +472,7 @@ def drc(
|
|
|
452
472
|
)
|
|
453
473
|
|
|
454
474
|
|
|
455
|
-
def dst(x):
|
|
475
|
+
def dst(x, dst_type=2):
|
|
456
476
|
"""Compute DST.
|
|
457
477
|
|
|
458
478
|
Parameters
|
|
@@ -460,13 +480,16 @@ def dst(x):
|
|
|
460
480
|
x : Tensor [shape=(..., L)]
|
|
461
481
|
Input signal.
|
|
462
482
|
|
|
483
|
+
dst_type : int in [1, 4]
|
|
484
|
+
DST type.
|
|
485
|
+
|
|
463
486
|
Returns
|
|
464
487
|
-------
|
|
465
488
|
out : Tensor [shape=(..., L)]
|
|
466
489
|
DST output.
|
|
467
490
|
|
|
468
491
|
"""
|
|
469
|
-
return nn.DiscreteSineTransform._func(x)
|
|
492
|
+
return nn.DiscreteSineTransform._func(x, dst_type=dst_type)
|
|
470
493
|
|
|
471
494
|
|
|
472
495
|
def entropy(p, out_format="nat"):
|
|
@@ -489,7 +512,15 @@ def entropy(p, out_format="nat"):
|
|
|
489
512
|
return nn.Entropy._func(p, out_format=out_format)
|
|
490
513
|
|
|
491
514
|
|
|
492
|
-
def excite(
|
|
515
|
+
def excite(
|
|
516
|
+
p,
|
|
517
|
+
frame_period=80,
|
|
518
|
+
*,
|
|
519
|
+
voiced_region="pulse",
|
|
520
|
+
unvoiced_region="gauss",
|
|
521
|
+
polarity="auto",
|
|
522
|
+
init_phase="zeros",
|
|
523
|
+
):
|
|
493
524
|
"""Generate a simple excitation signal.
|
|
494
525
|
|
|
495
526
|
Parameters
|
|
@@ -500,12 +531,19 @@ def excite(p, frame_period=80, voiced_region="pulse", unvoiced_region="gauss"):
|
|
|
500
531
|
frame_period : int >= 1
|
|
501
532
|
Frame period in samples, :math:`P`.
|
|
502
533
|
|
|
503
|
-
voiced_region : ['pulse', 'sinusoidal', 'sawtooth'
|
|
534
|
+
voiced_region : ['pulse', 'sinusoidal', 'sawtooth', 'inverted-sawtooth', \
|
|
535
|
+
'triangle', 'square']
|
|
504
536
|
Value on voiced region.
|
|
505
537
|
|
|
506
538
|
unvoiced_region : ['gauss', 'zeros']
|
|
507
539
|
Value on unvoiced region.
|
|
508
540
|
|
|
541
|
+
polarity : ['auto', 'unipolar', 'bipolar']
|
|
542
|
+
Polarity.
|
|
543
|
+
|
|
544
|
+
init_phase : ['zeros', 'random']
|
|
545
|
+
Initial phase.
|
|
546
|
+
|
|
509
547
|
Returns
|
|
510
548
|
-------
|
|
511
549
|
out : Tensor [shape=(..., NxP)]
|
|
@@ -517,6 +555,8 @@ def excite(p, frame_period=80, voiced_region="pulse", unvoiced_region="gauss"):
|
|
|
517
555
|
frame_period=frame_period,
|
|
518
556
|
voiced_region=voiced_region,
|
|
519
557
|
unvoiced_region=unvoiced_region,
|
|
558
|
+
polarity=polarity,
|
|
559
|
+
init_phase=init_phase,
|
|
520
560
|
)
|
|
521
561
|
|
|
522
562
|
|
|
@@ -544,7 +584,7 @@ def fbank(x, n_channel, sample_rate, f_min=0, f_max=None, floor=1e-5, out_format
|
|
|
544
584
|
Minimum mel-filter bank output in linear scale.
|
|
545
585
|
|
|
546
586
|
out_format : ['y', 'yE', 'y,E']
|
|
547
|
-
`y` is mel-filber bank
|
|
587
|
+
`y` is mel-filber bank output and `E` is energy. If this is `yE`, the two output
|
|
548
588
|
tensors are concatenated and return the tensor instead of the tuple.
|
|
549
589
|
|
|
550
590
|
Returns
|
|
@@ -594,6 +634,35 @@ def fftcep(x, cep_order, n_iter=0, accel=0):
|
|
|
594
634
|
return nn.CepstralAnalysis._func(x, cep_order=cep_order, n_iter=n_iter, accel=accel)
|
|
595
635
|
|
|
596
636
|
|
|
637
|
+
def flux(x, y=None, lag=1, norm=2, reduction="mean"):
|
|
638
|
+
"""Calculate flux.
|
|
639
|
+
|
|
640
|
+
Parameters
|
|
641
|
+
----------
|
|
642
|
+
x : Tensor [shape=(..., N, D)]
|
|
643
|
+
Input.
|
|
644
|
+
|
|
645
|
+
y : Tensor [shape=(..., N, D)] or None
|
|
646
|
+
Target (optional).
|
|
647
|
+
|
|
648
|
+
lag : int
|
|
649
|
+
Lag of the distance calculation, :math:`L`.
|
|
650
|
+
|
|
651
|
+
norm : int or float
|
|
652
|
+
Order of norm.
|
|
653
|
+
|
|
654
|
+
reduction : ['none', 'mean', 'batchmean', 'sum']
|
|
655
|
+
Reduction type.
|
|
656
|
+
|
|
657
|
+
Returns
|
|
658
|
+
-------
|
|
659
|
+
out : Tensor [shape=(..., N-\\|L\\|) or scalar]
|
|
660
|
+
Flux.
|
|
661
|
+
|
|
662
|
+
"""
|
|
663
|
+
return nn.Flux._func(x, y, lag=lag, norm=norm, reduction=reduction)
|
|
664
|
+
|
|
665
|
+
|
|
597
666
|
def frame(x, frame_length=400, frame_period=80, center=True, zmean=False):
|
|
598
667
|
"""Perform framing.
|
|
599
668
|
|
|
@@ -642,7 +711,7 @@ def freqt(c, out_order, alpha=0):
|
|
|
642
711
|
Order of output cepstrum, :math:`M_2`.
|
|
643
712
|
|
|
644
713
|
alpha : float in (-1, 1)
|
|
645
|
-
|
|
714
|
+
Frequency warping factor, :math:`\\alpha`.
|
|
646
715
|
|
|
647
716
|
Returns
|
|
648
717
|
-------
|
|
@@ -738,6 +807,54 @@ def grpdelay(b=None, a=None, *, fft_length=512, alpha=1, gamma=1, **kwargs):
|
|
|
738
807
|
)
|
|
739
808
|
|
|
740
809
|
|
|
810
|
+
def hilbert(x, fft_length=None, dim=-1):
|
|
811
|
+
"""Compute analytic signal using the Hilbert transform.
|
|
812
|
+
|
|
813
|
+
Parameters
|
|
814
|
+
----------
|
|
815
|
+
x : Tensor [shape=(..., T, ...)]
|
|
816
|
+
Input signal.
|
|
817
|
+
|
|
818
|
+
fft_length : int >= 1 or None
|
|
819
|
+
Number of FFT bins. If None, set to :math:`T`.
|
|
820
|
+
|
|
821
|
+
dim : int
|
|
822
|
+
Dimension along which to take the Hilbert transform.
|
|
823
|
+
|
|
824
|
+
Returns
|
|
825
|
+
-------
|
|
826
|
+
out : Tensor [shape=(..., T, ...)]
|
|
827
|
+
Analytic signal, where real part is the input signal and imaginary part is
|
|
828
|
+
the Hilbert transform of the input signal.
|
|
829
|
+
|
|
830
|
+
"""
|
|
831
|
+
return nn.HilbertTransform._func(x, fft_length=fft_length, dim=dim)
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
def hilbert2(x, fft_length=None, dim=(-2, -1)):
|
|
835
|
+
"""Compute analytic signal using the Hilbert transform.
|
|
836
|
+
|
|
837
|
+
Parameters
|
|
838
|
+
----------
|
|
839
|
+
x : Tensor [shape=(..., T1, T2, ...)]
|
|
840
|
+
Input signal.
|
|
841
|
+
|
|
842
|
+
fft_length : int, list[int], or None
|
|
843
|
+
Number of FFT bins. If None, set to (:math:`T1`, :math:`T2`).
|
|
844
|
+
|
|
845
|
+
dim : list[int]
|
|
846
|
+
Dimensions along which to take the Hilbert transform.
|
|
847
|
+
|
|
848
|
+
Returns
|
|
849
|
+
-------
|
|
850
|
+
out : Tensor [shape=(..., T1, T2, ...)]
|
|
851
|
+
Analytic signal, where real part is the input signal and imaginary part is
|
|
852
|
+
the Hilbert transform of the input signal.
|
|
853
|
+
|
|
854
|
+
"""
|
|
855
|
+
return nn.TwoDimensionalHilbertTransform._func(x, fft_length=fft_length, dim=dim)
|
|
856
|
+
|
|
857
|
+
|
|
741
858
|
def histogram(x, n_bin=10, lower_bound=0, upper_bound=1, norm=False, softness=1e-3):
|
|
742
859
|
"""Compute histogram.
|
|
743
860
|
|
|
@@ -801,7 +918,7 @@ def ialaw(y, abs_max=1, a=87.6):
|
|
|
801
918
|
return nn.ALawExpansion._func(y, abs_max=abs_max, a=a)
|
|
802
919
|
|
|
803
920
|
|
|
804
|
-
def idct(y):
|
|
921
|
+
def idct(y, dct_type=2):
|
|
805
922
|
"""Compute inverse DCT.
|
|
806
923
|
|
|
807
924
|
Parameters
|
|
@@ -809,16 +926,39 @@ def idct(y):
|
|
|
809
926
|
y : Tensor [shape=(..., L)]
|
|
810
927
|
Input.
|
|
811
928
|
|
|
929
|
+
dct_type : int in [1, 4]
|
|
930
|
+
DCT type.
|
|
931
|
+
|
|
812
932
|
Returns
|
|
813
933
|
-------
|
|
814
934
|
out : Tensor [shape=(..., L)]
|
|
815
935
|
Inverse DCT output.
|
|
816
936
|
|
|
817
937
|
"""
|
|
818
|
-
return nn.InverseDiscreteCosineTransform._func(y)
|
|
938
|
+
return nn.InverseDiscreteCosineTransform._func(y, dct_type=dct_type)
|
|
939
|
+
|
|
940
|
+
|
|
941
|
+
def idht(y, dht_type=2):
|
|
942
|
+
"""Compute inverse DHT.
|
|
943
|
+
|
|
944
|
+
Parameters
|
|
945
|
+
----------
|
|
946
|
+
y : Tensor [shape=(..., L)]
|
|
947
|
+
Input.
|
|
948
|
+
|
|
949
|
+
dht_type : int in [1, 4]
|
|
950
|
+
DHT type.
|
|
951
|
+
|
|
952
|
+
Returns
|
|
953
|
+
-------
|
|
954
|
+
out : Tensor [shape=(..., L)]
|
|
955
|
+
Inverse DHT output.
|
|
956
|
+
|
|
957
|
+
"""
|
|
958
|
+
return nn.InverseDiscreteHartleyTransform._func(y, dht_type=dht_type)
|
|
819
959
|
|
|
820
960
|
|
|
821
|
-
def idst(y):
|
|
961
|
+
def idst(y, dst_type=2):
|
|
822
962
|
"""Compute inverse DST.
|
|
823
963
|
|
|
824
964
|
Parameters
|
|
@@ -826,13 +966,16 @@ def idst(y):
|
|
|
826
966
|
y : Tensor [shape=(..., L)]
|
|
827
967
|
Input.
|
|
828
968
|
|
|
969
|
+
dst_type : int in [1, 4]
|
|
970
|
+
DST type.
|
|
971
|
+
|
|
829
972
|
Returns
|
|
830
973
|
-------
|
|
831
974
|
out : Tensor [shape=(..., L)]
|
|
832
975
|
Inverse DST output.
|
|
833
976
|
|
|
834
977
|
"""
|
|
835
|
-
return nn.InverseDiscreteSineTransform._func(y)
|
|
978
|
+
return nn.InverseDiscreteSineTransform._func(y, dst_type=dst_type)
|
|
836
979
|
|
|
837
980
|
|
|
838
981
|
def ifreqt2(c, out_order, alpha=0, theta=0, n_fft=512):
|
|
@@ -1060,6 +1203,26 @@ def iulaw(y, abs_max=1, mu=255):
|
|
|
1060
1203
|
return nn.MuLawExpansion._func(y, abs_max=abs_max, mu=mu)
|
|
1061
1204
|
|
|
1062
1205
|
|
|
1206
|
+
def iwht(y, wht_type="natural"):
|
|
1207
|
+
"""Compute inverse WHT.
|
|
1208
|
+
|
|
1209
|
+
Parameters
|
|
1210
|
+
----------
|
|
1211
|
+
y : Tensor [shape=(..., L)]
|
|
1212
|
+
Input.
|
|
1213
|
+
|
|
1214
|
+
wht_type : ['sequency', 'natural', 'dyadic']
|
|
1215
|
+
Order of coefficients of Walsh matrix.
|
|
1216
|
+
|
|
1217
|
+
Returns
|
|
1218
|
+
-------
|
|
1219
|
+
out : Tensor [shape=(..., L)]
|
|
1220
|
+
Inverse WHT output.
|
|
1221
|
+
|
|
1222
|
+
"""
|
|
1223
|
+
return nn.InverseWalshHadamardTransform._func(y, wht_type=wht_type)
|
|
1224
|
+
|
|
1225
|
+
|
|
1063
1226
|
def lar2par(g):
|
|
1064
1227
|
"""Convert LAR to PARCOR.
|
|
1065
1228
|
|
|
@@ -1853,30 +2016,27 @@ def rlevdur(a):
|
|
|
1853
2016
|
return nn.ReverseLevinsonDurbin._func(a)
|
|
1854
2017
|
|
|
1855
2018
|
|
|
1856
|
-
def rmse(x, y, reduction="mean"
|
|
2019
|
+
def rmse(x, y, reduction="mean"):
|
|
1857
2020
|
"""Calculate RMSE.
|
|
1858
2021
|
|
|
1859
2022
|
Parameters
|
|
1860
2023
|
----------
|
|
1861
|
-
x : Tensor [shape=(...,
|
|
2024
|
+
x : Tensor [shape=(..., D)]
|
|
1862
2025
|
Input.
|
|
1863
2026
|
|
|
1864
|
-
y : Tensor [shape=(...,
|
|
2027
|
+
y : Tensor [shape=(..., D)]
|
|
1865
2028
|
Target.
|
|
1866
2029
|
|
|
1867
2030
|
reduction : ['none', 'mean', 'sum']
|
|
1868
2031
|
Reduction type.
|
|
1869
2032
|
|
|
1870
|
-
eps : float >= 0
|
|
1871
|
-
A small value to prevent NaN.
|
|
1872
|
-
|
|
1873
2033
|
Returns
|
|
1874
2034
|
-------
|
|
1875
2035
|
out : Tensor [shape=(...,) or scalar]
|
|
1876
2036
|
RMSE.
|
|
1877
2037
|
|
|
1878
2038
|
"""
|
|
1879
|
-
return nn.RootMeanSquareError._func(x, y, reduction=reduction
|
|
2039
|
+
return nn.RootMeanSquareError._func(x, y, reduction=reduction)
|
|
1880
2040
|
|
|
1881
2041
|
|
|
1882
2042
|
def root_pol(a, out_format="rectangular"):
|
|
@@ -2126,6 +2286,26 @@ def unframe(
|
|
|
2126
2286
|
)
|
|
2127
2287
|
|
|
2128
2288
|
|
|
2289
|
+
def wht(x, wht_type="natural"):
|
|
2290
|
+
"""Compute WHT.
|
|
2291
|
+
|
|
2292
|
+
Parameters
|
|
2293
|
+
----------
|
|
2294
|
+
x : Tensor [shape=(..., L)]
|
|
2295
|
+
Input signal.
|
|
2296
|
+
|
|
2297
|
+
wht_type : ['sequency', 'natural', 'dyadic']
|
|
2298
|
+
Order of coefficients of Walsh matrix.
|
|
2299
|
+
|
|
2300
|
+
Returns
|
|
2301
|
+
-------
|
|
2302
|
+
out : Tensor [shape=(..., L)]
|
|
2303
|
+
WHT output.
|
|
2304
|
+
|
|
2305
|
+
"""
|
|
2306
|
+
return nn.WalshHadamardTransform._func(x, wht_type=wht_type)
|
|
2307
|
+
|
|
2308
|
+
|
|
2129
2309
|
def window(x, out_length=None, *, window="blackman", norm="power"):
|
|
2130
2310
|
"""Apply window function.
|
|
2131
2311
|
|
|
@@ -216,7 +216,7 @@ def train(order, frame_period, norm="power", **kwargs):
|
|
|
216
216
|
v = torch.full((order + 2,), frequency)
|
|
217
217
|
v[0] *= -1
|
|
218
218
|
v = torch.floor(torch.cumsum(v, dim=0))
|
|
219
|
-
index = torch.ge(v
|
|
219
|
+
index = torch.ge(torch.diff(v), 1)
|
|
220
220
|
|
|
221
221
|
x = torch.zeros(order + 1, **kwargs)
|
|
222
222
|
x[index] = pulse
|
|
@@ -266,7 +266,10 @@ def nrand(*order, mean=0, stdv=1, var=None, **kwargs):
|
|
|
266
266
|
stdv = var**0.5
|
|
267
267
|
assert 0 <= stdv
|
|
268
268
|
|
|
269
|
-
|
|
269
|
+
if any(isinstance(item, (list, tuple)) for item in order):
|
|
270
|
+
order = list(*order)
|
|
271
|
+
else:
|
|
272
|
+
order = list(order)
|
|
270
273
|
order[-1] += 1
|
|
271
274
|
x = torch.randn(*order, **kwargs)
|
|
272
275
|
x = x * stdv + mean
|