diffsptk 2.0.0__tar.gz → 2.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {diffsptk-2.0.0 → diffsptk-2.2.0}/.gitignore +4 -2
- diffsptk-2.2.0/CITATION.cff +26 -0
- {diffsptk-2.0.0 → diffsptk-2.2.0}/PKG-INFO +98 -31
- {diffsptk-2.0.0 → diffsptk-2.2.0}/README.md +85 -22
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/functional.py +354 -10
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/misc/utils.py +37 -9
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/__init__.py +21 -0
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/acorr.py +8 -8
- diffsptk-2.2.0/diffsptk/modules/acr2csm.py +119 -0
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/alaw.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/ap.py +13 -13
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/b2mc.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/c2acr.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/c2mpir.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/c2ndps.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/cdist.py +3 -5
- diffsptk-2.2.0/diffsptk/modules/chroma.py +132 -0
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/cqt.py +3 -3
- diffsptk-2.2.0/diffsptk/modules/csm2acr.py +92 -0
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/dct.py +5 -5
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/decimate.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/delay.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/delta.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/dequantize.py +4 -4
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/df2.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/dfs.py +2 -2
- diffsptk-2.2.0/diffsptk/modules/drc.py +183 -0
- diffsptk-2.2.0/diffsptk/modules/dst.py +85 -0
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/entropy.py +5 -5
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/excite.py +4 -4
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/fbank.py +5 -5
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/fftcep.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/frame.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/freqt.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/freqt2.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/gmm.py +124 -58
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/gnorm.py +4 -4
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/grpdelay.py +2 -2
- diffsptk-2.2.0/diffsptk/modules/histogram.py +114 -0
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/ialaw.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/icqt.py +5 -5
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/idct.py +2 -2
- diffsptk-2.2.0/diffsptk/modules/idst.py +81 -0
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/ifreqt2.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/ignorm.py +2 -2
- diffsptk-2.2.0/diffsptk/modules/imdct.py +160 -0
- diffsptk-2.2.0/diffsptk/modules/imdst.py +73 -0
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/imglsadf.py +2 -10
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/imsvq.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/interpolate.py +2 -2
- diffsptk-2.2.0/diffsptk/modules/ipnorm.py +71 -0
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/ipqmf.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/istft.py +3 -3
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/iulaw.py +3 -3
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/ivq.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/lar2par.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/lbg.py +121 -34
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/levdur.py +21 -7
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/linear_intpl.py +5 -5
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/lpc.py +11 -8
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/lpc2lsp.py +6 -6
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/lpc2par.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/lpccheck.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/lsp2lpc.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/lsp2sp.py +6 -6
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/lspcheck.py +4 -4
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/magic_intpl.py +6 -6
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/mc2b.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/mcep.py +3 -3
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/mcpf.py +5 -5
- diffsptk-2.2.0/diffsptk/modules/mdct.py +163 -0
- diffsptk-2.2.0/diffsptk/modules/mdst.py +70 -0
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/mfcc.py +6 -6
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/mgc2mgc.py +7 -7
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/mgc2sp.py +9 -9
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/mgcep.py +5 -5
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/mglsadf.py +15 -8
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/mlpg.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/mlsacheck.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/mpir2c.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/msvq.py +3 -7
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/ndps2c.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/norm0.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/par2lar.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/par2lpc.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/pca.py +5 -5
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/phase.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/pitch.py +9 -9
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/plp.py +6 -6
- diffsptk-2.2.0/diffsptk/modules/pnorm.py +87 -0
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/pol_root.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/poledf.py +8 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/pqmf.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/quantize.py +4 -4
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/rlevdur.py +3 -3
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/rmse.py +4 -4
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/root_pol.py +4 -4
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/smcep.py +3 -3
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/snr.py +4 -4
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/spec.py +6 -6
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/stft.py +3 -4
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/ulaw.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/unframe.py +3 -3
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/vq.py +3 -7
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/window.py +22 -12
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/yingram.py +3 -3
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/zcross.py +13 -7
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/modules/zerodf.py +2 -2
- diffsptk-2.2.0/diffsptk/version.py +1 -0
- {diffsptk-2.0.0 → diffsptk-2.2.0}/pyproject.toml +16 -10
- diffsptk-2.0.0/.github/workflows/ci.yml +0 -57
- diffsptk-2.0.0/.github/workflows/stale.yml +0 -23
- diffsptk-2.0.0/Makefile +0 -122
- diffsptk-2.0.0/UPLOAD +0 -18
- diffsptk-2.0.0/codecov.yml +0 -11
- diffsptk-2.0.0/diffsptk/version.py +0 -1
- {diffsptk-2.0.0 → diffsptk-2.2.0}/LICENSE +0 -0
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/__init__.py +0 -0
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/misc/__init__.py +0 -0
- {diffsptk-2.0.0 → diffsptk-2.2.0}/diffsptk/misc/signals.py +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use this software, please cite it as below."
|
|
3
|
+
authors:
|
|
4
|
+
- family-names: "SPTK Working Group"
|
|
5
|
+
title: "diffsptk"
|
|
6
|
+
url: "https://github.com/sp-nitech/diffsptk"
|
|
7
|
+
preferred-citation:
|
|
8
|
+
type: conference-paper
|
|
9
|
+
title: "SPTK4: An open-source software toolkit for speech signal processing"
|
|
10
|
+
authors:
|
|
11
|
+
- family-names: "Yoshimura"
|
|
12
|
+
given-names: "Takenori"
|
|
13
|
+
- family-names: "Fujimoto"
|
|
14
|
+
given-names: "Takato"
|
|
15
|
+
- family-names: "Oura"
|
|
16
|
+
given-names: "Keiichiro"
|
|
17
|
+
- family-names: "Tokuda"
|
|
18
|
+
given-names: "Keiichi"
|
|
19
|
+
collection-title: "12th ISCA Speech Synthesis Workshop"
|
|
20
|
+
collection-type: proceedings
|
|
21
|
+
doi: 10.21437/SSW.2023-33
|
|
22
|
+
month: 8
|
|
23
|
+
start: 211
|
|
24
|
+
end: 217
|
|
25
|
+
year: 2023
|
|
26
|
+
url: "https://www.isca-archive.org/ssw_2023/yoshimura23_ssw.pdf"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: diffsptk
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0
|
|
4
4
|
Summary: Speech signal processing modules for machine learning
|
|
5
5
|
Project-URL: Homepage, https://sp-tk.sourceforge.net/
|
|
6
6
|
Project-URL: Documentation, https://sp-nitech.github.io/diffsptk/latest/
|
|
@@ -13,23 +13,27 @@ Keywords: dsp,pytorch,signal processing,sptk
|
|
|
13
13
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
14
|
Classifier: Programming Language :: Python
|
|
15
15
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.9
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.10
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
-
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
21
|
Requires-Dist: librosa>=0.10.1
|
|
22
|
-
Requires-Dist: numpy
|
|
22
|
+
Requires-Dist: numpy<2.0.0,>=1.20.3
|
|
23
|
+
Requires-Dist: scipy<1.14.0,>=1.5.4
|
|
23
24
|
Requires-Dist: soundfile>=0.10.2
|
|
24
|
-
Requires-Dist: torch>=
|
|
25
|
-
Requires-Dist: torchaudio>=0.
|
|
25
|
+
Requires-Dist: torch>=2.0.0
|
|
26
|
+
Requires-Dist: torchaudio>=2.0.1
|
|
27
|
+
Requires-Dist: torchcomp>=0.1.0
|
|
26
28
|
Requires-Dist: torchcrepe>=0.0.21
|
|
27
29
|
Requires-Dist: torchlpc>=0.2.0
|
|
28
|
-
Requires-Dist:
|
|
30
|
+
Requires-Dist: tqdm>=4.15.0
|
|
31
|
+
Requires-Dist: vector-quantize-pytorch>=1.14.9
|
|
29
32
|
Provides-Extra: dev
|
|
30
33
|
Requires-Dist: build; extra == 'dev'
|
|
31
|
-
Requires-Dist:
|
|
34
|
+
Requires-Dist: docstrfmt; extra == 'dev'
|
|
32
35
|
Requires-Dist: isort; extra == 'dev'
|
|
36
|
+
Requires-Dist: mdformat; extra == 'dev'
|
|
33
37
|
Requires-Dist: numpydoc; extra == 'dev'
|
|
34
38
|
Requires-Dist: pydata-sphinx-theme; extra == 'dev'
|
|
35
39
|
Requires-Dist: pytest; extra == 'dev'
|
|
@@ -39,49 +43,49 @@ Requires-Dist: sphinx; extra == 'dev'
|
|
|
39
43
|
Requires-Dist: twine; extra == 'dev'
|
|
40
44
|
Description-Content-Type: text/markdown
|
|
41
45
|
|
|
42
|
-
diffsptk
|
|
43
|
-
|
|
46
|
+
# diffsptk
|
|
47
|
+
|
|
44
48
|
*diffsptk* is a differentiable version of [SPTK](https://github.com/sp-nitech/SPTK) based on the PyTorch framework.
|
|
45
49
|
|
|
46
50
|
[](https://sp-nitech.github.io/diffsptk/latest/)
|
|
47
|
-
[](https://sp-nitech.github.io/diffsptk/2.
|
|
51
|
+
[](https://sp-nitech.github.io/diffsptk/2.2.0/)
|
|
48
52
|
[](https://pepy.tech/project/diffsptk)
|
|
49
53
|
[](https://pypi.python.org/pypi/diffsptk)
|
|
50
|
-
[](https://pypi.python.org/pypi/diffsptk)
|
|
51
55
|
[](https://pypi.python.org/pypi/diffsptk)
|
|
52
56
|
[](https://app.codecov.io/gh/sp-nitech/diffsptk)
|
|
53
57
|
[](https://github.com/sp-nitech/diffsptk/blob/master/LICENSE)
|
|
54
58
|
[](https://github.com/sp-nitech/diffsptk/actions)
|
|
55
59
|
[](https://github.com/astral-sh/ruff)
|
|
56
60
|
|
|
61
|
+
## Requirements
|
|
57
62
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
- Python 3.8+
|
|
61
|
-
- PyTorch 1.11.0+
|
|
63
|
+
- Python 3.9+
|
|
64
|
+
- PyTorch 2.0.0+
|
|
62
65
|
|
|
66
|
+
## Documentation
|
|
63
67
|
|
|
64
|
-
Documentation
|
|
65
|
-
-------------
|
|
66
68
|
- See [this page](https://sp-nitech.github.io/diffsptk/latest/) for a reference manual.
|
|
67
69
|
- Our [paper](https://www.isca-speech.org/archive/ssw_2023/yoshimura23_ssw.html) is available on the ISCA Archive.
|
|
68
70
|
|
|
71
|
+
## Installation
|
|
69
72
|
|
|
70
|
-
Installation
|
|
71
|
-
------------
|
|
72
73
|
The latest stable release can be installed through PyPI by running
|
|
74
|
+
|
|
73
75
|
```sh
|
|
74
76
|
pip install diffsptk
|
|
75
77
|
```
|
|
78
|
+
|
|
76
79
|
The development release can be installed from the master branch:
|
|
80
|
+
|
|
77
81
|
```sh
|
|
78
82
|
pip install git+https://github.com/sp-nitech/diffsptk.git@master
|
|
79
83
|
```
|
|
80
84
|
|
|
85
|
+
## Examples
|
|
81
86
|
|
|
82
|
-
Examples
|
|
83
|
-
--------
|
|
84
87
|
### Mel-cepstral analysis and synthesis
|
|
88
|
+
|
|
85
89
|
```python
|
|
86
90
|
import diffsptk
|
|
87
91
|
|
|
@@ -103,7 +107,7 @@ mcep = diffsptk.MelCepstralAnalysis(cep_order=M, fft_length=n_fft, alpha=alpha,
|
|
|
103
107
|
mc = mcep(X)
|
|
104
108
|
|
|
105
109
|
# Reconstruct x.
|
|
106
|
-
mlsa = diffsptk.MLSA(filter_order=M, frame_period=fp, alpha=alpha, taylor_order=
|
|
110
|
+
mlsa = diffsptk.MLSA(filter_order=M, frame_period=fp, alpha=alpha, taylor_order=20)
|
|
107
111
|
x_hat = mlsa(mlsa(x, -mc), mc)
|
|
108
112
|
|
|
109
113
|
# Write reconstructed waveform.
|
|
@@ -131,7 +135,43 @@ diffsptk.write("voiced.wav", x_voiced, sr)
|
|
|
131
135
|
diffsptk.write("unvoiced.wav", x_unvoiced, sr)
|
|
132
136
|
```
|
|
133
137
|
|
|
138
|
+
### LPC analysis and synthesis
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
import diffsptk
|
|
142
|
+
|
|
143
|
+
fl = 400 # Frame length.
|
|
144
|
+
fp = 80 # Frame period.
|
|
145
|
+
M = 24 # LPC dimensions.
|
|
146
|
+
|
|
147
|
+
# Read waveform.
|
|
148
|
+
x, sr = diffsptk.read("assets/data.wav")
|
|
149
|
+
|
|
150
|
+
# Estimate LPC of x.
|
|
151
|
+
frame = diffsptk.Frame(frame_length=fl, frame_period=fp)
|
|
152
|
+
window = diffsptk.Window(in_length=fl)
|
|
153
|
+
lpc = diffsptk.LPC(frame_length=fl, lpc_order=M, eps=1e-6)
|
|
154
|
+
a = lpc(window(frame(x)))
|
|
155
|
+
|
|
156
|
+
# Convert to inverse filter coefficients.
|
|
157
|
+
norm0 = diffsptk.AllPoleToAllZeroDigitalFilterCoefficients(filter_order=M)
|
|
158
|
+
b = norm0(a)
|
|
159
|
+
|
|
160
|
+
# Reconstruct x.
|
|
161
|
+
zerodf = diffsptk.AllZeroDigitalFilter(filter_order=M, frame_period=fp)
|
|
162
|
+
poledf = diffsptk.AllPoleDigitalFilter(filter_order=M, frame_period=fp)
|
|
163
|
+
x_hat = poledf(zerodf(x, b), a)
|
|
164
|
+
|
|
165
|
+
# Write reconstructed waveform.
|
|
166
|
+
diffsptk.write("reconst.wav", x_hat, sr)
|
|
167
|
+
|
|
168
|
+
# Compute error.
|
|
169
|
+
error = (x_hat - x).abs().sum()
|
|
170
|
+
print(error)
|
|
171
|
+
```
|
|
172
|
+
|
|
134
173
|
### Mel-spectrogram, MFCC, and PLP extraction
|
|
174
|
+
|
|
135
175
|
```python
|
|
136
176
|
import diffsptk
|
|
137
177
|
|
|
@@ -148,7 +188,7 @@ x, sr = diffsptk.read("assets/data.wav")
|
|
|
148
188
|
stft = diffsptk.STFT(frame_length=fl, frame_period=fp, fft_length=n_fft)
|
|
149
189
|
X = stft(x)
|
|
150
190
|
|
|
151
|
-
# Extract mel-spectrogram.
|
|
191
|
+
# Extract log mel-spectrogram.
|
|
152
192
|
fbank = diffsptk.MelFilterBankAnalysis(
|
|
153
193
|
n_channel=n_channel,
|
|
154
194
|
fft_length=n_fft,
|
|
@@ -179,6 +219,7 @@ print(Y.shape)
|
|
|
179
219
|
```
|
|
180
220
|
|
|
181
221
|
### Subband decomposition
|
|
222
|
+
|
|
182
223
|
```python
|
|
183
224
|
import diffsptk
|
|
184
225
|
|
|
@@ -191,12 +232,12 @@ x, sr = diffsptk.read("assets/data.wav")
|
|
|
191
232
|
# Decompose x.
|
|
192
233
|
pqmf = diffsptk.PQMF(K, M)
|
|
193
234
|
decimate = diffsptk.Decimation(K)
|
|
194
|
-
y = decimate(pqmf(x)
|
|
235
|
+
y = decimate(pqmf(x))
|
|
195
236
|
|
|
196
237
|
# Reconstruct x.
|
|
197
238
|
interpolate = diffsptk.Interpolation(K)
|
|
198
239
|
ipqmf = diffsptk.IPQMF(K, M)
|
|
199
|
-
x_hat = ipqmf(interpolate(K * y
|
|
240
|
+
x_hat = ipqmf(interpolate(K * y)).reshape(-1)
|
|
200
241
|
|
|
201
242
|
# Write reconstructed waveform.
|
|
202
243
|
diffsptk.write("reconst.wav", x_hat, sr)
|
|
@@ -207,6 +248,7 @@ print(error)
|
|
|
207
248
|
```
|
|
208
249
|
|
|
209
250
|
### Constant-Q transform
|
|
251
|
+
|
|
210
252
|
```python
|
|
211
253
|
import diffsptk
|
|
212
254
|
import librosa # This is to get sample audio.
|
|
@@ -234,7 +276,34 @@ error = (x_hat - x).abs().sum()
|
|
|
234
276
|
print(error)
|
|
235
277
|
```
|
|
236
278
|
|
|
279
|
+
### Modified discrete cosine transform
|
|
280
|
+
|
|
281
|
+
```python
|
|
282
|
+
import diffsptk
|
|
283
|
+
|
|
284
|
+
fl = 512 # Frame length.
|
|
285
|
+
|
|
286
|
+
# Read waveform.
|
|
287
|
+
x, sr = diffsptk.read("assets/data.wav")
|
|
288
|
+
|
|
289
|
+
# Transform x.
|
|
290
|
+
mdct = diffsptk.MDCT(fl)
|
|
291
|
+
c = mdct(x)
|
|
292
|
+
|
|
293
|
+
# Reconstruct x.
|
|
294
|
+
imdct = diffpstk.IMDCT(fl)
|
|
295
|
+
x_hat = imdct(c, out_length=x.size(0))
|
|
296
|
+
|
|
297
|
+
# Write reconstructed waveform.
|
|
298
|
+
diffsptk.write("reconst.wav", x_hat, sr)
|
|
299
|
+
|
|
300
|
+
# Compute error.
|
|
301
|
+
error = (x_hat - x).abs().sum()
|
|
302
|
+
print(error)
|
|
303
|
+
```
|
|
304
|
+
|
|
237
305
|
### Vector quantization
|
|
306
|
+
|
|
238
307
|
```python
|
|
239
308
|
import diffsptk
|
|
240
309
|
|
|
@@ -253,14 +322,12 @@ error = (x_hat - x).abs().sum()
|
|
|
253
322
|
print(error)
|
|
254
323
|
```
|
|
255
324
|
|
|
325
|
+
## License
|
|
256
326
|
|
|
257
|
-
License
|
|
258
|
-
-------
|
|
259
327
|
This software is released under the Apache License 2.0.
|
|
260
328
|
|
|
329
|
+
## Citation
|
|
261
330
|
|
|
262
|
-
Reference
|
|
263
|
-
---------
|
|
264
331
|
```bibtex
|
|
265
332
|
@InProceedings{sp-nitech2023sptk,
|
|
266
333
|
author = {Takenori Yoshimura and Takato Fujimoto and Keiichiro Oura and Keiichi Tokuda},
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
diffsptk
|
|
2
|
-
|
|
1
|
+
# diffsptk
|
|
2
|
+
|
|
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.2.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)
|
|
13
13
|
[](https://github.com/sp-nitech/diffsptk/actions)
|
|
14
14
|
[](https://github.com/astral-sh/ruff)
|
|
15
15
|
|
|
16
|
+
## Requirements
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
- Python 3.8+
|
|
20
|
-
- PyTorch 1.11.0+
|
|
18
|
+
- Python 3.9+
|
|
19
|
+
- PyTorch 2.0.0+
|
|
21
20
|
|
|
21
|
+
## Documentation
|
|
22
22
|
|
|
23
|
-
Documentation
|
|
24
|
-
-------------
|
|
25
23
|
- See [this page](https://sp-nitech.github.io/diffsptk/latest/) for a reference manual.
|
|
26
24
|
- Our [paper](https://www.isca-speech.org/archive/ssw_2023/yoshimura23_ssw.html) is available on the ISCA Archive.
|
|
27
25
|
|
|
26
|
+
## Installation
|
|
28
27
|
|
|
29
|
-
Installation
|
|
30
|
-
------------
|
|
31
28
|
The latest stable release can be installed through PyPI by running
|
|
29
|
+
|
|
32
30
|
```sh
|
|
33
31
|
pip install diffsptk
|
|
34
32
|
```
|
|
33
|
+
|
|
35
34
|
The development release can be installed from the master branch:
|
|
35
|
+
|
|
36
36
|
```sh
|
|
37
37
|
pip install git+https://github.com/sp-nitech/diffsptk.git@master
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
+
## Examples
|
|
40
41
|
|
|
41
|
-
Examples
|
|
42
|
-
--------
|
|
43
42
|
### Mel-cepstral analysis and synthesis
|
|
43
|
+
|
|
44
44
|
```python
|
|
45
45
|
import diffsptk
|
|
46
46
|
|
|
@@ -62,7 +62,7 @@ mcep = diffsptk.MelCepstralAnalysis(cep_order=M, fft_length=n_fft, alpha=alpha,
|
|
|
62
62
|
mc = mcep(X)
|
|
63
63
|
|
|
64
64
|
# Reconstruct x.
|
|
65
|
-
mlsa = diffsptk.MLSA(filter_order=M, frame_period=fp, alpha=alpha, taylor_order=
|
|
65
|
+
mlsa = diffsptk.MLSA(filter_order=M, frame_period=fp, alpha=alpha, taylor_order=20)
|
|
66
66
|
x_hat = mlsa(mlsa(x, -mc), mc)
|
|
67
67
|
|
|
68
68
|
# Write reconstructed waveform.
|
|
@@ -90,7 +90,43 @@ diffsptk.write("voiced.wav", x_voiced, sr)
|
|
|
90
90
|
diffsptk.write("unvoiced.wav", x_unvoiced, sr)
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
+
### LPC analysis and synthesis
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
import diffsptk
|
|
97
|
+
|
|
98
|
+
fl = 400 # Frame length.
|
|
99
|
+
fp = 80 # Frame period.
|
|
100
|
+
M = 24 # LPC dimensions.
|
|
101
|
+
|
|
102
|
+
# Read waveform.
|
|
103
|
+
x, sr = diffsptk.read("assets/data.wav")
|
|
104
|
+
|
|
105
|
+
# Estimate LPC of x.
|
|
106
|
+
frame = diffsptk.Frame(frame_length=fl, frame_period=fp)
|
|
107
|
+
window = diffsptk.Window(in_length=fl)
|
|
108
|
+
lpc = diffsptk.LPC(frame_length=fl, lpc_order=M, eps=1e-6)
|
|
109
|
+
a = lpc(window(frame(x)))
|
|
110
|
+
|
|
111
|
+
# Convert to inverse filter coefficients.
|
|
112
|
+
norm0 = diffsptk.AllPoleToAllZeroDigitalFilterCoefficients(filter_order=M)
|
|
113
|
+
b = norm0(a)
|
|
114
|
+
|
|
115
|
+
# Reconstruct x.
|
|
116
|
+
zerodf = diffsptk.AllZeroDigitalFilter(filter_order=M, frame_period=fp)
|
|
117
|
+
poledf = diffsptk.AllPoleDigitalFilter(filter_order=M, frame_period=fp)
|
|
118
|
+
x_hat = poledf(zerodf(x, b), a)
|
|
119
|
+
|
|
120
|
+
# Write reconstructed waveform.
|
|
121
|
+
diffsptk.write("reconst.wav", x_hat, sr)
|
|
122
|
+
|
|
123
|
+
# Compute error.
|
|
124
|
+
error = (x_hat - x).abs().sum()
|
|
125
|
+
print(error)
|
|
126
|
+
```
|
|
127
|
+
|
|
93
128
|
### Mel-spectrogram, MFCC, and PLP extraction
|
|
129
|
+
|
|
94
130
|
```python
|
|
95
131
|
import diffsptk
|
|
96
132
|
|
|
@@ -107,7 +143,7 @@ x, sr = diffsptk.read("assets/data.wav")
|
|
|
107
143
|
stft = diffsptk.STFT(frame_length=fl, frame_period=fp, fft_length=n_fft)
|
|
108
144
|
X = stft(x)
|
|
109
145
|
|
|
110
|
-
# Extract mel-spectrogram.
|
|
146
|
+
# Extract log mel-spectrogram.
|
|
111
147
|
fbank = diffsptk.MelFilterBankAnalysis(
|
|
112
148
|
n_channel=n_channel,
|
|
113
149
|
fft_length=n_fft,
|
|
@@ -138,6 +174,7 @@ print(Y.shape)
|
|
|
138
174
|
```
|
|
139
175
|
|
|
140
176
|
### Subband decomposition
|
|
177
|
+
|
|
141
178
|
```python
|
|
142
179
|
import diffsptk
|
|
143
180
|
|
|
@@ -150,12 +187,12 @@ x, sr = diffsptk.read("assets/data.wav")
|
|
|
150
187
|
# Decompose x.
|
|
151
188
|
pqmf = diffsptk.PQMF(K, M)
|
|
152
189
|
decimate = diffsptk.Decimation(K)
|
|
153
|
-
y = decimate(pqmf(x)
|
|
190
|
+
y = decimate(pqmf(x))
|
|
154
191
|
|
|
155
192
|
# Reconstruct x.
|
|
156
193
|
interpolate = diffsptk.Interpolation(K)
|
|
157
194
|
ipqmf = diffsptk.IPQMF(K, M)
|
|
158
|
-
x_hat = ipqmf(interpolate(K * y
|
|
195
|
+
x_hat = ipqmf(interpolate(K * y)).reshape(-1)
|
|
159
196
|
|
|
160
197
|
# Write reconstructed waveform.
|
|
161
198
|
diffsptk.write("reconst.wav", x_hat, sr)
|
|
@@ -166,6 +203,7 @@ print(error)
|
|
|
166
203
|
```
|
|
167
204
|
|
|
168
205
|
### Constant-Q transform
|
|
206
|
+
|
|
169
207
|
```python
|
|
170
208
|
import diffsptk
|
|
171
209
|
import librosa # This is to get sample audio.
|
|
@@ -193,7 +231,34 @@ error = (x_hat - x).abs().sum()
|
|
|
193
231
|
print(error)
|
|
194
232
|
```
|
|
195
233
|
|
|
234
|
+
### Modified discrete cosine transform
|
|
235
|
+
|
|
236
|
+
```python
|
|
237
|
+
import diffsptk
|
|
238
|
+
|
|
239
|
+
fl = 512 # Frame length.
|
|
240
|
+
|
|
241
|
+
# Read waveform.
|
|
242
|
+
x, sr = diffsptk.read("assets/data.wav")
|
|
243
|
+
|
|
244
|
+
# Transform x.
|
|
245
|
+
mdct = diffsptk.MDCT(fl)
|
|
246
|
+
c = mdct(x)
|
|
247
|
+
|
|
248
|
+
# Reconstruct x.
|
|
249
|
+
imdct = diffpstk.IMDCT(fl)
|
|
250
|
+
x_hat = imdct(c, out_length=x.size(0))
|
|
251
|
+
|
|
252
|
+
# Write reconstructed waveform.
|
|
253
|
+
diffsptk.write("reconst.wav", x_hat, sr)
|
|
254
|
+
|
|
255
|
+
# Compute error.
|
|
256
|
+
error = (x_hat - x).abs().sum()
|
|
257
|
+
print(error)
|
|
258
|
+
```
|
|
259
|
+
|
|
196
260
|
### Vector quantization
|
|
261
|
+
|
|
197
262
|
```python
|
|
198
263
|
import diffsptk
|
|
199
264
|
|
|
@@ -212,14 +277,12 @@ error = (x_hat - x).abs().sum()
|
|
|
212
277
|
print(error)
|
|
213
278
|
```
|
|
214
279
|
|
|
280
|
+
## License
|
|
215
281
|
|
|
216
|
-
License
|
|
217
|
-
-------
|
|
218
282
|
This software is released under the Apache License 2.0.
|
|
219
283
|
|
|
284
|
+
## Citation
|
|
220
285
|
|
|
221
|
-
Reference
|
|
222
|
-
---------
|
|
223
286
|
```bibtex
|
|
224
287
|
@InProceedings{sp-nitech2023sptk,
|
|
225
288
|
author = {Takenori Yoshimura and Takato Fujimoto and Keiichiro Oura and Keiichi Tokuda},
|