diffsptk 3.3.1__tar.gz → 3.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.
Files changed (150) hide show
  1. {diffsptk-3.3.1 → diffsptk-3.5.0}/PKG-INFO +18 -13
  2. {diffsptk-3.3.1 → diffsptk-3.5.0}/README.md +12 -9
  3. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/functional.py +178 -42
  4. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/__init__.py +4 -1
  5. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/acorr.py +5 -5
  6. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/acr2csm.py +5 -12
  7. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/alaw.py +2 -1
  8. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/ap.py +14 -6
  9. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/b2mc.py +3 -2
  10. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/c2acr.py +5 -5
  11. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/c2mpir.py +4 -3
  12. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/c2ndps.py +2 -1
  13. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/cdist.py +6 -8
  14. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/chroma.py +9 -4
  15. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/cqt.py +4 -3
  16. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/csm2acr.py +4 -3
  17. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/dct.py +2 -1
  18. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/decimate.py +2 -1
  19. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/delay.py +6 -1
  20. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/delta.py +2 -1
  21. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/dequantize.py +3 -2
  22. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/df2.py +4 -3
  23. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/dfs.py +2 -1
  24. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/dht.py +2 -1
  25. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/drc.py +17 -13
  26. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/dst.py +2 -1
  27. diffsptk-3.5.0/diffsptk/modules/dtw.py +381 -0
  28. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/entropy.py +2 -1
  29. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/excite.py +22 -13
  30. diffsptk-3.5.0/diffsptk/modules/f0eval.py +138 -0
  31. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/fbank.py +2 -1
  32. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/fftcep.py +5 -4
  33. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/fftr.py +2 -3
  34. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/flux.py +2 -1
  35. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/frame.py +2 -1
  36. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/freqt.py +8 -7
  37. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/freqt2.py +7 -9
  38. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/gammatone.py +2 -1
  39. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/gmm.py +19 -10
  40. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/gnorm.py +2 -1
  41. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/griffin.py +6 -5
  42. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/grpdelay.py +2 -1
  43. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/hilbert.py +4 -5
  44. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/histogram.py +2 -1
  45. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/ialaw.py +2 -1
  46. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/ica.py +21 -2
  47. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/icqt.py +4 -1
  48. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/idct.py +3 -2
  49. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/idht.py +4 -3
  50. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/idst.py +3 -2
  51. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/ifbank.py +5 -4
  52. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/ifftr.py +2 -3
  53. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/ifreqt2.py +11 -10
  54. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/igammatone.py +4 -3
  55. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/ignorm.py +3 -2
  56. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/imdct.py +3 -4
  57. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/imdst.py +3 -4
  58. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/imglsadf.py +6 -8
  59. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/imsvq.py +5 -5
  60. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/interpolate.py +2 -1
  61. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/ipnorm.py +2 -1
  62. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/ipqmf.py +5 -6
  63. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/is2par.py +2 -1
  64. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/istft.py +2 -3
  65. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/iulaw.py +2 -1
  66. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/ivq.py +5 -7
  67. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/lar2par.py +2 -1
  68. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/lbg.py +11 -14
  69. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/levdur.py +7 -7
  70. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/linear_intpl.py +2 -1
  71. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/lpc.py +5 -4
  72. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/lpc2lsp.py +5 -8
  73. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/lpc2par.py +5 -8
  74. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/lpccheck.py +8 -8
  75. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/lsp2lpc.py +2 -1
  76. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/lsp2sp.py +6 -7
  77. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/lspcheck.py +7 -3
  78. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/magic_intpl.py +2 -1
  79. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/mc2b.py +2 -1
  80. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/mcep.py +5 -4
  81. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/mcpf.py +8 -6
  82. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/mdct.py +5 -6
  83. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/mdst.py +2 -3
  84. diffsptk-3.5.0/diffsptk/modules/medfilt.py +144 -0
  85. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/mfcc.py +5 -4
  86. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/mgc2mgc.py +3 -2
  87. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/mgc2sp.py +7 -7
  88. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/mgcep.py +4 -3
  89. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/mglsadf.py +294 -61
  90. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/mlpg.py +1 -0
  91. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/mlsacheck.py +6 -4
  92. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/mpir2c.py +2 -1
  93. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/msvq.py +11 -8
  94. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/ndps2c.py +2 -1
  95. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/nmf.py +4 -1
  96. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/norm0.py +4 -1
  97. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/oband.py +2 -1
  98. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/par2is.py +2 -1
  99. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/par2lar.py +2 -1
  100. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/par2lpc.py +7 -8
  101. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/pca.py +10 -7
  102. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/phase.py +2 -1
  103. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/pitch.py +14 -3
  104. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/pitch_spec.py +3 -2
  105. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/plp.py +3 -2
  106. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/pnorm.py +3 -2
  107. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/pol_root.py +3 -1
  108. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/poledf.py +3 -2
  109. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/pqmf.py +3 -2
  110. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/quantize.py +2 -1
  111. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/rlevdur.py +23 -28
  112. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/rmse.py +6 -8
  113. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/root_pol.py +3 -2
  114. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/smcep.py +5 -4
  115. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/snr.py +5 -7
  116. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/spec.py +2 -1
  117. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/stft.py +2 -1
  118. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/ulaw.py +2 -1
  119. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/unframe.py +3 -2
  120. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/vq.py +6 -5
  121. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/wht.py +2 -1
  122. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/window.py +2 -1
  123. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/world_synth.py +19 -9
  124. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/yingram.py +2 -1
  125. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/zcross.py +3 -3
  126. diffsptk-3.5.0/diffsptk/modules/zerodf.py +236 -0
  127. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/signals.py +16 -10
  128. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/third_party/world/common.py +1 -1
  129. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/utils/public.py +22 -18
  130. diffsptk-3.5.0/diffsptk/version.py +1 -0
  131. {diffsptk-3.3.1 → diffsptk-3.5.0}/pyproject.toml +5 -3
  132. diffsptk-3.3.1/diffsptk/modules/hilbert2.py +0 -134
  133. diffsptk-3.3.1/diffsptk/modules/zerodf.py +0 -117
  134. diffsptk-3.3.1/diffsptk/version.py +0 -1
  135. {diffsptk-3.3.1 → diffsptk-3.5.0}/.gitignore +0 -0
  136. {diffsptk-3.3.1 → diffsptk-3.5.0}/CITATION.cff +0 -0
  137. {diffsptk-3.3.1 → diffsptk-3.5.0}/LICENSE +0 -0
  138. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/__init__.py +0 -0
  139. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/modules/base.py +0 -0
  140. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/third_party/librosa/LICENSE +0 -0
  141. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/third_party/librosa/__init__.py +0 -0
  142. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/third_party/librosa/constantq.py +0 -0
  143. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/third_party/librosa/filters.py +0 -0
  144. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/third_party/librosa/typing.py +0 -0
  145. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/third_party/librosa/util.py +0 -0
  146. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/third_party/world/LICENSE +0 -0
  147. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/third_party/world/__init__.py +0 -0
  148. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/typing.py +0 -0
  149. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/utils/__init__.py +0 -0
  150. {diffsptk-3.3.1 → diffsptk-3.5.0}/diffsptk/utils/private.py +0 -0
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: diffsptk
3
- Version: 3.3.1
3
+ Version: 3.5.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
@@ -25,8 +27,8 @@ Requires-Dist: scipy>=1.12.0
25
27
  Requires-Dist: soundfile>=0.10.2
26
28
  Requires-Dist: torch>=2.3.1
27
29
  Requires-Dist: torchaudio>=2.3.1
28
- Requires-Dist: torchcomp>=0.2.0
29
- Requires-Dist: torchlpc>=0.6.0
30
+ Requires-Dist: torchcomp<0.3.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
@@ -45,13 +47,15 @@ Description-Content-Type: text/markdown
45
47
 
46
48
  # diffsptk
47
49
 
48
- *diffsptk* is a differentiable version of [SPTK](https://github.com/sp-nitech/SPTK) based on the PyTorch framework.
50
+ *diffsptk* is a differentiable version of [SPTK](https://github.com/sp-nitech/SPTK) built on the PyTorch framework.
51
+ It provides various speech signal processing modules as PyTorch layers,
52
+ allowing users to integrate classic signal processing algorithms directly into neural network architectures and optimize them through backpropagation.
49
53
 
50
- [![Manual](https://img.shields.io/badge/docs-stable-blue.svg)](https://sp-nitech.github.io/diffsptk/3.3.1/)
54
+ [![Manual](https://img.shields.io/badge/docs-stable-blue.svg)](https://sp-nitech.github.io/diffsptk/stable/)
51
55
  [![Downloads](https://static.pepy.tech/badge/diffsptk)](https://pepy.tech/project/diffsptk)
52
56
  [![ClickPy](https://img.shields.io/badge/downloads-clickpy-yellow.svg)](https://clickpy.clickhouse.com/dashboard/diffsptk)
53
57
  [![Python Version](https://img.shields.io/pypi/pyversions/diffsptk.svg)](https://pypi.python.org/pypi/diffsptk)
54
- [![PyTorch Version](https://img.shields.io/badge/pytorch-2.3.1%20%7C%202.8.0-orange.svg)](https://pypi.python.org/pypi/diffsptk)
58
+ [![PyTorch Version](https://img.shields.io/badge/pytorch-2.3.1%20%7C%202.11.0-orange.svg)](https://pypi.python.org/pypi/diffsptk)
55
59
  [![PyPI Version](https://img.shields.io/pypi/v/diffsptk.svg)](https://pypi.python.org/pypi/diffsptk)
56
60
  [![Codecov](https://codecov.io/gh/sp-nitech/diffsptk/branch/master/graph/badge.svg)](https://app.codecov.io/gh/sp-nitech/diffsptk)
57
61
  [![License](https://img.shields.io/github/license/sp-nitech/diffsptk.svg)](https://github.com/sp-nitech/diffsptk/blob/master/LICENSE)
@@ -65,18 +69,19 @@ Description-Content-Type: text/markdown
65
69
 
66
70
  ## Documentation
67
71
 
68
- - See [this page](https://sp-nitech.github.io/diffsptk/3.3.1/) for the reference manual.
69
- - Our [paper](https://www.isca-speech.org/archive/ssw_2023/yoshimura23_ssw.html) is available on the ISCA Archive.
72
+ - [**Reference Manual**](https://sp-nitech.github.io/diffsptk/stable/) - Detailed API documentation and module specifications.
73
+ - [**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.
74
+ - [**Conference Paper**](https://www.isca-archive.org/ssw_2023/yoshimura23_ssw.html) - Technical background and implementation details available on the ISCA Archive.
70
75
 
71
76
  ## Installation
72
77
 
73
- The latest stable release can be installed through PyPI by running
78
+ The latest stable release can be installed via PyPI:
74
79
 
75
80
  ```sh
76
81
  pip install diffsptk
77
82
  ```
78
83
 
79
- The development release can be installed from the master branch:
84
+ Alternatively, the development version can be installed directly from the GitHub repository:
80
85
 
81
86
  ```sh
82
87
  pip install git+https://github.com/sp-nitech/diffsptk.git@master
@@ -259,7 +264,7 @@ error = (x_hat - x).abs().sum()
259
264
  print(error)
260
265
  ```
261
266
 
262
- ### Mel-spectrogram analysis and synthesis
267
+ ### Mel spectrogram analysis and synthesis
263
268
 
264
269
  ```python
265
270
  import diffsptk
@@ -276,7 +281,7 @@ x, sr = diffsptk.read("assets/data.wav")
276
281
  stft = diffsptk.STFT(frame_length=fl, frame_period=fp, fft_length=n_fft)
277
282
  X = stft(x)
278
283
 
279
- # Extract log mel-spectrogram.
284
+ # Extract log-mel spectrogram.
280
285
  fbank = diffsptk.FBANK(
281
286
  fft_length=n_fft,
282
287
  n_channel=n_channel,
@@ -1,12 +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.3.1/)
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
10
  [![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-2.3.1%20%7C%202.8.0-orange.svg)](https://pypi.python.org/pypi/diffsptk)
11
+ [![PyTorch Version](https://img.shields.io/badge/pytorch-2.3.1%20%7C%202.11.0-orange.svg)](https://pypi.python.org/pypi/diffsptk)
10
12
  [![PyPI Version](https://img.shields.io/pypi/v/diffsptk.svg)](https://pypi.python.org/pypi/diffsptk)
11
13
  [![Codecov](https://codecov.io/gh/sp-nitech/diffsptk/branch/master/graph/badge.svg)](https://app.codecov.io/gh/sp-nitech/diffsptk)
12
14
  [![License](https://img.shields.io/github/license/sp-nitech/diffsptk.svg)](https://github.com/sp-nitech/diffsptk/blob/master/LICENSE)
@@ -20,18 +22,19 @@
20
22
 
21
23
  ## Documentation
22
24
 
23
- - See [this page](https://sp-nitech.github.io/diffsptk/3.3.1/) for the reference manual.
24
- - Our [paper](https://www.isca-speech.org/archive/ssw_2023/yoshimura23_ssw.html) is available on the ISCA Archive.
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.
25
28
 
26
29
  ## Installation
27
30
 
28
- The latest stable release can be installed through PyPI by running
31
+ The latest stable release can be installed via PyPI:
29
32
 
30
33
  ```sh
31
34
  pip install diffsptk
32
35
  ```
33
36
 
34
- The development release can be installed from the master branch:
37
+ Alternatively, the development version can be installed directly from the GitHub repository:
35
38
 
36
39
  ```sh
37
40
  pip install git+https://github.com/sp-nitech/diffsptk.git@master
@@ -214,7 +217,7 @@ error = (x_hat - x).abs().sum()
214
217
  print(error)
215
218
  ```
216
219
 
217
- ### Mel-spectrogram analysis and synthesis
220
+ ### Mel spectrogram analysis and synthesis
218
221
 
219
222
  ```python
220
223
  import diffsptk
@@ -231,7 +234,7 @@ x, sr = diffsptk.read("assets/data.wav")
231
234
  stft = diffsptk.STFT(frame_length=fl, frame_period=fp, fft_length=n_fft)
232
235
  X = stft(x)
233
236
 
234
- # Extract log mel-spectrogram.
237
+ # Extract log-mel spectrogram.
235
238
  fbank = diffsptk.FBANK(
236
239
  fft_length=n_fft,
237
240
  n_channel=n_channel,
@@ -444,11 +444,12 @@ def dht(x: Tensor, dht_type: int = 2) -> Tensor:
444
444
 
445
445
  def drc(
446
446
  x: Tensor,
447
+ *,
448
+ sample_rate: int,
447
449
  threshold: float,
448
450
  ratio: float,
449
451
  attack_time: float,
450
452
  release_time: float,
451
- sample_rate: int,
452
453
  makeup_gain: float = 0,
453
454
  abs_max: float = 1,
454
455
  ) -> Tensor:
@@ -459,6 +460,9 @@ def drc(
459
460
  x : Tensor [shape=(..., T)]
460
461
  The input waveform.
461
462
 
463
+ sample_rate : int >= 1
464
+ The sample rate in Hz.
465
+
462
466
  threshold : float <= 0
463
467
  The threshold in dB.
464
468
 
@@ -471,9 +475,6 @@ def drc(
471
475
  release_time : float > 0
472
476
  The release time in msec.
473
477
 
474
- sample_rate : int >= 1
475
- The sample rate in Hz.
476
-
477
478
  makeup_gain : float >= 0
478
479
  The make-up gain in dB.
479
480
 
@@ -518,6 +519,82 @@ def dst(x: Tensor, dst_type: int = 2) -> Tensor:
518
519
  return nn.DiscreteSineTransform._func(x, dst_type=dst_type)
519
520
 
520
521
 
522
+ def dtw(
523
+ x: Tensor,
524
+ y: Tensor,
525
+ lengths: Tensor | None = None,
526
+ return_indices: bool = False,
527
+ metric: str | int = "euclidean",
528
+ p: int = 4,
529
+ softness: float = 1e-3,
530
+ ) -> Tensor | tuple[Tensor, list[Tensor]]:
531
+ """Compute dynamic time warping distance.
532
+
533
+ x : Tensor [shape=(B, T1, D) or (T1, D) or (T1,)]
534
+ The query vector sequence.
535
+
536
+ y : Tensor [shape=(B, T2, D), (T2, D) or (T2,)]
537
+ The reference vector sequence.
538
+
539
+ lengths : Tensor [shape=(B, 2)] or None
540
+ The lengths of the sequences.
541
+
542
+ return_indices : bool
543
+ If True, returns the indices of the viterbi path.
544
+
545
+ metric : ['manhattan', 'euclidean', 'squared-euclidean', 'symmetric-kl']
546
+ The metric to compute the distance between two vectors.
547
+
548
+ p : int in [0, 6]
549
+ The local path constraint type.
550
+
551
+ softness : float > 0
552
+ A smoothing parameter. The smaller value makes the output closer to the true
553
+ dynamic time warping distance, but the gradient vanishes.
554
+
555
+ Returns
556
+ -------
557
+ distance : Tensor [shape=(B,)]
558
+ The dynamic time warping distance.
559
+
560
+ indices : list[Tensor [shape=(T, 2)]] (optional)
561
+ The indices of the viterbi path for each batch.
562
+
563
+ """
564
+ return nn.DynamicTimeWarping._func(
565
+ x,
566
+ y,
567
+ lengths=lengths,
568
+ return_indices=return_indices,
569
+ metric=metric,
570
+ p=p,
571
+ softness=softness,
572
+ )
573
+
574
+
575
+ def dtw_merge(x: Tensor, y: Tensor, indices: Tensor) -> Tensor:
576
+ """Merge two sequences according to the given indices.
577
+
578
+ Parameters
579
+ ----------
580
+ x : Tensor [shape=(T1, D) or (T1,)]
581
+ The query vector sequence.
582
+
583
+ y : Tensor [shape=(T2, D) or (T2,)]
584
+ The reference vector sequence.
585
+
586
+ indices : Tensor [shape=(T, 2)]
587
+ The indices of the viterbi path.
588
+
589
+ Returns
590
+ -------
591
+ z : Tensor [shape=(T, 2D) or (T, 2)]
592
+ The merged vector sequence.
593
+
594
+ """
595
+ return nn.DynamicTimeWarping.merge(x=x, y=y, indices=indices)
596
+
597
+
521
598
  def entropy(p: Tensor, out_format: str = "nat") -> Tensor:
522
599
  """Calculate the entropy of a probability distribution.
523
600
 
@@ -545,7 +622,7 @@ def excite(
545
622
  voiced_region: str = "pulse",
546
623
  unvoiced_region: str = "gauss",
547
624
  polarity: str = "auto",
548
- init_phase: str = "zeros",
625
+ init_phase: str | float = "zeros",
549
626
  ) -> Tensor:
550
627
  """Generate a simple excitation signal.
551
628
 
@@ -561,14 +638,14 @@ def excite(
561
638
  'triangle', 'square']
562
639
  The type of voiced region.
563
640
 
564
- unvoiced_region : ['zeros', 'gauss', 'uniform']
641
+ unvoiced_region : ['zeros', 'gauss', 'm-sequence', 'uniform']
565
642
  The type of unvoiced region.
566
643
 
567
644
  polarity : ['auto', 'unipolar', 'bipolar']
568
645
  The polarity.
569
646
 
570
- init_phase : ['zeros', 'random']
571
- The initial phase.
647
+ init_phase : ['zeros', 'random'] or float
648
+ The initial phase in radians.
572
649
 
573
650
  Returns
574
651
  -------
@@ -586,6 +663,35 @@ def excite(
586
663
  )
587
664
 
588
665
 
666
+ def f0eval(
667
+ x: Tensor, y: Tensor, reduction: str = "mean", out_format: str = "f0-rmse-cent"
668
+ ) -> Tensor:
669
+ """Calculate F0 metric.
670
+
671
+ Parameters
672
+ ----------
673
+ x : Tensor [shape=(..., N)]
674
+ The input F0 in Hz.
675
+
676
+ y : Tensor [shape=(..., N)]
677
+ The target F0 in Hz.
678
+
679
+ reduction : ['none', 'mean', 'sum']
680
+ The reduction type.
681
+
682
+ out_format : ['f0-rmse-hz', 'f0-rmse-cent', 'f0-rmse-semitone', 'vuv-error-rate', \
683
+ 'vuv-error-percent', 'vuv-macro-f1-score']
684
+ The output format.
685
+
686
+ Returns
687
+ -------
688
+ out : Tensor [shape=(...,) or scalar]
689
+ The F0 metric.
690
+
691
+ """
692
+ return nn.F0Evaluation._func(x, y, reduction=reduction, out_format=out_format)
693
+
694
+
589
695
  def fbank(
590
696
  x: Tensor,
591
697
  n_channel: int,
@@ -598,7 +704,7 @@ def fbank(
598
704
  erb_factor: float | None = None,
599
705
  use_power: bool = False,
600
706
  out_format: str = "y",
601
- ) -> tuple[Tensor, Tensor] | Tensor:
707
+ ) -> Tensor | tuple[Tensor, Tensor]:
602
708
  """Apply mel-filter banks to the STFT.
603
709
 
604
710
  Parameters
@@ -1032,33 +1138,6 @@ def hilbert(x: Tensor, fft_length: int | None = None, dim: int = -1) -> Tensor:
1032
1138
  return nn.HilbertTransform._func(x, fft_length=fft_length, dim=dim)
1033
1139
 
1034
1140
 
1035
- def hilbert2(
1036
- x: Tensor,
1037
- fft_length: ArrayLike[int] | int | None = None,
1038
- dim: ArrayLike[int] = (-2, -1),
1039
- ) -> Tensor:
1040
- """Compute the analytic signal using the Hilbert transform.
1041
-
1042
- Parameters
1043
- ----------
1044
- x : Tensor [shape=(..., T1, T2, ...)]
1045
- The input signal.
1046
-
1047
- fft_length : int, list[int], or None
1048
- The number of FFT bins. If None, set to (:math:`T1`, :math:`T2`).
1049
-
1050
- dim : list[int]
1051
- The dimensions along which to take the Hilbert transform.
1052
-
1053
- Returns
1054
- -------
1055
- out : Tensor [shape=(..., T1, T2, ...)]
1056
- The analytic signal.
1057
-
1058
- """
1059
- return nn.TwoDimensionalHilbertTransform._func(x, fft_length=fft_length, dim=dim)
1060
-
1061
-
1062
1141
  def histogram(
1063
1142
  x: Tensor,
1064
1143
  n_bin: int = 10,
@@ -1586,7 +1665,8 @@ def levdur(r: Tensor, eps: float | None = None) -> Tensor:
1586
1665
  The autocorrelation.
1587
1666
 
1588
1667
  eps : float >= 0 or None
1589
- 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.
1590
1670
 
1591
1671
  Returns
1592
1672
  -------
@@ -1629,7 +1709,8 @@ def lpc(x: Tensor, lpc_order: int, eps: float | None = None) -> Tensor:
1629
1709
  The order of the LPC coefficients, :math:`M`.
1630
1710
 
1631
1711
  eps : float >= 0 or None
1632
- 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.
1633
1714
 
1634
1715
  Returns
1635
1716
  -------
@@ -1983,6 +2064,42 @@ def mdst(x: Tensor, frame_length: int = 400, window: str = "sine") -> Tensor:
1983
2064
  )
1984
2065
 
1985
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
+
1986
2103
  def mfcc(
1987
2104
  x: Tensor,
1988
2105
  mfcc_order: int,
@@ -2636,7 +2753,7 @@ def quantize(
2636
2753
  )
2637
2754
 
2638
2755
 
2639
- def rlevdur(a: Tensor) -> Tensor:
2756
+ def rlevdur(a: Tensor, n_fft: int = 512) -> Tensor:
2640
2757
  """Solve a Yule-Walker linear system given the LPC coefficients.
2641
2758
 
2642
2759
  Parameters
@@ -2644,13 +2761,16 @@ def rlevdur(a: Tensor) -> Tensor:
2644
2761
  a : Tensor [shape=(..., M+1)]
2645
2762
  The gain and the LPC coefficients.
2646
2763
 
2764
+ n_fft : int >> M
2765
+ The number of FFT bins. Accurate conversion requires a large value.
2766
+
2647
2767
  Returns
2648
2768
  -------
2649
2769
  out : Tensor [shape=(..., M+1)]
2650
2770
  The autocorrelation.
2651
2771
 
2652
2772
  """
2653
- return nn.ReverseLevinsonDurbin._func(a)
2773
+ return nn.ReverseLevinsonDurbin._func(a, n_fft=n_fft)
2654
2774
 
2655
2775
 
2656
2776
  def rmse(x: Tensor, y: Tensor, reduction: str = "mean") -> Tensor:
@@ -3128,7 +3248,12 @@ def zcross(
3128
3248
 
3129
3249
 
3130
3250
  def zerodf(
3131
- 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",
3132
3257
  ) -> Tensor:
3133
3258
  """Apply an all-zero digital filter.
3134
3259
 
@@ -3146,6 +3271,12 @@ def zerodf(
3146
3271
  ignore_gain : bool
3147
3272
  If True, perform filtering without the gain.
3148
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
+
3149
3280
  Returns
3150
3281
  -------
3151
3282
  out : Tensor [shape=(..., T)]
@@ -3153,5 +3284,10 @@ def zerodf(
3153
3284
 
3154
3285
  """
3155
3286
  return nn.AllZeroDigitalFilter._func(
3156
- 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,
3157
3293
  )
@@ -42,8 +42,11 @@ from .drc import DynamicRangeCompression
42
42
  from .drc import DynamicRangeCompression as DRC
43
43
  from .dst import DiscreteSineTransform
44
44
  from .dst import DiscreteSineTransform as DST
45
+ from .dtw import DynamicTimeWarping
46
+ from .dtw import DynamicTimeWarping as DTW
45
47
  from .entropy import Entropy
46
48
  from .excite import ExcitationGeneration
49
+ from .f0eval import F0Evaluation
47
50
  from .fbank import MelFilterBankAnalysis
48
51
  from .fbank import MelFilterBankAnalysis as FBANK
49
52
  from .fftcep import CepstralAnalysis
@@ -59,7 +62,6 @@ from .gnorm import GeneralizedCepstrumGainNormalization
59
62
  from .griffin import GriffinLim
60
63
  from .grpdelay import GroupDelay
61
64
  from .hilbert import HilbertTransform
62
- from .hilbert2 import TwoDimensionalHilbertTransform
63
65
  from .histogram import Histogram
64
66
  from .ialaw import ALawExpansion
65
67
  from .ica import IndependentComponentAnalysis
@@ -114,6 +116,7 @@ from .mdct import ModifiedDiscreteCosineTransform
114
116
  from .mdct import ModifiedDiscreteCosineTransform as MDCT
115
117
  from .mdst import ModifiedDiscreteSineTransform
116
118
  from .mdst import ModifiedDiscreteSineTransform as MDST
119
+ from .medfilt import MedianFilter
117
120
  from .mfcc import MelFrequencyCepstralCoefficientsAnalysis
118
121
  from .mfcc import MelFrequencyCepstralCoefficientsAnalysis as MFCC
119
122
  from .mgc2mgc import MelGeneralizedCepstrumToMelGeneralizedCepstrum
@@ -62,8 +62,9 @@ class Autocorrelation(BaseFunctionalModule):
62
62
 
63
63
  Examples
64
64
  --------
65
- >>> x = diffsptk.ramp(4)
65
+ >>> import diffsptk
66
66
  >>> acorr = diffsptk.Autocorrelation(5, 3)
67
+ >>> x = diffsptk.ramp(4)
67
68
  >>> r = acorr(x)
68
69
  >>> r
69
70
  tensor([30.0000, 20.0000, 11.0000, 4.0000])
@@ -100,10 +101,9 @@ class Autocorrelation(BaseFunctionalModule):
100
101
  elif out_format in (2, "biased"):
101
102
  formatter = lambda x: x / frame_length
102
103
  elif out_format in (3, "unbiased"):
103
- formatter = lambda x: x / (
104
- torch.arange(
105
- frame_length, frame_length - acr_order - 1, -1, device=x.device
106
- )
104
+ n = frame_length - acr_order - 1
105
+ formatter = lambda x: (
106
+ x / (torch.arange(frame_length, n, -1, device=x.device))
107
107
  )
108
108
  else:
109
109
  raise ValueError(f"out_format {out_format} is not supported.")
@@ -73,14 +73,13 @@ class AutocorrelationToCompositeSinusoidalModelCoefficients(BaseFunctionalModule
73
73
 
74
74
  Examples
75
75
  --------
76
- >>> x = diffsptk.nrand(4)
77
- >>> x
78
- tensor([ 0.0165, -2.3693, 0.1375, -0.2262, 1.3307])
76
+ >>> import diffsptk
79
77
  >>> acorr = diffsptk.Autocorrelation(5, 3)
80
78
  >>> acr2csm = diffsptk.AutocorrelationToCompositeSinusoidalModelCoefficients(3)
79
+ >>> x = diffsptk.ramp(4)
81
80
  >>> c = acr2csm(acorr(x))
82
81
  >>> c
83
- tensor([0.9028, 2.5877, 3.8392, 3.6153])
82
+ tensor([ 0.5261, 2.1403, 25.7668, 4.2332])
84
83
 
85
84
  """
86
85
  check_size(r.size(-1), self.in_dim, "dimension of autocorrelation")
@@ -137,22 +136,16 @@ class AutocorrelationToCompositeSinusoidalModelCoefficients(BaseFunctionalModule
137
136
 
138
137
  @staticmethod
139
138
  def _forward(r: torch.Tensor, C: torch.Tensor) -> torch.Tensor:
140
- if r.dtype != torch.double or C.dtype != torch.double:
141
- raise ValueError(
142
- "Only double precision is supported "
143
- f"(input: {r.dtype}, module: {C.dtype})."
144
- )
145
-
146
139
  u = torch.matmul(r, C)
147
140
  u1, u2 = torch.tensor_split(u, 2, dim=-1)
148
141
 
149
142
  U = hankel(-u)
150
- p = torch.matmul(U.inverse(), u2.unsqueeze(-1)).squeeze(-1)
143
+ p = torch.linalg.solve(U, u2.unsqueeze(-1)).squeeze(-1)
151
144
  x = PolynomialToRoots._func(F.pad(p.flip(-1), (1, 0), value=1))
152
145
  x, _ = torch.sort(x.real, descending=True)
153
146
  w = torch.acos(x)
154
147
 
155
148
  V = vander(x)
156
- m = torch.matmul(V.inverse(), u1.unsqueeze(-1)).squeeze(-1)
149
+ m = torch.linalg.solve(V, u1.unsqueeze(-1)).squeeze(-1)
157
150
  c = torch.cat((w, m), dim=-1)
158
151
  return c
@@ -57,8 +57,9 @@ class ALawCompression(BaseFunctionalModule):
57
57
 
58
58
  Examples
59
59
  --------
60
- >>> x = diffsptk.ramp(4)
60
+ >>> import diffsptk
61
61
  >>> alaw = diffsptk.ALawCompression(4)
62
+ >>> x = diffsptk.ramp(4)
62
63
  >>> y = alaw(x)
63
64
  >>> y
64
65
  tensor([0.0000, 2.9868, 3.4934, 3.7897, 4.0000])
@@ -38,7 +38,7 @@ class Aperiodicity(BaseNonFunctionalModule):
38
38
  The frame period in samples, :math:`P`.
39
39
 
40
40
  sample_rate : int >= 8000
41
- The sample rate in Hz.
41
+ The sample rate in Hz. If **algorithm** is 'd4c', it must be at least 12000 Hz.
42
42
 
43
43
  fft_length : int >= 16 or None
44
44
  The size of double-sided aperiodicity, :math:`L`. If None, the band aperiodicity
@@ -138,15 +138,16 @@ class Aperiodicity(BaseNonFunctionalModule):
138
138
 
139
139
  Examples
140
140
  --------
141
- >>> x = diffsptk.sin(1000, 80)
142
- >>> pitch = diffsptk.Pitch(160, 8000, out_format="f0")
141
+ >>> import diffsptk
142
+ >>> pitch = diffsptk.Pitch(160, 16000, out_format="f0")
143
+ >>> aperiodicity = diffsptk.Aperiodicity(160, 16000, 1024)
144
+ >>> x = diffsptk.sin(2000, 80)
143
145
  >>> f0 = pitch(x)
144
146
  >>> f0.shape
145
- torch.Size([7])
146
- >>> aperiodicity = diffsptk.Aperiodicity(160, 16000, 1024)
147
+ torch.Size([13])
147
148
  >>> ap = aperiodicity(x, f0)
148
149
  >>> ap.shape
149
- torch.Size([7, 513])
150
+ torch.Size([13, 513])
150
151
 
151
152
  """
152
153
  d = x.dim()
@@ -461,6 +462,13 @@ class AperiodicityExtractionByD4C(nn.Module):
461
462
  ) -> None:
462
463
  super().__init__()
463
464
 
465
+ if sample_rate < 12000:
466
+ raise ValueError("sample_rate must be at least 12000 Hz.")
467
+ if threshold < 0:
468
+ raise ValueError("threshold must be non-negative.")
469
+ if default_f0 <= 0:
470
+ raise ValueError("default_f0 must be positive.")
471
+
464
472
  self.frame_period = frame_period
465
473
  self.sample_rate = sample_rate
466
474
  self.threshold = threshold
@@ -77,12 +77,13 @@ class MLSADigitalFilterCoefficientsToMelCepstrum(BaseFunctionalModule):
77
77
 
78
78
  Examples
79
79
  --------
80
- >>> b = diffsptk.ramp(4)
80
+ >>> import diffsptk
81
81
  >>> mc2b = diffsptk.MelCepstrumToMLSADigitalFilterCoefficients(4, 0.3)
82
82
  >>> b2mc = diffsptk.MLSADigitalFilterCoefficientsToMelCepstrum(4, 0.3)
83
+ >>> b = diffsptk.ramp(1, 5)
83
84
  >>> b2 = mc2b(b2mc(b))
84
85
  >>> b2
85
- tensor([0.0000, 1.0000, 2.0000, 3.0000, 4.0000])
86
+ tensor([1.0000, 2.0000, 3.0000, 4.0000, 5.0000])
86
87
 
87
88
  """
88
89
  check_size(b.size(-1), self.in_dim, "dimension of cepstrum")