diffsptk 2.0.0__tar.gz → 2.1.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.
Files changed (111) hide show
  1. {diffsptk-2.0.0 → diffsptk-2.1.0}/.gitignore +1 -2
  2. diffsptk-2.1.0/CITATION.cff +26 -0
  3. {diffsptk-2.0.0 → diffsptk-2.1.0}/PKG-INFO +29 -24
  4. {diffsptk-2.0.0 → diffsptk-2.1.0}/README.md +22 -20
  5. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/functional.py +138 -2
  6. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/misc/utils.py +19 -7
  7. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/__init__.py +6 -0
  8. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/acorr.py +7 -7
  9. diffsptk-2.1.0/diffsptk/modules/acr2csm.py +118 -0
  10. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/alaw.py +2 -2
  11. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/ap.py +8 -8
  12. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/b2mc.py +2 -2
  13. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/c2acr.py +2 -2
  14. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/c2mpir.py +2 -2
  15. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/c2ndps.py +2 -2
  16. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/cdist.py +2 -2
  17. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/cqt.py +3 -3
  18. diffsptk-2.1.0/diffsptk/modules/csm2acr.py +92 -0
  19. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/dct.py +2 -2
  20. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/decimate.py +2 -2
  21. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/delay.py +2 -2
  22. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/delta.py +2 -2
  23. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/dequantize.py +4 -4
  24. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/df2.py +2 -2
  25. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/dfs.py +2 -2
  26. diffsptk-2.1.0/diffsptk/modules/drc.py +183 -0
  27. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/entropy.py +5 -5
  28. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/excite.py +4 -4
  29. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/fbank.py +5 -5
  30. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/fftcep.py +2 -2
  31. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/frame.py +2 -2
  32. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/freqt.py +2 -2
  33. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/freqt2.py +2 -2
  34. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/gmm.py +4 -4
  35. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/gnorm.py +2 -2
  36. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/grpdelay.py +2 -2
  37. diffsptk-2.1.0/diffsptk/modules/histogram.py +114 -0
  38. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/ialaw.py +2 -2
  39. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/icqt.py +5 -5
  40. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/idct.py +2 -2
  41. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/ifreqt2.py +2 -2
  42. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/ignorm.py +2 -2
  43. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/imglsadf.py +2 -2
  44. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/imsvq.py +2 -2
  45. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/interpolate.py +2 -2
  46. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/ipqmf.py +2 -2
  47. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/istft.py +2 -2
  48. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/iulaw.py +3 -3
  49. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/ivq.py +2 -2
  50. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/lar2par.py +2 -2
  51. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/lbg.py +2 -2
  52. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/levdur.py +3 -2
  53. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/linear_intpl.py +4 -4
  54. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/lpc.py +2 -2
  55. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/lpc2lsp.py +6 -6
  56. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/lpc2par.py +2 -2
  57. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/lpccheck.py +2 -2
  58. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/lsp2lpc.py +2 -2
  59. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/lsp2sp.py +6 -6
  60. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/lspcheck.py +2 -2
  61. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/magic_intpl.py +5 -5
  62. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/mc2b.py +2 -2
  63. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/mcep.py +3 -3
  64. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/mcpf.py +2 -2
  65. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/mfcc.py +6 -6
  66. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/mgc2mgc.py +7 -7
  67. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/mgc2sp.py +9 -9
  68. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/mgcep.py +5 -5
  69. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/mglsadf.py +11 -7
  70. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/mlpg.py +2 -2
  71. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/mlsacheck.py +2 -2
  72. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/mpir2c.py +2 -2
  73. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/msvq.py +2 -2
  74. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/ndps2c.py +2 -2
  75. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/norm0.py +2 -2
  76. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/par2lar.py +2 -2
  77. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/par2lpc.py +2 -2
  78. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/pca.py +5 -5
  79. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/phase.py +2 -2
  80. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/pitch.py +9 -9
  81. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/plp.py +6 -6
  82. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/pol_root.py +2 -2
  83. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/poledf.py +8 -2
  84. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/pqmf.py +2 -2
  85. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/quantize.py +4 -4
  86. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/rlevdur.py +3 -3
  87. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/rmse.py +2 -2
  88. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/root_pol.py +4 -4
  89. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/smcep.py +3 -3
  90. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/snr.py +2 -2
  91. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/spec.py +6 -6
  92. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/stft.py +2 -2
  93. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/ulaw.py +2 -2
  94. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/unframe.py +3 -3
  95. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/vq.py +2 -2
  96. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/window.py +11 -11
  97. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/yingram.py +3 -3
  98. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/zcross.py +13 -7
  99. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/modules/zerodf.py +2 -2
  100. diffsptk-2.1.0/diffsptk/version.py +1 -0
  101. {diffsptk-2.0.0 → diffsptk-2.1.0}/pyproject.toml +10 -4
  102. diffsptk-2.0.0/.github/workflows/ci.yml +0 -57
  103. diffsptk-2.0.0/.github/workflows/stale.yml +0 -23
  104. diffsptk-2.0.0/Makefile +0 -122
  105. diffsptk-2.0.0/UPLOAD +0 -18
  106. diffsptk-2.0.0/codecov.yml +0 -11
  107. diffsptk-2.0.0/diffsptk/version.py +0 -1
  108. {diffsptk-2.0.0 → diffsptk-2.1.0}/LICENSE +0 -0
  109. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/__init__.py +0 -0
  110. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/misc/__init__.py +0 -0
  111. {diffsptk-2.0.0 → diffsptk-2.1.0}/diffsptk/misc/signals.py +0 -0
@@ -10,8 +10,7 @@ coverage.xml
10
10
  _build/
11
11
 
12
12
  # tools
13
- tools/SPTK/
14
- tools/taplo/
13
+ tools/**/
15
14
 
16
15
  # misc
17
16
  __pycache__/
@@ -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.3
1
+ Metadata-Version: 2.4
2
2
  Name: diffsptk
3
- Version: 2.0.0
3
+ Version: 2.1.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/
@@ -17,19 +17,22 @@ Classifier: Programming Language :: Python :: 3.8
17
17
  Classifier: Programming Language :: Python :: 3.9
18
18
  Classifier: Programming Language :: Python :: 3.10
19
19
  Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
20
21
  Requires-Python: >=3.8
21
22
  Requires-Dist: librosa>=0.10.1
22
- Requires-Dist: numpy
23
+ Requires-Dist: numpy<2.0.0
24
+ Requires-Dist: scipy<1.14.0
23
25
  Requires-Dist: soundfile>=0.10.2
24
26
  Requires-Dist: torch>=1.11.0
25
27
  Requires-Dist: torchaudio>=0.11.0
28
+ Requires-Dist: torchcomp>=0.1.1
26
29
  Requires-Dist: torchcrepe>=0.0.21
27
30
  Requires-Dist: torchlpc>=0.2.0
28
31
  Requires-Dist: vector-quantize-pytorch<=1.12.12,>=0.8.0
29
32
  Provides-Extra: dev
30
33
  Requires-Dist: build; extra == 'dev'
31
- Requires-Dist: grayskull; extra == 'dev'
32
34
  Requires-Dist: isort; extra == 'dev'
35
+ Requires-Dist: mdformat; extra == 'dev'
33
36
  Requires-Dist: numpydoc; extra == 'dev'
34
37
  Requires-Dist: pydata-sphinx-theme; extra == 'dev'
35
38
  Requires-Dist: pytest; extra == 'dev'
@@ -39,49 +42,49 @@ Requires-Dist: sphinx; extra == 'dev'
39
42
  Requires-Dist: twine; extra == 'dev'
40
43
  Description-Content-Type: text/markdown
41
44
 
42
- diffsptk
43
- ========
45
+ # diffsptk
46
+
44
47
  *diffsptk* is a differentiable version of [SPTK](https://github.com/sp-nitech/SPTK) based on the PyTorch framework.
45
48
 
46
49
  [![Latest Manual](https://img.shields.io/badge/docs-latest-blue.svg)](https://sp-nitech.github.io/diffsptk/latest/)
47
- [![Stable Manual](https://img.shields.io/badge/docs-stable-blue.svg)](https://sp-nitech.github.io/diffsptk/2.0.0/)
50
+ [![Stable Manual](https://img.shields.io/badge/docs-stable-blue.svg)](https://sp-nitech.github.io/diffsptk/2.1.0/)
48
51
  [![Downloads](https://static.pepy.tech/badge/diffsptk)](https://pepy.tech/project/diffsptk)
49
52
  [![Python Version](https://img.shields.io/pypi/pyversions/diffsptk.svg)](https://pypi.python.org/pypi/diffsptk)
50
- [![PyTorch Version](https://img.shields.io/badge/pytorch-1.11.0%20%7C%202.2.1-orange.svg)](https://pypi.python.org/pypi/diffsptk)
53
+ [![PyTorch Version](https://img.shields.io/badge/pytorch-1.12.0%20%7C%202.3.1-orange.svg)](https://pypi.python.org/pypi/diffsptk)
51
54
  [![PyPI Version](https://img.shields.io/pypi/v/diffsptk.svg)](https://pypi.python.org/pypi/diffsptk)
52
55
  [![Codecov](https://codecov.io/gh/sp-nitech/diffsptk/branch/master/graph/badge.svg)](https://app.codecov.io/gh/sp-nitech/diffsptk)
53
56
  [![License](https://img.shields.io/github/license/sp-nitech/diffsptk.svg)](https://github.com/sp-nitech/diffsptk/blob/master/LICENSE)
54
57
  [![GitHub Actions](https://github.com/sp-nitech/diffsptk/workflows/package/badge.svg)](https://github.com/sp-nitech/diffsptk/actions)
55
58
  [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
56
59
 
60
+ ## Requirements
57
61
 
58
- Requirements
59
- ------------
60
62
  - Python 3.8+
61
- - PyTorch 1.11.0+
63
+ - PyTorch 1.12.0+
62
64
 
65
+ ## Documentation
63
66
 
64
- Documentation
65
- -------------
66
67
  - See [this page](https://sp-nitech.github.io/diffsptk/latest/) for a reference manual.
67
68
  - Our [paper](https://www.isca-speech.org/archive/ssw_2023/yoshimura23_ssw.html) is available on the ISCA Archive.
68
69
 
70
+ ## Installation
69
71
 
70
- Installation
71
- ------------
72
72
  The latest stable release can be installed through PyPI by running
73
+
73
74
  ```sh
74
75
  pip install diffsptk
75
76
  ```
77
+
76
78
  The development release can be installed from the master branch:
79
+
77
80
  ```sh
78
81
  pip install git+https://github.com/sp-nitech/diffsptk.git@master
79
82
  ```
80
83
 
84
+ ## Examples
81
85
 
82
- Examples
83
- --------
84
86
  ### Mel-cepstral analysis and synthesis
87
+
85
88
  ```python
86
89
  import diffsptk
87
90
 
@@ -132,6 +135,7 @@ diffsptk.write("unvoiced.wav", x_unvoiced, sr)
132
135
  ```
133
136
 
134
137
  ### Mel-spectrogram, MFCC, and PLP extraction
138
+
135
139
  ```python
136
140
  import diffsptk
137
141
 
@@ -149,7 +153,7 @@ stft = diffsptk.STFT(frame_length=fl, frame_period=fp, fft_length=n_fft)
149
153
  X = stft(x)
150
154
 
151
155
  # Extract mel-spectrogram.
152
- fbank = diffsptk.MelFilterBankAnalysis(
156
+ fbank = diffsptk.FBANK(
153
157
  n_channel=n_channel,
154
158
  fft_length=n_fft,
155
159
  sample_rate=sr,
@@ -179,6 +183,7 @@ print(Y.shape)
179
183
  ```
180
184
 
181
185
  ### Subband decomposition
186
+
182
187
  ```python
183
188
  import diffsptk
184
189
 
@@ -191,12 +196,12 @@ x, sr = diffsptk.read("assets/data.wav")
191
196
  # Decompose x.
192
197
  pqmf = diffsptk.PQMF(K, M)
193
198
  decimate = diffsptk.Decimation(K)
194
- y = decimate(pqmf(x), dim=-1)
199
+ y = decimate(pqmf(x))
195
200
 
196
201
  # Reconstruct x.
197
202
  interpolate = diffsptk.Interpolation(K)
198
203
  ipqmf = diffsptk.IPQMF(K, M)
199
- x_hat = ipqmf(interpolate(K * y, dim=-1)).reshape(-1)
204
+ x_hat = ipqmf(interpolate(K * y)).reshape(-1)
200
205
 
201
206
  # Write reconstructed waveform.
202
207
  diffsptk.write("reconst.wav", x_hat, sr)
@@ -207,6 +212,7 @@ print(error)
207
212
  ```
208
213
 
209
214
  ### Constant-Q transform
215
+
210
216
  ```python
211
217
  import diffsptk
212
218
  import librosa # This is to get sample audio.
@@ -235,6 +241,7 @@ print(error)
235
241
  ```
236
242
 
237
243
  ### Vector quantization
244
+
238
245
  ```python
239
246
  import diffsptk
240
247
 
@@ -253,14 +260,12 @@ error = (x_hat - x).abs().sum()
253
260
  print(error)
254
261
  ```
255
262
 
263
+ ## License
256
264
 
257
- License
258
- -------
259
265
  This software is released under the Apache License 2.0.
260
266
 
267
+ ## Citation
261
268
 
262
- Reference
263
- ---------
264
269
  ```bibtex
265
270
  @InProceedings{sp-nitech2023sptk,
266
271
  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
  [![Latest Manual](https://img.shields.io/badge/docs-latest-blue.svg)](https://sp-nitech.github.io/diffsptk/latest/)
6
- [![Stable Manual](https://img.shields.io/badge/docs-stable-blue.svg)](https://sp-nitech.github.io/diffsptk/2.0.0/)
6
+ [![Stable Manual](https://img.shields.io/badge/docs-stable-blue.svg)](https://sp-nitech.github.io/diffsptk/2.1.0/)
7
7
  [![Downloads](https://static.pepy.tech/badge/diffsptk)](https://pepy.tech/project/diffsptk)
8
8
  [![Python Version](https://img.shields.io/pypi/pyversions/diffsptk.svg)](https://pypi.python.org/pypi/diffsptk)
9
- [![PyTorch Version](https://img.shields.io/badge/pytorch-1.11.0%20%7C%202.2.1-orange.svg)](https://pypi.python.org/pypi/diffsptk)
9
+ [![PyTorch Version](https://img.shields.io/badge/pytorch-1.12.0%20%7C%202.3.1-orange.svg)](https://pypi.python.org/pypi/diffsptk)
10
10
  [![PyPI Version](https://img.shields.io/pypi/v/diffsptk.svg)](https://pypi.python.org/pypi/diffsptk)
11
11
  [![Codecov](https://codecov.io/gh/sp-nitech/diffsptk/branch/master/graph/badge.svg)](https://app.codecov.io/gh/sp-nitech/diffsptk)
12
12
  [![License](https://img.shields.io/github/license/sp-nitech/diffsptk.svg)](https://github.com/sp-nitech/diffsptk/blob/master/LICENSE)
13
13
  [![GitHub Actions](https://github.com/sp-nitech/diffsptk/workflows/package/badge.svg)](https://github.com/sp-nitech/diffsptk/actions)
14
14
  [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
15
15
 
16
+ ## Requirements
16
17
 
17
- Requirements
18
- ------------
19
18
  - Python 3.8+
20
- - PyTorch 1.11.0+
19
+ - PyTorch 1.12.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
 
@@ -91,6 +91,7 @@ diffsptk.write("unvoiced.wav", x_unvoiced, sr)
91
91
  ```
92
92
 
93
93
  ### Mel-spectrogram, MFCC, and PLP extraction
94
+
94
95
  ```python
95
96
  import diffsptk
96
97
 
@@ -108,7 +109,7 @@ stft = diffsptk.STFT(frame_length=fl, frame_period=fp, fft_length=n_fft)
108
109
  X = stft(x)
109
110
 
110
111
  # Extract mel-spectrogram.
111
- fbank = diffsptk.MelFilterBankAnalysis(
112
+ fbank = diffsptk.FBANK(
112
113
  n_channel=n_channel,
113
114
  fft_length=n_fft,
114
115
  sample_rate=sr,
@@ -138,6 +139,7 @@ print(Y.shape)
138
139
  ```
139
140
 
140
141
  ### Subband decomposition
142
+
141
143
  ```python
142
144
  import diffsptk
143
145
 
@@ -150,12 +152,12 @@ x, sr = diffsptk.read("assets/data.wav")
150
152
  # Decompose x.
151
153
  pqmf = diffsptk.PQMF(K, M)
152
154
  decimate = diffsptk.Decimation(K)
153
- y = decimate(pqmf(x), dim=-1)
155
+ y = decimate(pqmf(x))
154
156
 
155
157
  # Reconstruct x.
156
158
  interpolate = diffsptk.Interpolation(K)
157
159
  ipqmf = diffsptk.IPQMF(K, M)
158
- x_hat = ipqmf(interpolate(K * y, dim=-1)).reshape(-1)
160
+ x_hat = ipqmf(interpolate(K * y)).reshape(-1)
159
161
 
160
162
  # Write reconstructed waveform.
161
163
  diffsptk.write("reconst.wav", x_hat, sr)
@@ -166,6 +168,7 @@ print(error)
166
168
  ```
167
169
 
168
170
  ### Constant-Q transform
171
+
169
172
  ```python
170
173
  import diffsptk
171
174
  import librosa # This is to get sample audio.
@@ -194,6 +197,7 @@ print(error)
194
197
  ```
195
198
 
196
199
  ### Vector quantization
200
+
197
201
  ```python
198
202
  import diffsptk
199
203
 
@@ -212,14 +216,12 @@ error = (x_hat - x).abs().sum()
212
216
  print(error)
213
217
  ```
214
218
 
219
+ ## License
215
220
 
216
- License
217
- -------
218
221
  This software is released under the Apache License 2.0.
219
222
 
223
+ ## Citation
220
224
 
221
- Reference
222
- ---------
223
225
  ```bibtex
224
226
  @InProceedings{sp-nitech2023sptk,
225
227
  author = {Takenori Yoshimura and Takato Fujimoto and Keiichiro Oura and Keiichi Tokuda},
@@ -45,6 +45,23 @@ def acorr(x, acr_order, norm=False, estimator="none"):
45
45
  )
46
46
 
47
47
 
48
+ def acr2csm(r):
49
+ """Convert autocorrelation to CSM coefficients.
50
+
51
+ Parameters
52
+ ----------
53
+ r : Tensor [shape=(..., M+1)]
54
+ Autocorrelation.
55
+
56
+ Returns
57
+ -------
58
+ out : Tensor [shape=(..., M+1)]
59
+ CSM coefficients.
60
+
61
+ """
62
+ return nn.AutocorrelationToCompositeSinusoidalModelCoefficients._func(r)
63
+
64
+
48
65
  def alaw(x, abs_max=1, a=87.6):
49
66
  """Compress waveform by A-law algorithm.
50
67
 
@@ -187,6 +204,23 @@ def cdist(c1, c2, full=False, reduction="mean", eps=1e-8):
187
204
  return nn.CepstralDistance._func(c1, c2, full=full, reduction=reduction, eps=eps)
188
205
 
189
206
 
207
+ def csm2acr(c):
208
+ """Convert CSM coefficients to autocorrelation.
209
+
210
+ Parameters
211
+ ----------
212
+ c : Tensor [shape=(..., M+1)]
213
+ CSM coefficients.
214
+
215
+ Returns
216
+ -------
217
+ out : Tensor [shape=(..., M+1)]
218
+ Autocorrelation.
219
+
220
+ """
221
+ return nn.CompositeSinusoidalModelCoefficientsToAutocorrelation._func(c)
222
+
223
+
190
224
  def dct(x):
191
225
  """Compute DCT.
192
226
 
@@ -330,6 +364,62 @@ def dfs(x, b=None, a=None):
330
364
  return nn.InfiniteImpulseResponseDigitalFilter._func(x, b=b, a=a)
331
365
 
332
366
 
367
+ def drc(
368
+ x,
369
+ threshold,
370
+ ratio,
371
+ attack_time,
372
+ release_time,
373
+ sample_rate,
374
+ makeup_gain=0,
375
+ abs_max=1,
376
+ ):
377
+ """Apply dynamic range compression.
378
+
379
+ Parameters
380
+ ----------
381
+ x : Tensor [shape=(..., T)]
382
+ Input signal.
383
+
384
+ threshold : float <= 0
385
+ Threshold in dB.
386
+
387
+ ratio : float > 1
388
+ Input/output ratio.
389
+
390
+ attack_time : float > 0
391
+ Attack time in msec.
392
+
393
+ release_time : float > 0
394
+ Release time in msec.
395
+
396
+ sample_rate : int >= 1
397
+ Sample rate in Hz.
398
+
399
+ makeup_gain : float >= 0
400
+ Make-up gain in dB.
401
+
402
+ abs_max : float > 0
403
+ Absolute maximum value of input.
404
+
405
+ Returns
406
+ -------
407
+ out : Tensor [shape=(..., T)]
408
+ Compressed signal.
409
+
410
+ """
411
+ return nn.DynamicRangeCompression._func(
412
+ x,
413
+ threshold=threshold,
414
+ ratio=ratio,
415
+ attack_time=attack_time,
416
+ release_time=release_time,
417
+ sample_rate=sample_rate,
418
+ makeup_gain=makeup_gain,
419
+ abs_max=abs_max,
420
+ )
421
+
422
+
333
423
  def entropy(p, out_format="nat"):
334
424
  """Calculate entropy.
335
425
 
@@ -599,6 +689,46 @@ def grpdelay(b=None, a=None, *, fft_length=512, alpha=1, gamma=1, **kwargs):
599
689
  )
600
690
 
601
691
 
692
+ def histogram(x, n_bin=10, lower_bound=0, upper_bound=1, norm=False, softness=1e-3):
693
+ """Compute histogram.
694
+
695
+ Parameters
696
+ ----------
697
+ x : Tensor [shape=(..., T)]
698
+ Input data.
699
+
700
+ n_bin : int >= 1
701
+ Number of bins, :math:`K`.
702
+
703
+ lower_bound : float < U
704
+ Lower bound of the histogram, :math:`L`.
705
+
706
+ upper_bound : float > L
707
+ Upper bound of the histogram, :math:`U`.
708
+
709
+ norm : bool
710
+ If True, normalize the histogram.
711
+
712
+ softness : float > 0
713
+ A smoothing parameter. The smaller value makes the output closer to the true
714
+ histogram, but the gradient vanishes.
715
+
716
+ Returns
717
+ -------
718
+ out : Tensor [shape=(..., K)]
719
+ Histogram in [L, U].
720
+
721
+ """
722
+ return nn.Histogram._func(
723
+ x,
724
+ n_bin=n_bin,
725
+ lower_bound=lower_bound,
726
+ upper_bound=upper_bound,
727
+ norm=norm,
728
+ softness=softness,
729
+ )
730
+
731
+
602
732
  def ialaw(y, abs_max=1, a=87.6):
603
733
  """Expand waveform by A-law algorithm.
604
734
 
@@ -1846,7 +1976,7 @@ def yingram(x, sample_rate=22050, lag_min=22, lag_max=None, n_bin=20):
1846
1976
  )
1847
1977
 
1848
1978
 
1849
- def zcross(x, frame_length, norm=False):
1979
+ def zcross(x, frame_length, norm=False, softness=1e-3):
1850
1980
  """Compute zero-crossing rate.
1851
1981
 
1852
1982
  Parameters
@@ -1860,13 +1990,19 @@ def zcross(x, frame_length, norm=False):
1860
1990
  norm : bool
1861
1991
  If True, divide zero-crossing rate by frame length.
1862
1992
 
1993
+ softness : float > 0
1994
+ A smoothing parameter. The smaller value makes the output closer to the true
1995
+ zero-crossing rate, but the gradient vanishes.
1996
+
1863
1997
  Returns
1864
1998
  -------
1865
1999
  out : Tensor [shape=(..., T/L)]
1866
2000
  Zero-crossing rate.
1867
2001
 
1868
2002
  """
1869
- return nn.ZeroCrossingAnalysis._func(x, frame_length=frame_length, norm=norm)
2003
+ return nn.ZeroCrossingAnalysis._func(
2004
+ x, frame_length=frame_length, norm=norm, softness=softness
2005
+ )
1870
2006
 
1871
2007
 
1872
2008
  def zerodf(x, b, frame_period=80, ignore_gain=False):
@@ -15,20 +15,22 @@
15
15
  # ------------------------------------------------------------------------ #
16
16
 
17
17
  from importlib import import_module
18
+ import math
18
19
 
19
20
  import numpy as np
20
21
  import soundfile as sf
21
22
  import torch
23
+ from torch import nn
22
24
  import torch.nn.functional as F
23
25
  import torchaudio
24
26
 
25
27
  UNVOICED_SYMBOL = 0
26
- TWO_PI = 6.283185307179586
28
+ TWO_PI = math.tau
27
29
 
28
30
 
29
- class Lambda(torch.nn.Module):
31
+ class Lambda(nn.Module):
30
32
  def __init__(self, func, **opt):
31
- super(Lambda, self).__init__()
33
+ super().__init__()
32
34
  self.func = func
33
35
  self.opt = opt
34
36
 
@@ -80,6 +82,11 @@ def to(x, dtype=None):
80
82
  return x.to(dtype=dtype)
81
83
 
82
84
 
85
+ def to_2d(x):
86
+ y = x.view(-1, x.size(-1))
87
+ return y
88
+
89
+
83
90
  def to_3d(x):
84
91
  y = x.view(-1, 1, x.size(-1))
85
92
  return y
@@ -101,9 +108,9 @@ def replicate1(x, left=True, right=True):
101
108
  return y
102
109
 
103
110
 
104
- def remove_gain(a, return_gain=False):
111
+ def remove_gain(a, return_gain=False, value=1):
105
112
  K, a1 = torch.split(a, [1, a.size(-1) - 1], dim=-1)
106
- a = F.pad(a1, (1, 0), value=1)
113
+ a = F.pad(a1, (1, 0), value=value)
107
114
  if return_gain:
108
115
  ret = (K, a)
109
116
  else:
@@ -209,8 +216,13 @@ def symmetric_toeplitz(x):
209
216
 
210
217
  def hankel(x):
211
218
  d = x.size(-1)
212
- assert d % 2 == 1
213
- X = x.unfold(-1, (d + 1) // 2, 1)
219
+ n = (d + 1) // 2
220
+ X = x.unfold(-1, n, 1)[..., :n, :]
221
+ return X
222
+
223
+
224
+ def vander(x):
225
+ X = torch.linalg.vander(x).transpose(-2, -1)
214
226
  return X
215
227
 
216
228
 
@@ -1,4 +1,5 @@
1
1
  from .acorr import Autocorrelation
2
+ from .acr2csm import AutocorrelationToCompositeSinusoidalModelCoefficients
2
3
  from .alaw import ALawCompression
3
4
  from .ap import Aperiodicity
4
5
  from .b2mc import MLSADigitalFilterCoefficientsToMelCepstrum
@@ -8,6 +9,7 @@ from .c2ndps import CepstrumToNegativeDerivativeOfPhaseSpectrum
8
9
  from .cdist import CepstralDistance
9
10
  from .cqt import ConstantQTransform
10
11
  from .cqt import ConstantQTransform as CQT
12
+ from .csm2acr import CompositeSinusoidalModelCoefficientsToAutocorrelation
11
13
  from .dct import DiscreteCosineTransform
12
14
  from .dct import DiscreteCosineTransform as DCT
13
15
  from .decimate import Decimation
@@ -17,9 +19,12 @@ from .dequantize import InverseUniformQuantization
17
19
  from .df2 import SecondOrderDigitalFilter
18
20
  from .dfs import InfiniteImpulseResponseDigitalFilter
19
21
  from .dfs import InfiniteImpulseResponseDigitalFilter as IIR
22
+ from .drc import DynamicRangeCompression
23
+ from .drc import DynamicRangeCompression as DRC
20
24
  from .entropy import Entropy
21
25
  from .excite import ExcitationGeneration
22
26
  from .fbank import MelFilterBankAnalysis
27
+ from .fbank import MelFilterBankAnalysis as FBANK
23
28
  from .fftcep import CepstralAnalysis
24
29
  from .frame import Frame
25
30
  from .freqt import FrequencyTransform
@@ -28,6 +33,7 @@ from .gmm import GaussianMixtureModeling
28
33
  from .gmm import GaussianMixtureModeling as GMM
29
34
  from .gnorm import GeneralizedCepstrumGainNormalization
30
35
  from .grpdelay import GroupDelay
36
+ from .histogram import Histogram
31
37
  from .ialaw import ALawExpansion
32
38
  from .icqt import InverseConstantQTransform
33
39
  from .icqt import InverseConstantQTransform as ICQT
@@ -15,7 +15,7 @@
15
15
  # ------------------------------------------------------------------------ #
16
16
 
17
17
  import torch
18
- import torch.nn as nn
18
+ from torch import nn
19
19
 
20
20
  from ..misc.utils import check_size
21
21
 
@@ -41,7 +41,7 @@ class Autocorrelation(nn.Module):
41
41
  """
42
42
 
43
43
  def __init__(self, frame_length, acr_order, norm=False, estimator="none"):
44
- super(Autocorrelation, self).__init__()
44
+ super().__init__()
45
45
 
46
46
  assert 0 <= acr_order < frame_length
47
47
 
@@ -93,17 +93,17 @@ class Autocorrelation(nn.Module):
93
93
  @staticmethod
94
94
  def _func(x, acr_order, norm=False, estimator="none"):
95
95
  const = Autocorrelation._precompute(
96
- x.size(-1), acr_order, estimator, dtype=x.dtype, device=x.device
96
+ x.size(-1), acr_order, estimator, device=x.device
97
97
  )
98
98
  return Autocorrelation._forward(x, acr_order, norm, const)
99
99
 
100
100
  @staticmethod
101
- def _precompute(frame_length, acr_order, estimator, dtype=None, device=None):
102
- if estimator == 0 or estimator == 1 or estimator == "none":
101
+ def _precompute(frame_length, acr_order, estimator, device=None):
102
+ if estimator in (0, 1, "none"):
103
103
  return 1
104
- elif estimator == 2 or estimator == "biased":
104
+ elif estimator in (2, "biased"):
105
105
  return 1 / frame_length
106
- elif estimator == 3 or estimator == "unbiased":
106
+ elif estimator in (3, "unbiased"):
107
107
  return torch.arange(
108
108
  frame_length, frame_length - acr_order - 1, -1, device=device
109
109
  ).reciprocal()