diffsptk 3.4.0__tar.gz → 4.0.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 (152) hide show
  1. {diffsptk-3.4.0 → diffsptk-4.0.0}/.gitignore +1 -0
  2. {diffsptk-3.4.0 → diffsptk-4.0.0}/PKG-INFO +16 -12
  3. {diffsptk-3.4.0 → diffsptk-4.0.0}/README.md +10 -9
  4. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/functional.py +70 -40
  5. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/__init__.py +1 -1
  6. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/acorr.py +15 -16
  7. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/acr2csm.py +13 -19
  8. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/alaw.py +10 -15
  9. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/ap.py +37 -19
  10. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/b2mc.py +7 -11
  11. diffsptk-4.0.0/diffsptk/modules/base.py +109 -0
  12. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/c2acr.py +9 -12
  13. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/c2mpir.py +9 -12
  14. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/c2ndps.py +13 -15
  15. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/cdist.py +7 -12
  16. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/chroma.py +12 -13
  17. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/cqt.py +8 -4
  18. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/csm2acr.py +11 -17
  19. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/dct.py +9 -13
  20. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/decimate.py +7 -12
  21. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/delay.py +9 -12
  22. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/delta.py +26 -27
  23. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/dequantize.py +19 -19
  24. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/df2.py +6 -8
  25. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/dfs.py +37 -35
  26. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/dht.py +9 -13
  27. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/drc.py +24 -31
  28. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/dst.py +9 -13
  29. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/dtw.py +29 -20
  30. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/entropy.py +7 -12
  31. diffsptk-4.0.0/diffsptk/modules/excite.py +310 -0
  32. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/f0eval.py +9 -14
  33. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/fbank.py +21 -22
  34. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/fftcep.py +14 -15
  35. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/fftr.py +16 -18
  36. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/flux.py +7 -11
  37. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/frame.py +14 -16
  38. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/freqt.py +9 -13
  39. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/freqt2.py +9 -13
  40. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/gammatone.py +6 -2
  41. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/gmm.py +19 -16
  42. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/gnorm.py +9 -12
  43. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/griffin.py +19 -19
  44. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/grpdelay.py +15 -17
  45. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/hilbert.py +9 -13
  46. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/histogram.py +10 -15
  47. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/ialaw.py +10 -15
  48. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/ica.py +5 -2
  49. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/icqt.py +12 -6
  50. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/idct.py +8 -12
  51. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/idht.py +8 -12
  52. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/idst.py +8 -12
  53. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/ifbank.py +17 -20
  54. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/ifftr.py +13 -18
  55. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/ifreqt2.py +9 -13
  56. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/igammatone.py +9 -3
  57. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/ignorm.py +8 -11
  58. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/imdct.py +31 -37
  59. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/imdst.py +4 -10
  60. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/imsvq.py +7 -7
  61. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/interpolate.py +6 -11
  62. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/ipnorm.py +5 -8
  63. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/ipqmf.py +1 -1
  64. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/is2par.py +9 -12
  65. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/istft.py +18 -19
  66. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/iulaw.py +7 -16
  67. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/lar2par.py +9 -12
  68. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/lbg.py +10 -6
  69. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/levdur.py +13 -16
  70. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/linear_intpl.py +7 -12
  71. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/lpc.py +19 -18
  72. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/lpc2lsp.py +15 -17
  73. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/lpc2par.py +11 -14
  74. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/lpccheck.py +9 -12
  75. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/lsp2lpc.py +23 -17
  76. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/lsp2sp.py +13 -14
  77. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/lspcheck.py +14 -15
  78. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/magic_intpl.py +13 -17
  79. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/mc2b.py +7 -11
  80. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/mcep.py +30 -40
  81. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/mcpf.py +20 -17
  82. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/mdct.py +28 -34
  83. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/mdst.py +4 -10
  84. diffsptk-4.0.0/diffsptk/modules/medfilt.py +147 -0
  85. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/mfcc.py +16 -18
  86. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/mgc2mgc.py +33 -24
  87. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/mgc2sp.py +18 -16
  88. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/mgcep.py +3 -3
  89. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/mglsadf.py +345 -93
  90. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/mlpg.py +19 -17
  91. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/mlsacheck.py +21 -17
  92. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/mpir2c.py +9 -12
  93. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/msvq.py +3 -1
  94. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/ndps2c.py +13 -15
  95. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/nmf.py +8 -5
  96. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/norm0.py +5 -8
  97. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/oband.py +3 -1
  98. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/par2is.py +9 -12
  99. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/par2lar.py +9 -14
  100. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/par2lpc.py +10 -13
  101. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/pca.py +2 -1
  102. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/phase.py +10 -12
  103. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/pitch.py +6 -4
  104. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/pitch_spec.py +31 -16
  105. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/plp.py +29 -34
  106. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/pnorm.py +17 -17
  107. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/pol_root.py +10 -12
  108. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/poledf.py +16 -11
  109. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/pqmf.py +1 -1
  110. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/quantize.py +23 -23
  111. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/rlevdur.py +25 -35
  112. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/rmse.py +7 -12
  113. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/root_pol.py +12 -13
  114. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/smcep.py +26 -33
  115. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/snr.py +14 -11
  116. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/spec.py +24 -28
  117. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/stft.py +22 -22
  118. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/ulaw.py +8 -15
  119. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/unframe.py +27 -22
  120. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/wht.py +9 -13
  121. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/window.py +16 -20
  122. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/world_synth.py +6 -2
  123. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/yingram.py +16 -15
  124. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/zcross.py +9 -12
  125. diffsptk-4.0.0/diffsptk/modules/zerodf.py +240 -0
  126. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/signals.py +46 -16
  127. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/third_party/librosa/constantq.py +2 -2
  128. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/third_party/librosa/filters.py +1 -1
  129. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/third_party/world/common.py +2 -2
  130. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/typing.py +5 -12
  131. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/utils/private.py +15 -12
  132. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/utils/public.py +1 -1
  133. diffsptk-4.0.0/diffsptk/version.py +1 -0
  134. {diffsptk-3.4.0 → diffsptk-4.0.0}/pyproject.toml +11 -2
  135. diffsptk-3.4.0/diffsptk/modules/base.py +0 -59
  136. diffsptk-3.4.0/diffsptk/modules/excite.py +0 -221
  137. diffsptk-3.4.0/diffsptk/modules/hilbert2.py +0 -133
  138. diffsptk-3.4.0/diffsptk/modules/zerodf.py +0 -118
  139. diffsptk-3.4.0/diffsptk/version.py +0 -1
  140. {diffsptk-3.4.0 → diffsptk-4.0.0}/CITATION.cff +0 -0
  141. {diffsptk-3.4.0 → diffsptk-4.0.0}/LICENSE +0 -0
  142. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/__init__.py +0 -0
  143. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/imglsadf.py +0 -0
  144. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/ivq.py +0 -0
  145. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/modules/vq.py +0 -0
  146. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/third_party/librosa/LICENSE +0 -0
  147. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/third_party/librosa/__init__.py +0 -0
  148. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/third_party/librosa/typing.py +0 -0
  149. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/third_party/librosa/util.py +0 -0
  150. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/third_party/world/LICENSE +0 -0
  151. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/third_party/world/__init__.py +0 -0
  152. {diffsptk-3.4.0 → diffsptk-4.0.0}/diffsptk/utils/__init__.py +0 -0
@@ -18,6 +18,7 @@ tools/**/
18
18
 
19
19
  # misc
20
20
  __pycache__/
21
+ .claude/
21
22
  *.pyc
22
23
  *~
23
24
  *.swp
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: diffsptk
3
- Version: 3.4.0
3
+ Version: 4.0.0
4
4
  Summary: Speech signal processing modules for machine learning
5
5
  Project-URL: Homepage, https://sp-tk.sourceforge.net/
6
- Project-URL: Documentation, https://sp-nitech.github.io/diffsptk/latest/
6
+ Project-URL: Documentation, https://sp-nitech.github.io/diffsptk/stable/
7
7
  Project-URL: Source, https://github.com/sp-nitech/diffsptk
8
8
  Author: SPTK Working Group
9
9
  Maintainer-email: Takenori Yoshimura <takenori@sp.nitech.ac.jp>
@@ -17,7 +17,9 @@ Classifier: Programming Language :: Python :: 3.10
17
17
  Classifier: Programming Language :: Python :: 3.11
18
18
  Classifier: Programming Language :: Python :: 3.12
19
19
  Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
20
21
  Requires-Python: >=3.10
22
+ Requires-Dist: mpmath>=0.17.0
21
23
  Requires-Dist: numpy>=1.23.0
22
24
  Requires-Dist: penn<1.0.0,>=0.0.1
23
25
  Requires-Dist: pylstraight>=0.1.0
@@ -26,7 +28,7 @@ Requires-Dist: soundfile>=0.10.2
26
28
  Requires-Dist: torch>=2.3.1
27
29
  Requires-Dist: torchaudio>=2.3.1
28
30
  Requires-Dist: torchcomp<0.3.0,>=0.1.0
29
- Requires-Dist: torchlpc<0.7.0,>=0.1.0
31
+ Requires-Dist: torchlpc<0.7.0,>=0.4.0
30
32
  Requires-Dist: tqdm>=4.63.0
31
33
  Requires-Dist: vector-quantize-pytorch>=1.14.9
32
34
  Provides-Extra: dev
@@ -36,6 +38,7 @@ Requires-Dist: mdformat; extra == 'dev'
36
38
  Requires-Dist: numpydoc; extra == 'dev'
37
39
  Requires-Dist: pkginfo; extra == 'dev'
38
40
  Requires-Dist: pydata-sphinx-theme; extra == 'dev'
41
+ Requires-Dist: pyright[nodejs]<1.1.409; extra == 'dev'
39
42
  Requires-Dist: pytest; extra == 'dev'
40
43
  Requires-Dist: pytest-cov; extra == 'dev'
41
44
  Requires-Dist: ruff; extra == 'dev'
@@ -45,14 +48,15 @@ Description-Content-Type: text/markdown
45
48
 
46
49
  # diffsptk
47
50
 
48
- *diffsptk* is a differentiable version of [SPTK](https://github.com/sp-nitech/SPTK) based on the PyTorch framework.
51
+ *diffsptk* is a differentiable version of [SPTK](https://github.com/sp-nitech/SPTK) built on the PyTorch framework.
52
+ It provides various speech signal processing modules as PyTorch layers,
53
+ allowing users to integrate classic signal processing algorithms directly into neural network architectures and optimize them through backpropagation.
49
54
 
50
- [![Manual](https://img.shields.io/badge/docs-stable-blue.svg)](https://sp-nitech.github.io/diffsptk/3.4.0/)
55
+ [![Manual](https://img.shields.io/badge/docs-stable-blue.svg)](https://sp-nitech.github.io/diffsptk/stable/)
51
56
  [![Downloads](https://static.pepy.tech/badge/diffsptk)](https://pepy.tech/project/diffsptk)
52
57
  [![ClickPy](https://img.shields.io/badge/downloads-clickpy-yellow.svg)](https://clickpy.clickhouse.com/dashboard/diffsptk)
53
- [![Advisor](https://snyk.io/advisor/python/diffsptk/badge.svg)](https://snyk.io/advisor/python/diffsptk)
54
58
  [![Python Version](https://img.shields.io/pypi/pyversions/diffsptk.svg)](https://pypi.python.org/pypi/diffsptk)
55
- [![PyTorch Version](https://img.shields.io/badge/pytorch-2.3.1%20%7C%202.9.0-orange.svg)](https://pypi.python.org/pypi/diffsptk)
59
+ [![PyTorch Version](https://img.shields.io/badge/pytorch-2.3.1%20%7C%202.12.0-orange.svg)](https://pypi.python.org/pypi/diffsptk)
56
60
  [![PyPI Version](https://img.shields.io/pypi/v/diffsptk.svg)](https://pypi.python.org/pypi/diffsptk)
57
61
  [![Codecov](https://codecov.io/gh/sp-nitech/diffsptk/branch/master/graph/badge.svg)](https://app.codecov.io/gh/sp-nitech/diffsptk)
58
62
  [![License](https://img.shields.io/github/license/sp-nitech/diffsptk.svg)](https://github.com/sp-nitech/diffsptk/blob/master/LICENSE)
@@ -66,19 +70,19 @@ Description-Content-Type: text/markdown
66
70
 
67
71
  ## Documentation
68
72
 
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
73
+ - [**Reference Manual**](https://sp-nitech.github.io/diffsptk/stable/) - Detailed API documentation and module specifications.
74
+ - [**Interactive Tutorial**](https://colab.research.google.com/drive/1xAoUKqXadvJXJ7RzN0OceB6y7q5i7Sn6?usp=drive_link) (Google Colab) - Hands-on examples to get started with `diffsptk` in your browser.
75
+ - [**Conference Paper**](https://www.isca-archive.org/ssw_2023/yoshimura23_ssw.html) - Technical background and implementation details available on the ISCA Archive.
72
76
 
73
77
  ## Installation
74
78
 
75
- The latest stable release can be installed through PyPI by running
79
+ The latest stable release can be installed via PyPI:
76
80
 
77
81
  ```sh
78
82
  pip install diffsptk
79
83
  ```
80
84
 
81
- The development release can be installed from the master branch:
85
+ Alternatively, the development version can be installed directly from the GitHub repository:
82
86
 
83
87
  ```sh
84
88
  pip install git+https://github.com/sp-nitech/diffsptk.git@master
@@ -1,13 +1,14 @@
1
1
  # diffsptk
2
2
 
3
- *diffsptk* is a differentiable version of [SPTK](https://github.com/sp-nitech/SPTK) based on the PyTorch framework.
3
+ *diffsptk* is a differentiable version of [SPTK](https://github.com/sp-nitech/SPTK) built on the PyTorch framework.
4
+ It provides various speech signal processing modules as PyTorch layers,
5
+ allowing users to integrate classic signal processing algorithms directly into neural network architectures and optimize them through backpropagation.
4
6
 
5
- [![Manual](https://img.shields.io/badge/docs-stable-blue.svg)](https://sp-nitech.github.io/diffsptk/3.4.0/)
7
+ [![Manual](https://img.shields.io/badge/docs-stable-blue.svg)](https://sp-nitech.github.io/diffsptk/stable/)
6
8
  [![Downloads](https://static.pepy.tech/badge/diffsptk)](https://pepy.tech/project/diffsptk)
7
9
  [![ClickPy](https://img.shields.io/badge/downloads-clickpy-yellow.svg)](https://clickpy.clickhouse.com/dashboard/diffsptk)
8
- [![Advisor](https://snyk.io/advisor/python/diffsptk/badge.svg)](https://snyk.io/advisor/python/diffsptk)
9
10
  [![Python Version](https://img.shields.io/pypi/pyversions/diffsptk.svg)](https://pypi.python.org/pypi/diffsptk)
10
- [![PyTorch Version](https://img.shields.io/badge/pytorch-2.3.1%20%7C%202.9.0-orange.svg)](https://pypi.python.org/pypi/diffsptk)
11
+ [![PyTorch Version](https://img.shields.io/badge/pytorch-2.3.1%20%7C%202.12.0-orange.svg)](https://pypi.python.org/pypi/diffsptk)
11
12
  [![PyPI Version](https://img.shields.io/pypi/v/diffsptk.svg)](https://pypi.python.org/pypi/diffsptk)
12
13
  [![Codecov](https://codecov.io/gh/sp-nitech/diffsptk/branch/master/graph/badge.svg)](https://app.codecov.io/gh/sp-nitech/diffsptk)
13
14
  [![License](https://img.shields.io/github/license/sp-nitech/diffsptk.svg)](https://github.com/sp-nitech/diffsptk/blob/master/LICENSE)
@@ -21,19 +22,19 @@
21
22
 
22
23
  ## Documentation
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
+ - [**Reference Manual**](https://sp-nitech.github.io/diffsptk/stable/) - Detailed API documentation and module specifications.
26
+ - [**Interactive Tutorial**](https://colab.research.google.com/drive/1xAoUKqXadvJXJ7RzN0OceB6y7q5i7Sn6?usp=drive_link) (Google Colab) - Hands-on examples to get started with `diffsptk` in your browser.
27
+ - [**Conference Paper**](https://www.isca-archive.org/ssw_2023/yoshimura23_ssw.html) - Technical background and implementation details available on the ISCA Archive.
27
28
 
28
29
  ## Installation
29
30
 
30
- The latest stable release can be installed through PyPI by running
31
+ The latest stable release can be installed via PyPI:
31
32
 
32
33
  ```sh
33
34
  pip install diffsptk
34
35
  ```
35
36
 
36
- The development release can be installed from the master branch:
37
+ Alternatively, the development version can be installed directly from the GitHub repository:
37
38
 
38
39
  ```sh
39
40
  pip install git+https://github.com/sp-nitech/diffsptk.git@master
@@ -333,7 +333,7 @@ def delay(x: Tensor, start: int = 0, keeplen: bool = False, dim: int = -1) -> Te
333
333
 
334
334
  def delta(
335
335
  x: Tensor,
336
- seed: ArrayLike[ArrayLike[float]] | ArrayLike[int] = [[-0.5, 0, 0.5]],
336
+ seed: ArrayLike[float] | ArrayLike[int] = [[-0.5, 0, 0.5]],
337
337
  static_out: bool = True,
338
338
  ) -> Tensor:
339
339
  """Compute the delta components.
@@ -622,7 +622,7 @@ def excite(
622
622
  voiced_region: str = "pulse",
623
623
  unvoiced_region: str = "gauss",
624
624
  polarity: str = "auto",
625
- init_phase: str = "zeros",
625
+ init_phase: str | float = "zeros",
626
626
  ) -> Tensor:
627
627
  """Generate a simple excitation signal.
628
628
 
@@ -635,17 +635,17 @@ def excite(
635
635
  The frame period in samples, :math:`P`.
636
636
 
637
637
  voiced_region : ['pulse', 'sinusoidal', 'sawtooth', 'inverted-sawtooth', \
638
- 'triangle', 'square']
638
+ 'triangle', 'square', 'harmonic-pulse']
639
639
  The type of voiced region.
640
640
 
641
- unvoiced_region : ['zeros', 'gauss', 'uniform']
641
+ unvoiced_region : ['zeros', 'gauss', 'm-sequence', 'uniform']
642
642
  The type of unvoiced region.
643
643
 
644
644
  polarity : ['auto', 'unipolar', 'bipolar']
645
645
  The polarity.
646
646
 
647
- init_phase : ['zeros', 'random']
648
- The initial phase.
647
+ init_phase : ['zeros', 'random'] or float
648
+ The initial phase in radians.
649
649
 
650
650
  Returns
651
651
  -------
@@ -1138,33 +1138,6 @@ def hilbert(x: Tensor, fft_length: int | None = None, dim: int = -1) -> Tensor:
1138
1138
  return nn.HilbertTransform._func(x, fft_length=fft_length, dim=dim)
1139
1139
 
1140
1140
 
1141
- def hilbert2(
1142
- x: Tensor,
1143
- fft_length: ArrayLike[int] | int | None = None,
1144
- dim: ArrayLike[int] = (-2, -1),
1145
- ) -> Tensor:
1146
- """Compute the analytic signal using the Hilbert transform.
1147
-
1148
- Parameters
1149
- ----------
1150
- x : Tensor [shape=(..., T1, T2, ...)]
1151
- The input signal.
1152
-
1153
- fft_length : int, list[int], or None
1154
- The number of FFT bins. If None, set to (:math:`T1`, :math:`T2`).
1155
-
1156
- dim : list[int]
1157
- The dimensions along which to take the Hilbert transform.
1158
-
1159
- Returns
1160
- -------
1161
- out : Tensor [shape=(..., T1, T2, ...)]
1162
- The analytic signal.
1163
-
1164
- """
1165
- return nn.TwoDimensionalHilbertTransform._func(x, fft_length=fft_length, dim=dim)
1166
-
1167
-
1168
1141
  def histogram(
1169
1142
  x: Tensor,
1170
1143
  n_bin: int = 10,
@@ -1692,7 +1665,8 @@ def levdur(r: Tensor, eps: float | None = None) -> Tensor:
1692
1665
  The autocorrelation.
1693
1666
 
1694
1667
  eps : float >= 0 or None
1695
- A small value to improve numerical stability.
1668
+ A small value to improve numerical stability. If None, automatically set
1669
+ based on the input data type.
1696
1670
 
1697
1671
  Returns
1698
1672
  -------
@@ -1735,7 +1709,8 @@ def lpc(x: Tensor, lpc_order: int, eps: float | None = None) -> Tensor:
1735
1709
  The order of the LPC coefficients, :math:`M`.
1736
1710
 
1737
1711
  eps : float >= 0 or None
1738
- A small value to improve numerical stability.
1712
+ A small value to improve numerical stability. If None, automatically set
1713
+ based on the input data type.
1739
1714
 
1740
1715
  Returns
1741
1716
  -------
@@ -2089,6 +2064,42 @@ def mdst(x: Tensor, frame_length: int = 400, window: str = "sine") -> Tensor:
2089
2064
  )
2090
2065
 
2091
2066
 
2067
+ def medfilt(
2068
+ x: Tensor,
2069
+ filter_length: int = 3,
2070
+ across_features: bool = False,
2071
+ magic_number: float | None = None,
2072
+ ) -> Tensor:
2073
+ """Apply median filtering to the input sequence.
2074
+
2075
+ Parameters
2076
+ ----------
2077
+ x : Tensor [shape=(B, N, D) or (N, D) or (N,)]
2078
+ The input sequence.
2079
+
2080
+ filter_length : int > 0
2081
+ The length of the median filter, :math:`L`.
2082
+
2083
+ across_features : bool
2084
+ If True, apply the filter across the feature dimension.
2085
+
2086
+ magic_number : float or None
2087
+ The magic number representing unvoiced frames.
2088
+
2089
+ Returns
2090
+ -------
2091
+ out : Tensor [shape=(B, N, D) or (B, N) or (N, D) or (N,)]
2092
+ The filtered sequence.
2093
+
2094
+ """
2095
+ return nn.MedianFilter._func(
2096
+ x,
2097
+ filter_length=filter_length,
2098
+ across_features=across_features,
2099
+ magic_number=magic_number,
2100
+ )
2101
+
2102
+
2092
2103
  def mfcc(
2093
2104
  x: Tensor,
2094
2105
  mfcc_order: int,
@@ -2302,7 +2313,7 @@ def mgc2sp(
2302
2313
 
2303
2314
  def mlpg(
2304
2315
  u: Tensor,
2305
- seed: ArrayLike[ArrayLike[float]] | ArrayLike[int] = [[-0.5, 0, 0.5], [1, -2, 1]],
2316
+ seed: ArrayLike[float] | ArrayLike[int] = [[-0.5, 0, 0.5], [1, -2, 1]],
2306
2317
  ) -> Tensor:
2307
2318
  """Perform MLPG given the mean vectors with delta components.
2308
2319
 
@@ -2742,7 +2753,7 @@ def quantize(
2742
2753
  )
2743
2754
 
2744
2755
 
2745
- def rlevdur(a: Tensor) -> Tensor:
2756
+ def rlevdur(a: Tensor, n_fft: int = 512) -> Tensor:
2746
2757
  """Solve a Yule-Walker linear system given the LPC coefficients.
2747
2758
 
2748
2759
  Parameters
@@ -2750,13 +2761,16 @@ def rlevdur(a: Tensor) -> Tensor:
2750
2761
  a : Tensor [shape=(..., M+1)]
2751
2762
  The gain and the LPC coefficients.
2752
2763
 
2764
+ n_fft : int >> M
2765
+ The number of FFT bins. Accurate conversion requires a large value.
2766
+
2753
2767
  Returns
2754
2768
  -------
2755
2769
  out : Tensor [shape=(..., M+1)]
2756
2770
  The autocorrelation.
2757
2771
 
2758
2772
  """
2759
- return nn.ReverseLevinsonDurbin._func(a)
2773
+ return nn.ReverseLevinsonDurbin._func(a, n_fft=n_fft)
2760
2774
 
2761
2775
 
2762
2776
  def rmse(x: Tensor, y: Tensor, reduction: str = "mean") -> Tensor:
@@ -3234,7 +3248,12 @@ def zcross(
3234
3248
 
3235
3249
 
3236
3250
  def zerodf(
3237
- x: Tensor, b: Tensor, frame_period: int = 80, ignore_gain: bool = False
3251
+ x: Tensor,
3252
+ b: Tensor,
3253
+ frame_period: int = 80,
3254
+ ignore_gain: bool = False,
3255
+ zeroth_index: int = 0,
3256
+ mode: str = "direct",
3238
3257
  ) -> Tensor:
3239
3258
  """Apply an all-zero digital filter.
3240
3259
 
@@ -3252,6 +3271,12 @@ def zerodf(
3252
3271
  ignore_gain : bool
3253
3272
  If True, perform filtering without the gain.
3254
3273
 
3274
+ zeroth_index : int >= 0
3275
+ The index of the zeroth coefficient in the filter coefficients.
3276
+
3277
+ mode : ['direct', 'efficient']
3278
+ The implementation mode for time-varying convolution.
3279
+
3255
3280
  Returns
3256
3281
  -------
3257
3282
  out : Tensor [shape=(..., T)]
@@ -3259,5 +3284,10 @@ def zerodf(
3259
3284
 
3260
3285
  """
3261
3286
  return nn.AllZeroDigitalFilter._func(
3262
- x, b, frame_period=frame_period, ignore_gain=ignore_gain
3287
+ x,
3288
+ b,
3289
+ frame_period=frame_period,
3290
+ ignore_gain=ignore_gain,
3291
+ zeroth_index=zeroth_index,
3292
+ mode=mode,
3263
3293
  )
@@ -62,7 +62,6 @@ from .gnorm import GeneralizedCepstrumGainNormalization
62
62
  from .griffin import GriffinLim
63
63
  from .grpdelay import GroupDelay
64
64
  from .hilbert import HilbertTransform
65
- from .hilbert2 import TwoDimensionalHilbertTransform
66
65
  from .histogram import Histogram
67
66
  from .ialaw import ALawExpansion
68
67
  from .ica import IndependentComponentAnalysis
@@ -117,6 +116,7 @@ from .mdct import ModifiedDiscreteCosineTransform
117
116
  from .mdct import ModifiedDiscreteCosineTransform as MDCT
118
117
  from .mdst import ModifiedDiscreteSineTransform
119
118
  from .mdst import ModifiedDiscreteSineTransform as MDST
119
+ from .medfilt import MedianFilter
120
120
  from .mfcc import MelFrequencyCepstralCoefficientsAnalysis
121
121
  from .mfcc import MelFrequencyCepstralCoefficientsAnalysis as MFCC
122
122
  from .mgc2mgc import MelGeneralizedCepstrumToMelGeneralizedCepstrum
@@ -16,9 +16,9 @@
16
16
 
17
17
  import torch
18
18
 
19
- from ..typing import Callable, Precomputed
19
+ from ..typing import Callable
20
20
  from ..utils.private import check_size, filter_values
21
- from .base import BaseFunctionalModule
21
+ from .base import BaseFunctionalModule, Precomputed
22
22
 
23
23
 
24
24
  class Autocorrelation(BaseFunctionalModule):
@@ -38,6 +38,8 @@ class Autocorrelation(BaseFunctionalModule):
38
38
 
39
39
  """
40
40
 
41
+ _takes_input_size = True
42
+
41
43
  def __init__(
42
44
  self, frame_length: int, acr_order: int, out_format: str | int = "naive"
43
45
  ) -> None:
@@ -45,7 +47,7 @@ class Autocorrelation(BaseFunctionalModule):
45
47
 
46
48
  self.in_dim = frame_length
47
49
 
48
- self.values = self._precompute(**filter_values(locals()))
50
+ self._register_precomputed(self._precompute(**filter_values(locals())))
49
51
 
50
52
  def forward(self, x: torch.Tensor) -> torch.Tensor:
51
53
  """Estimate the autocorrelation of the input waveform.
@@ -71,16 +73,12 @@ class Autocorrelation(BaseFunctionalModule):
71
73
 
72
74
  """
73
75
  check_size(x.size(-1), self.in_dim, "length of waveform")
74
- return self._forward(x, *self.values)
76
+ return self._call_forward(x)
75
77
 
76
78
  @staticmethod
77
79
  def _func(x: torch.Tensor, *args, **kwargs) -> torch.Tensor:
78
- values = Autocorrelation._precompute(x.size(-1), *args, **kwargs)
79
- return Autocorrelation._forward(x, *values)
80
-
81
- @staticmethod
82
- def _takes_input_size() -> bool:
83
- return True
80
+ _p = Autocorrelation._precompute(x.size(-1), *args, **kwargs)
81
+ return Autocorrelation._apply_precomputed(_p, x=x)
84
82
 
85
83
  @staticmethod
86
84
  def _check(frame_length: int, acr_order: int) -> None:
@@ -101,17 +99,18 @@ class Autocorrelation(BaseFunctionalModule):
101
99
  elif out_format in (2, "biased"):
102
100
  formatter = lambda x: x / frame_length
103
101
  elif out_format in (3, "unbiased"):
104
- formatter = lambda x: x / (
105
- torch.arange(
106
- frame_length, frame_length - acr_order - 1, -1, device=x.device
107
- )
102
+ n = frame_length - acr_order - 1
103
+ formatter = lambda x: (
104
+ x / (torch.arange(frame_length, n, -1, device=x.device))
108
105
  )
109
106
  else:
110
107
  raise ValueError(f"out_format {out_format} is not supported.")
111
- return (acr_order, formatter)
108
+ return Precomputed(values={"acr_order": acr_order, "formatter": formatter})
112
109
 
113
110
  @staticmethod
114
- def _forward(x: torch.Tensor, acr_order: int, formatter: Callable) -> torch.Tensor:
111
+ def _forward(
112
+ x: torch.Tensor, *, acr_order: int, formatter: Callable
113
+ ) -> torch.Tensor:
115
114
  fft_length = x.size(-1) + acr_order
116
115
  if fft_length % 2 == 1:
117
116
  fft_length += 1
@@ -17,9 +17,8 @@
17
17
  import torch
18
18
  import torch.nn.functional as F
19
19
 
20
- from ..typing import Precomputed
21
20
  from ..utils.private import check_size, filter_values, hankel, to, vander
22
- from .base import BaseFunctionalModule
21
+ from .base import BaseFunctionalModule, Precomputed
23
22
  from .root_pol import PolynomialToRoots
24
23
 
25
24
 
@@ -45,6 +44,8 @@ class AutocorrelationToCompositeSinusoidalModelCoefficients(BaseFunctionalModule
45
44
 
46
45
  """
47
46
 
47
+ _takes_input_size = True
48
+
48
49
  def __init__(
49
50
  self,
50
51
  acr_order: int,
@@ -55,8 +56,7 @@ class AutocorrelationToCompositeSinusoidalModelCoefficients(BaseFunctionalModule
55
56
 
56
57
  self.in_dim = acr_order + 1
57
58
 
58
- _, _, tensors = self._precompute(**filter_values(locals()))
59
- self.register_buffer("C", tensors[0])
59
+ self._register_precomputed(self._precompute(**filter_values(locals())))
60
60
 
61
61
  def forward(self, r: torch.Tensor) -> torch.Tensor:
62
62
  """Convert autocorrelation to CSM coefficients.
@@ -83,23 +83,17 @@ class AutocorrelationToCompositeSinusoidalModelCoefficients(BaseFunctionalModule
83
83
 
84
84
  """
85
85
  check_size(r.size(-1), self.in_dim, "dimension of autocorrelation")
86
- return self._forward(r, **self._buffers)
86
+ return self._call_forward(r)
87
87
 
88
88
  @staticmethod
89
89
  def _func(r: torch.Tensor, *args, **kwargs) -> torch.Tensor:
90
- _, _, tensors = (
91
- AutocorrelationToCompositeSinusoidalModelCoefficients._precompute(
92
- r.size(-1) - 1, *args, **kwargs, device=r.device, dtype=r.dtype
93
- )
90
+ _p = AutocorrelationToCompositeSinusoidalModelCoefficients._precompute(
91
+ r.size(-1) - 1, *args, **kwargs, device=r.device, dtype=r.dtype
94
92
  )
95
- return AutocorrelationToCompositeSinusoidalModelCoefficients._forward(
96
- r, *tensors
93
+ return AutocorrelationToCompositeSinusoidalModelCoefficients._apply_precomputed(
94
+ _p, r=r
97
95
  )
98
96
 
99
- @staticmethod
100
- def _takes_input_size() -> bool:
101
- return True
102
-
103
97
  @staticmethod
104
98
  def _check(acr_order: int) -> None:
105
99
  if acr_order <= 0 or acr_order % 2 == 0:
@@ -132,20 +126,20 @@ class AutocorrelationToCompositeSinusoidalModelCoefficients(BaseFunctionalModule
132
126
  bias + center : bias + center + length, k
133
127
  ]
134
128
  C[1:] *= 2
135
- return None, None, (to(C, dtype=dtype),)
129
+ return Precomputed(tensors={"C": to(C, dtype=dtype)})
136
130
 
137
131
  @staticmethod
138
- def _forward(r: torch.Tensor, C: torch.Tensor) -> torch.Tensor:
132
+ def _forward(r: torch.Tensor, *, C: torch.Tensor) -> torch.Tensor:
139
133
  u = torch.matmul(r, C)
140
134
  u1, u2 = torch.tensor_split(u, 2, dim=-1)
141
135
 
142
136
  U = hankel(-u)
143
- p = torch.matmul(U.inverse(), u2.unsqueeze(-1)).squeeze(-1)
137
+ p = torch.linalg.solve(U, u2.unsqueeze(-1)).squeeze(-1)
144
138
  x = PolynomialToRoots._func(F.pad(p.flip(-1), (1, 0), value=1))
145
139
  x, _ = torch.sort(x.real, descending=True)
146
140
  w = torch.acos(x)
147
141
 
148
142
  V = vander(x)
149
- m = torch.matmul(V.inverse(), u1.unsqueeze(-1)).squeeze(-1)
143
+ m = torch.linalg.solve(V, u1.unsqueeze(-1)).squeeze(-1)
150
144
  c = torch.cat((w, m), dim=-1)
151
145
  return c
@@ -18,9 +18,8 @@ import math
18
18
 
19
19
  import torch
20
20
 
21
- from ..typing import Precomputed
22
21
  from ..utils.private import filter_values
23
- from .base import BaseFunctionalModule
22
+ from .base import BaseFunctionalModule, Precomputed
24
23
 
25
24
 
26
25
  class ALawCompression(BaseFunctionalModule):
@@ -40,7 +39,7 @@ class ALawCompression(BaseFunctionalModule):
40
39
  def __init__(self, abs_max: float = 1, a: float = 87.6) -> None:
41
40
  super().__init__()
42
41
 
43
- self.values = self._precompute(**filter_values(locals()))
42
+ self._register_precomputed(self._precompute(**filter_values(locals())))
44
43
 
45
44
  def forward(self, x: torch.Tensor) -> torch.Tensor:
46
45
  """Compress the input waveform using the A-law algorithm.
@@ -65,16 +64,12 @@ class ALawCompression(BaseFunctionalModule):
65
64
  tensor([0.0000, 2.9868, 3.4934, 3.7897, 4.0000])
66
65
 
67
66
  """
68
- return self._forward(x, *self.values)
67
+ return self._call_forward(x)
69
68
 
70
69
  @staticmethod
71
70
  def _func(x: torch.Tensor, *args, **kwargs) -> torch.Tensor:
72
- values = ALawCompression._precompute(*args, **kwargs)
73
- return ALawCompression._forward(x, *values)
74
-
75
- @staticmethod
76
- def _takes_input_size() -> bool:
77
- return False
71
+ _p = ALawCompression._precompute(*args, **kwargs)
72
+ return ALawCompression._apply_precomputed(_p, x=x)
78
73
 
79
74
  @staticmethod
80
75
  def _check(abs_max: float, a: float) -> None:
@@ -86,14 +81,14 @@ class ALawCompression(BaseFunctionalModule):
86
81
  @staticmethod
87
82
  def _precompute(abs_max: float, a: float) -> Precomputed:
88
83
  ALawCompression._check(abs_max, a)
89
- return (
90
- abs_max,
91
- a,
92
- abs_max / (1 + math.log(a)),
84
+ return Precomputed(
85
+ values={"abs_max": abs_max, "a": a, "c": abs_max / (1 + math.log(a))}
93
86
  )
94
87
 
95
88
  @staticmethod
96
- def _forward(x: torch.Tensor, abs_max: float, a: float, c: float) -> torch.Tensor:
89
+ def _forward(
90
+ x: torch.Tensor, *, abs_max: float, a: float, c: float
91
+ ) -> torch.Tensor:
97
92
  x_abs = x.abs() / abs_max
98
93
  x1 = a * x_abs
99
94
  x2 = 1 + torch.log(x1)