diffsptk 3.3.1__tar.gz → 3.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-3.3.1 → diffsptk-3.4.0}/PKG-INFO +11 -9
- {diffsptk-3.3.1 → diffsptk-3.4.0}/README.md +8 -6
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/functional.py +111 -5
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/__init__.py +3 -0
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/acorr.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/acr2csm.py +3 -10
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/alaw.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/ap.py +14 -6
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/b2mc.py +3 -2
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/c2acr.py +5 -5
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/c2mpir.py +4 -3
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/c2ndps.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/cdist.py +6 -8
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/chroma.py +9 -4
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/cqt.py +4 -3
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/csm2acr.py +4 -3
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/dct.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/decimate.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/delay.py +6 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/delta.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/dequantize.py +3 -2
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/df2.py +4 -3
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/dfs.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/dht.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/drc.py +17 -13
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/dst.py +2 -1
- diffsptk-3.4.0/diffsptk/modules/dtw.py +381 -0
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/entropy.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/excite.py +2 -1
- diffsptk-3.4.0/diffsptk/modules/f0eval.py +138 -0
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/fbank.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/fftcep.py +3 -2
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/fftr.py +2 -3
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/flux.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/frame.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/freqt.py +8 -7
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/freqt2.py +7 -9
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/gammatone.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/gmm.py +17 -10
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/gnorm.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/griffin.py +6 -5
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/grpdelay.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/hilbert.py +4 -5
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/hilbert2.py +4 -5
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/histogram.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/ialaw.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/ica.py +21 -2
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/icqt.py +4 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/idct.py +3 -2
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/idht.py +4 -3
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/idst.py +3 -2
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/ifbank.py +5 -4
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/ifftr.py +2 -3
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/ifreqt2.py +11 -10
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/igammatone.py +4 -3
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/ignorm.py +3 -2
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/imdct.py +3 -4
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/imdst.py +3 -4
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/imglsadf.py +6 -8
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/imsvq.py +5 -5
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/interpolate.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/ipnorm.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/ipqmf.py +5 -6
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/is2par.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/istft.py +2 -3
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/iulaw.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/ivq.py +5 -7
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/lar2par.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/lbg.py +11 -14
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/levdur.py +3 -4
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/linear_intpl.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/lpc.py +3 -3
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/lpc2lsp.py +5 -8
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/lpc2par.py +5 -8
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/lpccheck.py +8 -8
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/lsp2lpc.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/lsp2sp.py +6 -7
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/lspcheck.py +7 -3
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/magic_intpl.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/mc2b.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/mcep.py +3 -2
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/mcpf.py +8 -6
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/mdct.py +5 -6
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/mdst.py +2 -3
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/mfcc.py +5 -4
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/mgc2mgc.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/mgc2sp.py +7 -7
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/mgcep.py +4 -3
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/mglsadf.py +8 -10
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/mlpg.py +1 -0
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/mlsacheck.py +6 -4
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/mpir2c.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/msvq.py +11 -8
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/ndps2c.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/nmf.py +4 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/norm0.py +4 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/oband.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/par2is.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/par2lar.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/par2lpc.py +7 -8
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/pca.py +10 -7
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/phase.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/pitch.py +12 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/pitch_spec.py +3 -2
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/plp.py +3 -2
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/pnorm.py +3 -2
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/pol_root.py +3 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/poledf.py +3 -2
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/pqmf.py +3 -2
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/quantize.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/rlevdur.py +4 -3
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/rmse.py +6 -8
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/root_pol.py +3 -2
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/smcep.py +5 -4
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/snr.py +5 -7
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/spec.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/stft.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/ulaw.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/unframe.py +3 -2
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/vq.py +6 -5
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/wht.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/window.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/world_synth.py +19 -9
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/yingram.py +2 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/zcross.py +3 -3
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/zerodf.py +3 -2
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/signals.py +16 -10
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/third_party/world/common.py +1 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/utils/public.py +22 -18
- diffsptk-3.4.0/diffsptk/version.py +1 -0
- {diffsptk-3.3.1 → diffsptk-3.4.0}/pyproject.toml +2 -2
- diffsptk-3.3.1/diffsptk/version.py +0 -1
- {diffsptk-3.3.1 → diffsptk-3.4.0}/.gitignore +0 -0
- {diffsptk-3.3.1 → diffsptk-3.4.0}/CITATION.cff +0 -0
- {diffsptk-3.3.1 → diffsptk-3.4.0}/LICENSE +0 -0
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/__init__.py +0 -0
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/modules/base.py +0 -0
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/third_party/librosa/LICENSE +0 -0
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/third_party/librosa/__init__.py +0 -0
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/third_party/librosa/constantq.py +0 -0
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/third_party/librosa/filters.py +0 -0
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/third_party/librosa/typing.py +0 -0
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/third_party/librosa/util.py +0 -0
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/third_party/world/LICENSE +0 -0
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/third_party/world/__init__.py +0 -0
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/typing.py +0 -0
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/utils/__init__.py +0 -0
- {diffsptk-3.3.1 → diffsptk-3.4.0}/diffsptk/utils/private.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: diffsptk
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.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,8 +25,8 @@ Requires-Dist: scipy>=1.12.0
|
|
|
25
25
|
Requires-Dist: soundfile>=0.10.2
|
|
26
26
|
Requires-Dist: torch>=2.3.1
|
|
27
27
|
Requires-Dist: torchaudio>=2.3.1
|
|
28
|
-
Requires-Dist: torchcomp
|
|
29
|
-
Requires-Dist: torchlpc
|
|
28
|
+
Requires-Dist: torchcomp<0.3.0,>=0.1.0
|
|
29
|
+
Requires-Dist: torchlpc<0.7.0,>=0.1.0
|
|
30
30
|
Requires-Dist: tqdm>=4.63.0
|
|
31
31
|
Requires-Dist: vector-quantize-pytorch>=1.14.9
|
|
32
32
|
Provides-Extra: dev
|
|
@@ -47,11 +47,12 @@ 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.4.0/)
|
|
51
51
|
[](https://pepy.tech/project/diffsptk)
|
|
52
52
|
[](https://clickpy.clickhouse.com/dashboard/diffsptk)
|
|
53
|
+
[](https://snyk.io/advisor/python/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,8 +66,9 @@ Description-Content-Type: text/markdown
|
|
|
65
66
|
|
|
66
67
|
## Documentation
|
|
67
68
|
|
|
68
|
-
-
|
|
69
|
-
-
|
|
69
|
+
- Online [documentation](https://sp-nitech.github.io/diffsptk/3.4.0/) for the reference manual
|
|
70
|
+
- Conference [paper](https://www.isca-archive.org/ssw_2023/yoshimura23_ssw.html) on the ISCA Archive
|
|
71
|
+
- Hands-on [tutorial](https://colab.research.google.com/drive/1xAoUKqXadvJXJ7RzN0OceB6y7q5i7Sn6?usp=drive_link) on Google Colab
|
|
70
72
|
|
|
71
73
|
## Installation
|
|
72
74
|
|
|
@@ -259,7 +261,7 @@ error = (x_hat - x).abs().sum()
|
|
|
259
261
|
print(error)
|
|
260
262
|
```
|
|
261
263
|
|
|
262
|
-
### Mel
|
|
264
|
+
### Mel spectrogram analysis and synthesis
|
|
263
265
|
|
|
264
266
|
```python
|
|
265
267
|
import diffsptk
|
|
@@ -276,7 +278,7 @@ x, sr = diffsptk.read("assets/data.wav")
|
|
|
276
278
|
stft = diffsptk.STFT(frame_length=fl, frame_period=fp, fft_length=n_fft)
|
|
277
279
|
X = stft(x)
|
|
278
280
|
|
|
279
|
-
# Extract log
|
|
281
|
+
# Extract log-mel spectrogram.
|
|
280
282
|
fbank = diffsptk.FBANK(
|
|
281
283
|
fft_length=n_fft,
|
|
282
284
|
n_channel=n_channel,
|
|
@@ -2,11 +2,12 @@
|
|
|
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.4.0/)
|
|
6
6
|
[](https://pepy.tech/project/diffsptk)
|
|
7
7
|
[](https://clickpy.clickhouse.com/dashboard/diffsptk)
|
|
8
|
+
[](https://snyk.io/advisor/python/diffsptk)
|
|
8
9
|
[](https://pypi.python.org/pypi/diffsptk)
|
|
9
|
-
[](https://pypi.python.org/pypi/diffsptk)
|
|
10
11
|
[](https://pypi.python.org/pypi/diffsptk)
|
|
11
12
|
[](https://app.codecov.io/gh/sp-nitech/diffsptk)
|
|
12
13
|
[](https://github.com/sp-nitech/diffsptk/blob/master/LICENSE)
|
|
@@ -20,8 +21,9 @@
|
|
|
20
21
|
|
|
21
22
|
## Documentation
|
|
22
23
|
|
|
23
|
-
-
|
|
24
|
-
-
|
|
24
|
+
- Online [documentation](https://sp-nitech.github.io/diffsptk/3.4.0/) for the reference manual
|
|
25
|
+
- Conference [paper](https://www.isca-archive.org/ssw_2023/yoshimura23_ssw.html) on the ISCA Archive
|
|
26
|
+
- Hands-on [tutorial](https://colab.research.google.com/drive/1xAoUKqXadvJXJ7RzN0OceB6y7q5i7Sn6?usp=drive_link) on Google Colab
|
|
25
27
|
|
|
26
28
|
## Installation
|
|
27
29
|
|
|
@@ -214,7 +216,7 @@ error = (x_hat - x).abs().sum()
|
|
|
214
216
|
print(error)
|
|
215
217
|
```
|
|
216
218
|
|
|
217
|
-
### Mel
|
|
219
|
+
### Mel spectrogram analysis and synthesis
|
|
218
220
|
|
|
219
221
|
```python
|
|
220
222
|
import diffsptk
|
|
@@ -231,7 +233,7 @@ x, sr = diffsptk.read("assets/data.wav")
|
|
|
231
233
|
stft = diffsptk.STFT(frame_length=fl, frame_period=fp, fft_length=n_fft)
|
|
232
234
|
X = stft(x)
|
|
233
235
|
|
|
234
|
-
# Extract log
|
|
236
|
+
# Extract log-mel spectrogram.
|
|
235
237
|
fbank = diffsptk.FBANK(
|
|
236
238
|
fft_length=n_fft,
|
|
237
239
|
n_channel=n_channel,
|
|
@@ -444,11 +444,12 @@ def dht(x: Tensor, dht_type: int = 2) -> Tensor:
|
|
|
444
444
|
|
|
445
445
|
def drc(
|
|
446
446
|
x: Tensor,
|
|
447
|
+
*,
|
|
448
|
+
sample_rate: int,
|
|
447
449
|
threshold: float,
|
|
448
450
|
ratio: float,
|
|
449
451
|
attack_time: float,
|
|
450
452
|
release_time: float,
|
|
451
|
-
sample_rate: int,
|
|
452
453
|
makeup_gain: float = 0,
|
|
453
454
|
abs_max: float = 1,
|
|
454
455
|
) -> Tensor:
|
|
@@ -459,6 +460,9 @@ def drc(
|
|
|
459
460
|
x : Tensor [shape=(..., T)]
|
|
460
461
|
The input waveform.
|
|
461
462
|
|
|
463
|
+
sample_rate : int >= 1
|
|
464
|
+
The sample rate in Hz.
|
|
465
|
+
|
|
462
466
|
threshold : float <= 0
|
|
463
467
|
The threshold in dB.
|
|
464
468
|
|
|
@@ -471,9 +475,6 @@ def drc(
|
|
|
471
475
|
release_time : float > 0
|
|
472
476
|
The release time in msec.
|
|
473
477
|
|
|
474
|
-
sample_rate : int >= 1
|
|
475
|
-
The sample rate in Hz.
|
|
476
|
-
|
|
477
478
|
makeup_gain : float >= 0
|
|
478
479
|
The make-up gain in dB.
|
|
479
480
|
|
|
@@ -518,6 +519,82 @@ def dst(x: Tensor, dst_type: int = 2) -> Tensor:
|
|
|
518
519
|
return nn.DiscreteSineTransform._func(x, dst_type=dst_type)
|
|
519
520
|
|
|
520
521
|
|
|
522
|
+
def dtw(
|
|
523
|
+
x: Tensor,
|
|
524
|
+
y: Tensor,
|
|
525
|
+
lengths: Tensor | None = None,
|
|
526
|
+
return_indices: bool = False,
|
|
527
|
+
metric: str | int = "euclidean",
|
|
528
|
+
p: int = 4,
|
|
529
|
+
softness: float = 1e-3,
|
|
530
|
+
) -> Tensor | tuple[Tensor, list[Tensor]]:
|
|
531
|
+
"""Compute dynamic time warping distance.
|
|
532
|
+
|
|
533
|
+
x : Tensor [shape=(B, T1, D) or (T1, D) or (T1,)]
|
|
534
|
+
The query vector sequence.
|
|
535
|
+
|
|
536
|
+
y : Tensor [shape=(B, T2, D), (T2, D) or (T2,)]
|
|
537
|
+
The reference vector sequence.
|
|
538
|
+
|
|
539
|
+
lengths : Tensor [shape=(B, 2)] or None
|
|
540
|
+
The lengths of the sequences.
|
|
541
|
+
|
|
542
|
+
return_indices : bool
|
|
543
|
+
If True, returns the indices of the viterbi path.
|
|
544
|
+
|
|
545
|
+
metric : ['manhattan', 'euclidean', 'squared-euclidean', 'symmetric-kl']
|
|
546
|
+
The metric to compute the distance between two vectors.
|
|
547
|
+
|
|
548
|
+
p : int in [0, 6]
|
|
549
|
+
The local path constraint type.
|
|
550
|
+
|
|
551
|
+
softness : float > 0
|
|
552
|
+
A smoothing parameter. The smaller value makes the output closer to the true
|
|
553
|
+
dynamic time warping distance, but the gradient vanishes.
|
|
554
|
+
|
|
555
|
+
Returns
|
|
556
|
+
-------
|
|
557
|
+
distance : Tensor [shape=(B,)]
|
|
558
|
+
The dynamic time warping distance.
|
|
559
|
+
|
|
560
|
+
indices : list[Tensor [shape=(T, 2)]] (optional)
|
|
561
|
+
The indices of the viterbi path for each batch.
|
|
562
|
+
|
|
563
|
+
"""
|
|
564
|
+
return nn.DynamicTimeWarping._func(
|
|
565
|
+
x,
|
|
566
|
+
y,
|
|
567
|
+
lengths=lengths,
|
|
568
|
+
return_indices=return_indices,
|
|
569
|
+
metric=metric,
|
|
570
|
+
p=p,
|
|
571
|
+
softness=softness,
|
|
572
|
+
)
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
def dtw_merge(x: Tensor, y: Tensor, indices: Tensor) -> Tensor:
|
|
576
|
+
"""Merge two sequences according to the given indices.
|
|
577
|
+
|
|
578
|
+
Parameters
|
|
579
|
+
----------
|
|
580
|
+
x : Tensor [shape=(T1, D) or (T1,)]
|
|
581
|
+
The query vector sequence.
|
|
582
|
+
|
|
583
|
+
y : Tensor [shape=(T2, D) or (T2,)]
|
|
584
|
+
The reference vector sequence.
|
|
585
|
+
|
|
586
|
+
indices : Tensor [shape=(T, 2)]
|
|
587
|
+
The indices of the viterbi path.
|
|
588
|
+
|
|
589
|
+
Returns
|
|
590
|
+
-------
|
|
591
|
+
z : Tensor [shape=(T, 2D) or (T, 2)]
|
|
592
|
+
The merged vector sequence.
|
|
593
|
+
|
|
594
|
+
"""
|
|
595
|
+
return nn.DynamicTimeWarping.merge(x=x, y=y, indices=indices)
|
|
596
|
+
|
|
597
|
+
|
|
521
598
|
def entropy(p: Tensor, out_format: str = "nat") -> Tensor:
|
|
522
599
|
"""Calculate the entropy of a probability distribution.
|
|
523
600
|
|
|
@@ -586,6 +663,35 @@ def excite(
|
|
|
586
663
|
)
|
|
587
664
|
|
|
588
665
|
|
|
666
|
+
def f0eval(
|
|
667
|
+
x: Tensor, y: Tensor, reduction: str = "mean", out_format: str = "f0-rmse-cent"
|
|
668
|
+
) -> Tensor:
|
|
669
|
+
"""Calculate F0 metric.
|
|
670
|
+
|
|
671
|
+
Parameters
|
|
672
|
+
----------
|
|
673
|
+
x : Tensor [shape=(..., N)]
|
|
674
|
+
The input F0 in Hz.
|
|
675
|
+
|
|
676
|
+
y : Tensor [shape=(..., N)]
|
|
677
|
+
The target F0 in Hz.
|
|
678
|
+
|
|
679
|
+
reduction : ['none', 'mean', 'sum']
|
|
680
|
+
The reduction type.
|
|
681
|
+
|
|
682
|
+
out_format : ['f0-rmse-hz', 'f0-rmse-cent', 'f0-rmse-semitone', 'vuv-error-rate', \
|
|
683
|
+
'vuv-error-percent', 'vuv-macro-f1-score']
|
|
684
|
+
The output format.
|
|
685
|
+
|
|
686
|
+
Returns
|
|
687
|
+
-------
|
|
688
|
+
out : Tensor [shape=(...,) or scalar]
|
|
689
|
+
The F0 metric.
|
|
690
|
+
|
|
691
|
+
"""
|
|
692
|
+
return nn.F0Evaluation._func(x, y, reduction=reduction, out_format=out_format)
|
|
693
|
+
|
|
694
|
+
|
|
589
695
|
def fbank(
|
|
590
696
|
x: Tensor,
|
|
591
697
|
n_channel: int,
|
|
@@ -598,7 +704,7 @@ def fbank(
|
|
|
598
704
|
erb_factor: float | None = None,
|
|
599
705
|
use_power: bool = False,
|
|
600
706
|
out_format: str = "y",
|
|
601
|
-
) -> tuple[Tensor, Tensor]
|
|
707
|
+
) -> Tensor | tuple[Tensor, Tensor]:
|
|
602
708
|
"""Apply mel-filter banks to the STFT.
|
|
603
709
|
|
|
604
710
|
Parameters
|
|
@@ -42,8 +42,11 @@ from .drc import DynamicRangeCompression
|
|
|
42
42
|
from .drc import DynamicRangeCompression as DRC
|
|
43
43
|
from .dst import DiscreteSineTransform
|
|
44
44
|
from .dst import DiscreteSineTransform as DST
|
|
45
|
+
from .dtw import DynamicTimeWarping
|
|
46
|
+
from .dtw import DynamicTimeWarping as DTW
|
|
45
47
|
from .entropy import Entropy
|
|
46
48
|
from .excite import ExcitationGeneration
|
|
49
|
+
from .f0eval import F0Evaluation
|
|
47
50
|
from .fbank import MelFilterBankAnalysis
|
|
48
51
|
from .fbank import MelFilterBankAnalysis as FBANK
|
|
49
52
|
from .fftcep import CepstralAnalysis
|
|
@@ -62,8 +62,9 @@ class Autocorrelation(BaseFunctionalModule):
|
|
|
62
62
|
|
|
63
63
|
Examples
|
|
64
64
|
--------
|
|
65
|
-
>>>
|
|
65
|
+
>>> import diffsptk
|
|
66
66
|
>>> acorr = diffsptk.Autocorrelation(5, 3)
|
|
67
|
+
>>> x = diffsptk.ramp(4)
|
|
67
68
|
>>> r = acorr(x)
|
|
68
69
|
>>> r
|
|
69
70
|
tensor([30.0000, 20.0000, 11.0000, 4.0000])
|
|
@@ -73,14 +73,13 @@ class AutocorrelationToCompositeSinusoidalModelCoefficients(BaseFunctionalModule
|
|
|
73
73
|
|
|
74
74
|
Examples
|
|
75
75
|
--------
|
|
76
|
-
>>>
|
|
77
|
-
>>> x
|
|
78
|
-
tensor([ 0.0165, -2.3693, 0.1375, -0.2262, 1.3307])
|
|
76
|
+
>>> import diffsptk
|
|
79
77
|
>>> acorr = diffsptk.Autocorrelation(5, 3)
|
|
80
78
|
>>> acr2csm = diffsptk.AutocorrelationToCompositeSinusoidalModelCoefficients(3)
|
|
79
|
+
>>> x = diffsptk.ramp(4)
|
|
81
80
|
>>> c = acr2csm(acorr(x))
|
|
82
81
|
>>> c
|
|
83
|
-
tensor([0.
|
|
82
|
+
tensor([ 0.5261, 2.1403, 25.7668, 4.2332])
|
|
84
83
|
|
|
85
84
|
"""
|
|
86
85
|
check_size(r.size(-1), self.in_dim, "dimension of autocorrelation")
|
|
@@ -137,12 +136,6 @@ class AutocorrelationToCompositeSinusoidalModelCoefficients(BaseFunctionalModule
|
|
|
137
136
|
|
|
138
137
|
@staticmethod
|
|
139
138
|
def _forward(r: torch.Tensor, C: torch.Tensor) -> torch.Tensor:
|
|
140
|
-
if r.dtype != torch.double or C.dtype != torch.double:
|
|
141
|
-
raise ValueError(
|
|
142
|
-
"Only double precision is supported "
|
|
143
|
-
f"(input: {r.dtype}, module: {C.dtype})."
|
|
144
|
-
)
|
|
145
|
-
|
|
146
139
|
u = torch.matmul(r, C)
|
|
147
140
|
u1, u2 = torch.tensor_split(u, 2, dim=-1)
|
|
148
141
|
|
|
@@ -57,8 +57,9 @@ class ALawCompression(BaseFunctionalModule):
|
|
|
57
57
|
|
|
58
58
|
Examples
|
|
59
59
|
--------
|
|
60
|
-
>>>
|
|
60
|
+
>>> import diffsptk
|
|
61
61
|
>>> alaw = diffsptk.ALawCompression(4)
|
|
62
|
+
>>> x = diffsptk.ramp(4)
|
|
62
63
|
>>> y = alaw(x)
|
|
63
64
|
>>> y
|
|
64
65
|
tensor([0.0000, 2.9868, 3.4934, 3.7897, 4.0000])
|
|
@@ -38,7 +38,7 @@ class Aperiodicity(BaseNonFunctionalModule):
|
|
|
38
38
|
The frame period in samples, :math:`P`.
|
|
39
39
|
|
|
40
40
|
sample_rate : int >= 8000
|
|
41
|
-
The sample rate in Hz.
|
|
41
|
+
The sample rate in Hz. If **algorithm** is 'd4c', it must be at least 12000 Hz.
|
|
42
42
|
|
|
43
43
|
fft_length : int >= 16 or None
|
|
44
44
|
The size of double-sided aperiodicity, :math:`L`. If None, the band aperiodicity
|
|
@@ -138,15 +138,16 @@ class Aperiodicity(BaseNonFunctionalModule):
|
|
|
138
138
|
|
|
139
139
|
Examples
|
|
140
140
|
--------
|
|
141
|
-
>>>
|
|
142
|
-
>>> pitch = diffsptk.Pitch(160,
|
|
141
|
+
>>> import diffsptk
|
|
142
|
+
>>> pitch = diffsptk.Pitch(160, 16000, out_format="f0")
|
|
143
|
+
>>> aperiodicity = diffsptk.Aperiodicity(160, 16000, 1024)
|
|
144
|
+
>>> x = diffsptk.sin(2000, 80)
|
|
143
145
|
>>> f0 = pitch(x)
|
|
144
146
|
>>> f0.shape
|
|
145
|
-
torch.Size([
|
|
146
|
-
>>> aperiodicity = diffsptk.Aperiodicity(160, 16000, 1024)
|
|
147
|
+
torch.Size([13])
|
|
147
148
|
>>> ap = aperiodicity(x, f0)
|
|
148
149
|
>>> ap.shape
|
|
149
|
-
torch.Size([
|
|
150
|
+
torch.Size([13, 513])
|
|
150
151
|
|
|
151
152
|
"""
|
|
152
153
|
d = x.dim()
|
|
@@ -461,6 +462,13 @@ class AperiodicityExtractionByD4C(nn.Module):
|
|
|
461
462
|
) -> None:
|
|
462
463
|
super().__init__()
|
|
463
464
|
|
|
465
|
+
if sample_rate < 12000:
|
|
466
|
+
raise ValueError("sample_rate must be at least 12000 Hz.")
|
|
467
|
+
if threshold < 0:
|
|
468
|
+
raise ValueError("threshold must be non-negative.")
|
|
469
|
+
if default_f0 <= 0:
|
|
470
|
+
raise ValueError("default_f0 must be positive.")
|
|
471
|
+
|
|
464
472
|
self.frame_period = frame_period
|
|
465
473
|
self.sample_rate = sample_rate
|
|
466
474
|
self.threshold = threshold
|
|
@@ -77,12 +77,13 @@ class MLSADigitalFilterCoefficientsToMelCepstrum(BaseFunctionalModule):
|
|
|
77
77
|
|
|
78
78
|
Examples
|
|
79
79
|
--------
|
|
80
|
-
>>>
|
|
80
|
+
>>> import diffsptk
|
|
81
81
|
>>> mc2b = diffsptk.MelCepstrumToMLSADigitalFilterCoefficients(4, 0.3)
|
|
82
82
|
>>> b2mc = diffsptk.MLSADigitalFilterCoefficientsToMelCepstrum(4, 0.3)
|
|
83
|
+
>>> b = diffsptk.ramp(1, 5)
|
|
83
84
|
>>> b2 = mc2b(b2mc(b))
|
|
84
85
|
>>> b2
|
|
85
|
-
tensor([
|
|
86
|
+
tensor([1.0000, 2.0000, 3.0000, 4.0000, 5.0000])
|
|
86
87
|
|
|
87
88
|
"""
|
|
88
89
|
check_size(b.size(-1), self.in_dim, "dimension of cepstrum")
|
|
@@ -61,13 +61,13 @@ class CepstrumToAutocorrelation(BaseFunctionalModule):
|
|
|
61
61
|
|
|
62
62
|
Examples
|
|
63
63
|
--------
|
|
64
|
-
>>>
|
|
65
|
-
>>>
|
|
66
|
-
|
|
67
|
-
>>>
|
|
64
|
+
>>> import diffsptk
|
|
65
|
+
>>> import torch
|
|
66
|
+
>>> c2acr = diffsptk.CepstrumToAutocorrelation(4, 3)
|
|
67
|
+
>>> c = torch.tensor([0.5, -0.3, 0.2, -0.1, 0.05])
|
|
68
68
|
>>> r = c2acr(c)
|
|
69
69
|
>>> r
|
|
70
|
-
tensor([
|
|
70
|
+
tensor([ 3.2404, -1.1920, 0.9037, -0.5838])
|
|
71
71
|
|
|
72
72
|
"""
|
|
73
73
|
check_size(c.size(-1), self.in_dim, "dimension of cepstrum")
|
|
@@ -61,11 +61,12 @@ class CepstrumToMinimumPhaseImpulseResponse(BaseFunctionalModule):
|
|
|
61
61
|
|
|
62
62
|
Examples
|
|
63
63
|
--------
|
|
64
|
-
>>>
|
|
65
|
-
>>> c2mpir = diffsptk.CepstrumToMinimumPhaseImpulseResponse(
|
|
64
|
+
>>> import diffsptk
|
|
65
|
+
>>> c2mpir = diffsptk.CepstrumToMinimumPhaseImpulseResponse(4, 5)
|
|
66
|
+
>>> c = torch.tensor([0.5, -0.3, 0.2, -0.1, 0.05])
|
|
66
67
|
>>> h = c2mpir(c)
|
|
67
68
|
>>> h
|
|
68
|
-
tensor([1.
|
|
69
|
+
tensor([ 1.6487, -0.4946, 0.4039, -0.2712, 0.1803])
|
|
69
70
|
|
|
70
71
|
"""
|
|
71
72
|
check_size(c.size(-1), self.in_dim, "dimension of cepstrum")
|
|
@@ -75,8 +75,9 @@ class CepstrumToNegativeDerivativeOfPhaseSpectrum(BaseFunctionalModule):
|
|
|
75
75
|
|
|
76
76
|
Examples
|
|
77
77
|
--------
|
|
78
|
-
>>>
|
|
78
|
+
>>> import diffsptk
|
|
79
79
|
>>> c2ndps = diffsptk.CepstrumToNegativeDerivativeOfPhaseSpectrum(4, 8)
|
|
80
|
+
>>> c = diffsptk.ramp(4)
|
|
80
81
|
>>> n = c2ndps(c)
|
|
81
82
|
>>> n
|
|
82
83
|
tensor([ 30.0000, -21.6569, 12.0000, -10.3431, 10.0000])
|
|
@@ -66,16 +66,14 @@ class CepstralDistance(BaseFunctionalModule):
|
|
|
66
66
|
|
|
67
67
|
Examples
|
|
68
68
|
--------
|
|
69
|
-
>>>
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
>>>
|
|
73
|
-
tensor([[ 1.6441, -0.6962,
|
|
74
|
-
[ 0.9344, 0.3965, 1.1494]])
|
|
75
|
-
>>> cdist = diffsptk.CepstralDistance()
|
|
69
|
+
>>> import diffsptk
|
|
70
|
+
>>> import torch
|
|
71
|
+
>>> cdist = diffsptk.CepstralDistance(reduction="none")
|
|
72
|
+
>>> c1 = torch.tensor([[ 0.4296, 1.6517], [-1.0464, -0.6088]])
|
|
73
|
+
>>> c2 = torch.tensor([[ 1.6441, -0.6962], [ 0.9344, 0.3965]])
|
|
76
74
|
>>> distance = cdist(c1, c2)
|
|
77
75
|
>>> distance
|
|
78
|
-
tensor(1.
|
|
76
|
+
tensor([2.3479, 1.0053])
|
|
79
77
|
|
|
80
78
|
"""
|
|
81
79
|
return self._forward(c1, c2, *self.values)
|
|
@@ -85,10 +85,15 @@ class ChromaFilterBankAnalysis(BaseFunctionalModule):
|
|
|
85
85
|
|
|
86
86
|
Examples
|
|
87
87
|
--------
|
|
88
|
-
>>>
|
|
89
|
-
>>>
|
|
90
|
-
>>> stft = diffsptk.STFT(
|
|
91
|
-
|
|
88
|
+
>>> import diffsptk
|
|
89
|
+
>>> sample_rate = 16000
|
|
90
|
+
>>> stft = diffsptk.STFT(
|
|
91
|
+
... frame_length=512, frame_period=512, fft_length=512, window="hanning"
|
|
92
|
+
... )
|
|
93
|
+
>>> chroma = diffsptk.ChromaFilterBankAnalysis(
|
|
94
|
+
... fft_length=512, n_channel=12, sample_rate=sample_rate
|
|
95
|
+
... )
|
|
96
|
+
>>> x = diffsptk.sin(500, period=sample_rate / 440)
|
|
92
97
|
>>> y = chroma(stft(x))
|
|
93
98
|
>>> y
|
|
94
99
|
tensor([[0.1146, 0.0574, 0.0457, 0.0468, 0.0519, 0.0789, 0.1736, 0.4285, 0.7416,
|
|
@@ -274,11 +274,12 @@ class ConstantQTransform(BaseNonFunctionalModule):
|
|
|
274
274
|
|
|
275
275
|
Examples
|
|
276
276
|
--------
|
|
277
|
-
>>>
|
|
278
|
-
>>> cqt = diffsptk.CQT(100, 8000, n_bin=4)
|
|
277
|
+
>>> import diffsptk
|
|
278
|
+
>>> cqt = diffsptk.CQT(100, 8000, n_bin=4, res_type=None)
|
|
279
|
+
>>> x = diffsptk.sin(100 - 1)
|
|
279
280
|
>>> c = cqt(x).abs()
|
|
280
281
|
>>> c
|
|
281
|
-
tensor([[1.
|
|
282
|
+
tensor([[1.1231, 1.2045, 1.2976, 1.3867]])
|
|
282
283
|
|
|
283
284
|
"""
|
|
284
285
|
x = self.early_downsample(x)
|
|
@@ -71,16 +71,17 @@ class CompositeSinusoidalModelCoefficientsToAutocorrelation(BaseFunctionalModule
|
|
|
71
71
|
|
|
72
72
|
Examples
|
|
73
73
|
--------
|
|
74
|
-
>>>
|
|
74
|
+
>>> import diffsptk
|
|
75
75
|
>>> acorr = diffsptk.Autocorrelation(5, 3)
|
|
76
76
|
>>> acr2csm = diffsptk.AutocorrelationToCompositeSinusoidalModelCoefficients(3)
|
|
77
77
|
>>> csm2acr = diffsptk.CompositeSinusoidalModelCoefficientsToAutocorrelation(3)
|
|
78
|
+
>>> x = diffsptk.ramp(4)
|
|
78
79
|
>>> r = acorr(x)
|
|
79
80
|
>>> r
|
|
80
|
-
tensor([
|
|
81
|
+
tensor([30.0000, 20.0000, 11.0000, 4.0000])
|
|
81
82
|
>>> r2 = csm2acr(acr2csm(r))
|
|
82
83
|
>>> r2
|
|
83
|
-
tensor([
|
|
84
|
+
tensor([30.0000, 20.0000, 11.0000, 4.0000])
|
|
84
85
|
|
|
85
86
|
"""
|
|
86
87
|
check_size(c.size(-1), self.in_dim, "dimension of autocorrelation")
|
|
@@ -70,8 +70,9 @@ class DiscreteCosineTransform(BaseFunctionalModule):
|
|
|
70
70
|
|
|
71
71
|
Examples
|
|
72
72
|
--------
|
|
73
|
-
>>>
|
|
73
|
+
>>> import diffsptk
|
|
74
74
|
>>> dct = diffsptk.DCT(4)
|
|
75
|
+
>>> x = diffsptk.ramp(3)
|
|
75
76
|
>>> y = dct(x)
|
|
76
77
|
>>> y
|
|
77
78
|
tensor([ 3.0000, -2.2304, 0.0000, -0.1585])
|
|
@@ -59,11 +59,16 @@ class Delay(BaseFunctionalModule):
|
|
|
59
59
|
|
|
60
60
|
Examples
|
|
61
61
|
--------
|
|
62
|
-
>>>
|
|
62
|
+
>>> import diffsptk
|
|
63
63
|
>>> delay = diffsptk.Delay(2)
|
|
64
|
+
>>> x = diffsptk.ramp(1, 3)
|
|
64
65
|
>>> y = delay(x)
|
|
65
66
|
>>> y
|
|
66
67
|
tensor([0., 0., 1., 2., 3.])
|
|
68
|
+
>>> delay = diffsptk.Delay(-2)
|
|
69
|
+
>>> y = delay(x)
|
|
70
|
+
>>> y
|
|
71
|
+
tensor([3.])
|
|
67
72
|
|
|
68
73
|
"""
|
|
69
74
|
return self._forward(x, *self.values)
|
|
@@ -72,13 +72,14 @@ class Delta(BaseFunctionalModule):
|
|
|
72
72
|
|
|
73
73
|
Examples
|
|
74
74
|
--------
|
|
75
|
+
>>> import diffsptk
|
|
76
|
+
>>> delta = diffsptk.Delta([[-0.5, 0], [0, 0, 0.5]])
|
|
75
77
|
>>> x = diffsptk.ramp(1, 8).view(1, -1, 2)
|
|
76
78
|
>>> x
|
|
77
79
|
tensor([[[1., 2.],
|
|
78
80
|
[3., 4.],
|
|
79
81
|
[5., 6.],
|
|
80
82
|
[7., 8.]]])
|
|
81
|
-
>>> delta = diffsptk.Delta([[-0.5, 0], [0, 0, 0.5]])
|
|
82
83
|
>>> y = delta(x)
|
|
83
84
|
>>> y
|
|
84
85
|
tensor([[[ 1.0000, 2.0000, -0.5000, -1.0000, 1.5000, 2.0000],
|
|
@@ -61,11 +61,12 @@ class InverseUniformQuantization(BaseFunctionalModule):
|
|
|
61
61
|
|
|
62
62
|
Examples
|
|
63
63
|
--------
|
|
64
|
+
>>> import diffsptk
|
|
65
|
+
>>> quantize = diffsptk.UniformQuantization(4, 2)
|
|
66
|
+
>>> dequantize = diffsptk.InverseUniformQuantization(4, 2)
|
|
64
67
|
>>> x = diffsptk.ramp(-4, 4)
|
|
65
68
|
>>> x
|
|
66
69
|
tensor([-4., -3., -2., -1., 0., 1., 2., 3., 4.])
|
|
67
|
-
>>> quantize = diffsptk.UniformQuantization(4, 2)
|
|
68
|
-
>>> dequantize = diffsptk.InverseUniformQuantization(4, 2)
|
|
69
70
|
>>> x2 = dequantize(quantize(x))
|
|
70
71
|
>>> x2
|
|
71
72
|
tensor([-3., -3., -1., -1., 1., 1., 3., 3., 3.])
|
|
@@ -89,11 +89,12 @@ class SecondOrderDigitalFilter(BaseNonFunctionalModule):
|
|
|
89
89
|
|
|
90
90
|
Examples
|
|
91
91
|
--------
|
|
92
|
-
>>>
|
|
93
|
-
>>> df2 = diffsptk.SecondOrderDigitalFilter(16000,
|
|
92
|
+
>>> import diffsptk
|
|
93
|
+
>>> df2 = diffsptk.SecondOrderDigitalFilter(16000, 1000, 200)
|
|
94
|
+
>>> x = diffsptk.impulse(4)
|
|
94
95
|
>>> y = df2(x)
|
|
95
96
|
>>> y
|
|
96
|
-
tensor([
|
|
97
|
+
tensor([1.0000, 1.7766, 2.2319, 2.3227, 2.0633])
|
|
97
98
|
|
|
98
99
|
"""
|
|
99
100
|
return self._forward(x, *self.layers)
|
|
@@ -89,8 +89,9 @@ class InfiniteImpulseResponseDigitalFilter(BaseFunctionalModule):
|
|
|
89
89
|
|
|
90
90
|
Examples
|
|
91
91
|
--------
|
|
92
|
-
>>>
|
|
92
|
+
>>> import diffsptk
|
|
93
93
|
>>> dfs = diffsptk.IIR(b=[1, -0.97])
|
|
94
|
+
>>> x = diffsptk.ramp(4)
|
|
94
95
|
>>> y = dfs(x)
|
|
95
96
|
>>> y
|
|
96
97
|
tensor([0.0000, 1.0000, 1.0300, 1.0600, 1.0900])
|
|
@@ -69,8 +69,9 @@ class DiscreteHartleyTransform(BaseFunctionalModule):
|
|
|
69
69
|
|
|
70
70
|
Examples
|
|
71
71
|
--------
|
|
72
|
-
>>>
|
|
72
|
+
>>> import diffsptk
|
|
73
73
|
>>> dht = diffsptk.DHT(4)
|
|
74
|
+
>>> x = diffsptk.ramp(3)
|
|
74
75
|
>>> y = dht(x)
|
|
75
76
|
>>> y
|
|
76
77
|
tensor([ 3.0000, -1.4142, -1.0000, -1.4142])
|