diffsptk 2.0.0__tar.gz → 2.5.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.5.0}/.gitignore +2 -3
- diffsptk-2.5.0/CITATION.cff +26 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/PKG-INFO +206 -39
- {diffsptk-2.0.0 → diffsptk-2.5.0}/README.md +188 -25
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/functional.py +563 -33
- diffsptk-2.5.0/diffsptk/misc/librosa/LICENSE +15 -0
- diffsptk-2.5.0/diffsptk/misc/librosa/__init__.py +2 -0
- diffsptk-2.5.0/diffsptk/misc/librosa/constantq.py +95 -0
- diffsptk-2.5.0/diffsptk/misc/librosa/filters.py +299 -0
- diffsptk-2.5.0/diffsptk/misc/librosa/util.py +172 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/misc/signals.py +5 -2
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/misc/utils.py +116 -16
- diffsptk-2.5.0/diffsptk/misc/world.py +113 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/__init__.py +43 -4
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/acorr.py +8 -8
- diffsptk-2.5.0/diffsptk/modules/acr2csm.py +124 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/alaw.py +2 -2
- diffsptk-2.5.0/diffsptk/modules/ap.py +549 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/b2mc.py +8 -2
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/c2acr.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/c2mpir.py +3 -3
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/c2ndps.py +7 -2
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/cdist.py +12 -13
- diffsptk-2.5.0/diffsptk/modules/chroma.py +131 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/cqt.py +23 -35
- diffsptk-2.5.0/diffsptk/modules/csm2acr.py +97 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/dct.py +35 -10
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/decimate.py +2 -5
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/delay.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/delta.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/dequantize.py +4 -4
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/df2.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/dfs.py +2 -2
- diffsptk-2.5.0/diffsptk/modules/dht.py +95 -0
- diffsptk-2.5.0/diffsptk/modules/drc.py +183 -0
- diffsptk-2.5.0/diffsptk/modules/dst.py +107 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/entropy.py +5 -5
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/excite.py +96 -23
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/fbank.py +9 -8
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/fftcep.py +7 -2
- diffsptk-2.5.0/diffsptk/modules/flux.py +106 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/frame.py +18 -7
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/freqt.py +7 -2
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/freqt2.py +9 -3
- diffsptk-2.5.0/diffsptk/modules/gammatone.py +225 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/gmm.py +211 -87
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/gnorm.py +10 -4
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/grpdelay.py +2 -2
- diffsptk-2.5.0/diffsptk/modules/hilbert.py +96 -0
- diffsptk-2.5.0/diffsptk/modules/hilbert2.py +105 -0
- diffsptk-2.5.0/diffsptk/modules/histogram.py +114 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/ialaw.py +2 -2
- diffsptk-2.5.0/diffsptk/modules/ica.py +181 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/icqt.py +25 -37
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/idct.py +15 -8
- diffsptk-2.5.0/diffsptk/modules/idht.py +88 -0
- diffsptk-2.5.0/diffsptk/modules/idst.py +88 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/ifreqt2.py +9 -3
- diffsptk-2.5.0/diffsptk/modules/igammatone.py +203 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/ignorm.py +8 -2
- diffsptk-2.5.0/diffsptk/modules/imdct.py +160 -0
- diffsptk-2.5.0/diffsptk/modules/imdst.py +73 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/imglsadf.py +7 -12
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/imsvq.py +7 -2
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/interpolate.py +2 -2
- diffsptk-2.5.0/diffsptk/modules/ipnorm.py +71 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/ipqmf.py +12 -3
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/istft.py +4 -4
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/iulaw.py +3 -3
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/ivq.py +7 -2
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/lar2par.py +2 -2
- diffsptk-2.5.0/diffsptk/modules/lbg.py +328 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/levdur.py +21 -7
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/linear_intpl.py +5 -5
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/lpc.py +11 -8
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/lpc2lsp.py +12 -6
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/lpc2par.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/lpccheck.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/lsp2lpc.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/lsp2sp.py +14 -6
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/lspcheck.py +6 -6
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/magic_intpl.py +6 -6
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/mc2b.py +8 -2
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/mcep.py +3 -3
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/mcpf.py +11 -5
- diffsptk-2.5.0/diffsptk/modules/mdct.py +163 -0
- diffsptk-2.5.0/diffsptk/modules/mdst.py +70 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/mfcc.py +6 -6
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/mgc2mgc.py +12 -7
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/mgc2sp.py +9 -9
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/mgcep.py +5 -5
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/mglsadf.py +236 -83
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/mlpg.py +5 -3
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/mlsacheck.py +9 -3
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/mpir2c.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/msvq.py +8 -7
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/ndps2c.py +7 -2
- diffsptk-2.5.0/diffsptk/modules/nmf.py +246 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/norm0.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/par2lar.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/par2lpc.py +2 -2
- diffsptk-2.5.0/diffsptk/modules/pca.py +211 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/phase.py +3 -3
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/pitch.py +112 -53
- diffsptk-2.5.0/diffsptk/modules/pitch_spec.py +185 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/plp.py +6 -6
- diffsptk-2.5.0/diffsptk/modules/pnorm.py +87 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/pol_root.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/poledf.py +9 -3
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/pqmf.py +12 -3
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/quantize.py +4 -4
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/rlevdur.py +3 -3
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/rmse.py +9 -13
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/root_pol.py +4 -4
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/smcep.py +9 -3
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/snr.py +4 -4
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/spec.py +7 -7
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/stft.py +4 -5
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/ulaw.py +2 -2
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/unframe.py +4 -4
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/vq.py +8 -7
- diffsptk-2.5.0/diffsptk/modules/wht.py +115 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/window.py +28 -13
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/yingram.py +3 -3
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/zcross.py +14 -8
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/modules/zerodf.py +3 -3
- diffsptk-2.5.0/diffsptk/version.py +1 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/pyproject.toml +33 -26
- 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/modules/ap.py +0 -338
- diffsptk-2.0.0/diffsptk/modules/lbg.py +0 -195
- diffsptk-2.0.0/diffsptk/modules/pca.py +0 -130
- diffsptk-2.0.0/diffsptk/version.py +0 -1
- {diffsptk-2.0.0 → diffsptk-2.5.0}/LICENSE +0 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/__init__.py +0 -0
- {diffsptk-2.0.0 → diffsptk-2.5.0}/diffsptk/misc/__init__.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.5.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,24 +13,28 @@ 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
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
18
16
|
Classifier: Programming Language :: Python :: 3.10
|
|
19
17
|
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Requires-
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Requires-Dist: numpy>=1.23.0
|
|
22
|
+
Requires-Dist: penn>=0.0.1
|
|
23
|
+
Requires-Dist: scipy>=1.12.0
|
|
23
24
|
Requires-Dist: soundfile>=0.10.2
|
|
24
|
-
Requires-Dist: torch>=
|
|
25
|
-
Requires-Dist: torchaudio>=
|
|
26
|
-
Requires-Dist:
|
|
27
|
-
Requires-Dist: torchlpc>=0.
|
|
28
|
-
Requires-Dist:
|
|
25
|
+
Requires-Dist: torch>=2.3.1
|
|
26
|
+
Requires-Dist: torchaudio>=2.3.1
|
|
27
|
+
Requires-Dist: torchcomp>=0.2.0
|
|
28
|
+
Requires-Dist: torchlpc>=0.6.0
|
|
29
|
+
Requires-Dist: tqdm>=4.63.0
|
|
30
|
+
Requires-Dist: vector-quantize-pytorch>=1.14.9
|
|
29
31
|
Provides-Extra: dev
|
|
30
32
|
Requires-Dist: build; extra == 'dev'
|
|
31
|
-
Requires-Dist:
|
|
32
|
-
Requires-Dist:
|
|
33
|
+
Requires-Dist: codespell; extra == 'dev'
|
|
34
|
+
Requires-Dist: docstrfmt; extra == 'dev'
|
|
35
|
+
Requires-Dist: mdformat; extra == 'dev'
|
|
33
36
|
Requires-Dist: numpydoc; extra == 'dev'
|
|
37
|
+
Requires-Dist: pkginfo; extra == 'dev'
|
|
34
38
|
Requires-Dist: pydata-sphinx-theme; extra == 'dev'
|
|
35
39
|
Requires-Dist: pytest; extra == 'dev'
|
|
36
40
|
Requires-Dist: pytest-cov; 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.5.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.10+
|
|
64
|
+
- PyTorch 2.3.1+
|
|
62
65
|
|
|
66
|
+
## Documentation
|
|
63
67
|
|
|
64
|
-
|
|
65
|
-
-------------
|
|
66
|
-
- See [this page](https://sp-nitech.github.io/diffsptk/latest/) for a reference manual.
|
|
68
|
+
- See [this page](https://sp-nitech.github.io/diffsptk/latest/) for the 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
|
|
|
@@ -99,11 +103,16 @@ X = stft(x)
|
|
|
99
103
|
|
|
100
104
|
# Estimate mel-cepstrum of x.
|
|
101
105
|
alpha = diffsptk.get_alpha(sr)
|
|
102
|
-
mcep = diffsptk.MelCepstralAnalysis(
|
|
106
|
+
mcep = diffsptk.MelCepstralAnalysis(
|
|
107
|
+
cep_order=M,
|
|
108
|
+
fft_length=n_fft,
|
|
109
|
+
alpha=alpha,
|
|
110
|
+
n_iter=10,
|
|
111
|
+
)
|
|
103
112
|
mc = mcep(X)
|
|
104
113
|
|
|
105
114
|
# Reconstruct x.
|
|
106
|
-
mlsa = diffsptk.MLSA(filter_order=M, frame_period=fp, alpha=alpha, taylor_order=
|
|
115
|
+
mlsa = diffsptk.MLSA(filter_order=M, frame_period=fp, alpha=alpha, taylor_order=20)
|
|
107
116
|
x_hat = mlsa(mlsa(x, -mc), mc)
|
|
108
117
|
|
|
109
118
|
# Write reconstructed waveform.
|
|
@@ -114,7 +123,14 @@ error = (x_hat - x).abs().sum()
|
|
|
114
123
|
print(error)
|
|
115
124
|
|
|
116
125
|
# Extract pitch of x.
|
|
117
|
-
pitch = diffsptk.Pitch(
|
|
126
|
+
pitch = diffsptk.Pitch(
|
|
127
|
+
frame_period=fp,
|
|
128
|
+
sample_rate=sr,
|
|
129
|
+
f_min=80,
|
|
130
|
+
f_max=180,
|
|
131
|
+
voicing_threshold=0.4,
|
|
132
|
+
out_format="pitch",
|
|
133
|
+
)
|
|
118
134
|
p = pitch(x)
|
|
119
135
|
|
|
120
136
|
# Generate excitation signal.
|
|
@@ -131,7 +147,107 @@ diffsptk.write("voiced.wav", x_voiced, sr)
|
|
|
131
147
|
diffsptk.write("unvoiced.wav", x_unvoiced, sr)
|
|
132
148
|
```
|
|
133
149
|
|
|
150
|
+
### WORLD analysis and mel-cepstral synthesis
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
import diffsptk
|
|
154
|
+
|
|
155
|
+
fp = 80 # Frame period.
|
|
156
|
+
n_fft = 1024 # FFT length.
|
|
157
|
+
M = 24 # Mel-cepstrum dimensions.
|
|
158
|
+
|
|
159
|
+
# Read waveform.
|
|
160
|
+
x, sr = diffsptk.read("assets/data.wav")
|
|
161
|
+
|
|
162
|
+
# Extract F0 of x, or prepare well-estimated F0.
|
|
163
|
+
pitch = diffsptk.Pitch(
|
|
164
|
+
frame_period=fp,
|
|
165
|
+
sample_rate=sr,
|
|
166
|
+
f_min=80,
|
|
167
|
+
f_max=180,
|
|
168
|
+
voicing_threshold=0.4,
|
|
169
|
+
out_format="f0",
|
|
170
|
+
)
|
|
171
|
+
f0 = pitch(x)
|
|
172
|
+
|
|
173
|
+
# Extract aperiodicity of x by D4C.
|
|
174
|
+
ap = diffsptk.Aperiodicity(
|
|
175
|
+
frame_period=fp,
|
|
176
|
+
sample_rate=sr,
|
|
177
|
+
fft_length=n_fft,
|
|
178
|
+
algorithm="d4c",
|
|
179
|
+
out_format="a",
|
|
180
|
+
)
|
|
181
|
+
A = ap(x, f0)
|
|
182
|
+
|
|
183
|
+
# Extract spectral envelope of x by CheapTrick.
|
|
184
|
+
pitch_spec = diffsptk.PitchAdaptiveSpectralAnalysis(
|
|
185
|
+
frame_period=fp,
|
|
186
|
+
sample_rate=sr,
|
|
187
|
+
fft_length=n_fft,
|
|
188
|
+
)
|
|
189
|
+
H = pitch_spec(x, f0)
|
|
190
|
+
|
|
191
|
+
# Estimate mel-cepstrum of x.
|
|
192
|
+
alpha = diffsptk.get_alpha(sr)
|
|
193
|
+
mcep = diffsptk.MelCepstralAnalysis(cep_order=M, fft_length=n_fft, alpha=alpha)
|
|
194
|
+
mc_a = mcep(A)
|
|
195
|
+
mc_h = mcep(H)
|
|
196
|
+
|
|
197
|
+
# Generate excitation signals.
|
|
198
|
+
excite = diffsptk.ExcitationGeneration(frame_period=fp, unvoiced_region="zeros")
|
|
199
|
+
p = (sr / f0).nan_to_num(posinf=0)
|
|
200
|
+
pulse = excite(p)
|
|
201
|
+
noise = diffsptk.nrand(len(pulse) - 1)
|
|
202
|
+
|
|
203
|
+
# Make mixed excitation signal and reconstruct x.
|
|
204
|
+
mlsa = diffsptk.MLSA(filter_order=M, frame_period=fp, alpha=alpha, taylor_order=20)
|
|
205
|
+
e_p = pulse - mlsa(pulse, mc_a)
|
|
206
|
+
e_a = mlsa(noise, mc_a)
|
|
207
|
+
e = e_p + e_a
|
|
208
|
+
x_hat = mlsa(e, mc_h)
|
|
209
|
+
|
|
210
|
+
# Write reconstructed waveform.
|
|
211
|
+
diffsptk.write("reconst.wav", x_hat, sr)
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### LPC analysis and synthesis
|
|
215
|
+
|
|
216
|
+
```python
|
|
217
|
+
import diffsptk
|
|
218
|
+
|
|
219
|
+
fl = 400 # Frame length.
|
|
220
|
+
fp = 80 # Frame period.
|
|
221
|
+
M = 24 # LPC dimensions.
|
|
222
|
+
|
|
223
|
+
# Read waveform.
|
|
224
|
+
x, sr = diffsptk.read("assets/data.wav")
|
|
225
|
+
|
|
226
|
+
# Estimate LPC of x.
|
|
227
|
+
frame = diffsptk.Frame(frame_length=fl, frame_period=fp)
|
|
228
|
+
window = diffsptk.Window(in_length=fl)
|
|
229
|
+
lpc = diffsptk.LPC(frame_length=fl, lpc_order=M, eps=1e-6)
|
|
230
|
+
a = lpc(window(frame(x)))
|
|
231
|
+
|
|
232
|
+
# Convert to inverse filter coefficients.
|
|
233
|
+
norm0 = diffsptk.AllPoleToAllZeroDigitalFilterCoefficients(filter_order=M)
|
|
234
|
+
b = norm0(a)
|
|
235
|
+
|
|
236
|
+
# Reconstruct x.
|
|
237
|
+
zerodf = diffsptk.AllZeroDigitalFilter(filter_order=M, frame_period=fp)
|
|
238
|
+
poledf = diffsptk.AllPoleDigitalFilter(filter_order=M, frame_period=fp)
|
|
239
|
+
x_hat = poledf(zerodf(x, b), a)
|
|
240
|
+
|
|
241
|
+
# Write reconstructed waveform.
|
|
242
|
+
diffsptk.write("reconst.wav", x_hat, sr)
|
|
243
|
+
|
|
244
|
+
# Compute error.
|
|
245
|
+
error = (x_hat - x).abs().sum()
|
|
246
|
+
print(error)
|
|
247
|
+
```
|
|
248
|
+
|
|
134
249
|
### Mel-spectrogram, MFCC, and PLP extraction
|
|
250
|
+
|
|
135
251
|
```python
|
|
136
252
|
import diffsptk
|
|
137
253
|
|
|
@@ -148,7 +264,7 @@ x, sr = diffsptk.read("assets/data.wav")
|
|
|
148
264
|
stft = diffsptk.STFT(frame_length=fl, frame_period=fp, fft_length=n_fft)
|
|
149
265
|
X = stft(x)
|
|
150
266
|
|
|
151
|
-
# Extract mel-spectrogram.
|
|
267
|
+
# Extract log mel-spectrogram.
|
|
152
268
|
fbank = diffsptk.MelFilterBankAnalysis(
|
|
153
269
|
n_channel=n_channel,
|
|
154
270
|
fft_length=n_fft,
|
|
@@ -179,6 +295,7 @@ print(Y.shape)
|
|
|
179
295
|
```
|
|
180
296
|
|
|
181
297
|
### Subband decomposition
|
|
298
|
+
|
|
182
299
|
```python
|
|
183
300
|
import diffsptk
|
|
184
301
|
|
|
@@ -191,12 +308,36 @@ x, sr = diffsptk.read("assets/data.wav")
|
|
|
191
308
|
# Decompose x.
|
|
192
309
|
pqmf = diffsptk.PQMF(K, M)
|
|
193
310
|
decimate = diffsptk.Decimation(K)
|
|
194
|
-
y = decimate(pqmf(x)
|
|
311
|
+
y = decimate(pqmf(x))
|
|
195
312
|
|
|
196
313
|
# Reconstruct x.
|
|
197
314
|
interpolate = diffsptk.Interpolation(K)
|
|
198
315
|
ipqmf = diffsptk.IPQMF(K, M)
|
|
199
|
-
x_hat = ipqmf(interpolate(K * y
|
|
316
|
+
x_hat = ipqmf(interpolate(K * y)).reshape(-1)
|
|
317
|
+
|
|
318
|
+
# Write reconstructed waveform.
|
|
319
|
+
diffsptk.write("reconst.wav", x_hat, sr)
|
|
320
|
+
|
|
321
|
+
# Compute error.
|
|
322
|
+
error = (x_hat - x).abs().sum()
|
|
323
|
+
print(error)
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### Gammatone filter bank analysis and synthesis
|
|
327
|
+
|
|
328
|
+
```python
|
|
329
|
+
import diffsptk
|
|
330
|
+
|
|
331
|
+
# Read waveform.
|
|
332
|
+
x, sr = diffsptk.read("assets/data.wav")
|
|
333
|
+
|
|
334
|
+
# Decompose x.
|
|
335
|
+
gammatone = diffsptk.GammatoneFilterBankAnalysis(sr)
|
|
336
|
+
y = gammatone(x)
|
|
337
|
+
|
|
338
|
+
# Reconstruct x.
|
|
339
|
+
igammatone = diffsptk.GammatoneFilterBankSynthesis(sr)
|
|
340
|
+
x_hat = igammatone(y).reshape(-1)
|
|
200
341
|
|
|
201
342
|
# Write reconstructed waveform.
|
|
202
343
|
diffsptk.write("reconst.wav", x_hat, sr)
|
|
@@ -207,6 +348,7 @@ print(error)
|
|
|
207
348
|
```
|
|
208
349
|
|
|
209
350
|
### Constant-Q transform
|
|
351
|
+
|
|
210
352
|
```python
|
|
211
353
|
import diffsptk
|
|
212
354
|
import librosa # This is to get sample audio.
|
|
@@ -234,7 +376,34 @@ error = (x_hat - x).abs().sum()
|
|
|
234
376
|
print(error)
|
|
235
377
|
```
|
|
236
378
|
|
|
379
|
+
### Modified discrete cosine transform
|
|
380
|
+
|
|
381
|
+
```python
|
|
382
|
+
import diffsptk
|
|
383
|
+
|
|
384
|
+
fl = 512 # Frame length.
|
|
385
|
+
|
|
386
|
+
# Read waveform.
|
|
387
|
+
x, sr = diffsptk.read("assets/data.wav")
|
|
388
|
+
|
|
389
|
+
# Transform x.
|
|
390
|
+
mdct = diffsptk.MDCT(fl)
|
|
391
|
+
c = mdct(x)
|
|
392
|
+
|
|
393
|
+
# Reconstruct x.
|
|
394
|
+
imdct = diffpstk.IMDCT(fl)
|
|
395
|
+
x_hat = imdct(c, out_length=x.size(0))
|
|
396
|
+
|
|
397
|
+
# Write reconstructed waveform.
|
|
398
|
+
diffsptk.write("reconst.wav", x_hat, sr)
|
|
399
|
+
|
|
400
|
+
# Compute error.
|
|
401
|
+
error = (x_hat - x).abs().sum()
|
|
402
|
+
print(error)
|
|
403
|
+
```
|
|
404
|
+
|
|
237
405
|
### Vector quantization
|
|
406
|
+
|
|
238
407
|
```python
|
|
239
408
|
import diffsptk
|
|
240
409
|
|
|
@@ -253,14 +422,12 @@ error = (x_hat - x).abs().sum()
|
|
|
253
422
|
print(error)
|
|
254
423
|
```
|
|
255
424
|
|
|
425
|
+
## License
|
|
256
426
|
|
|
257
|
-
License
|
|
258
|
-
-------
|
|
259
427
|
This software is released under the Apache License 2.0.
|
|
260
428
|
|
|
429
|
+
## Citation
|
|
261
430
|
|
|
262
|
-
Reference
|
|
263
|
-
---------
|
|
264
431
|
```bibtex
|
|
265
432
|
@InProceedings{sp-nitech2023sptk,
|
|
266
433
|
author = {Takenori Yoshimura and Takato Fujimoto and Keiichiro Oura and Keiichi Tokuda},
|