diffsptk 2.0.0__tar.gz → 2.0.1__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 (108) hide show
  1. {diffsptk-2.0.0 → diffsptk-2.0.1}/.gitignore +1 -2
  2. diffsptk-2.0.1/CITATION.cff +26 -0
  3. {diffsptk-2.0.0 → diffsptk-2.0.1}/PKG-INFO +7 -7
  4. {diffsptk-2.0.0 → diffsptk-2.0.1}/README.md +4 -4
  5. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/functional.py +48 -2
  6. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/misc/utils.py +5 -3
  7. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/__init__.py +2 -0
  8. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/acorr.py +7 -7
  9. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/alaw.py +2 -2
  10. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/ap.py +8 -8
  11. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/b2mc.py +2 -2
  12. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/c2acr.py +2 -2
  13. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/c2mpir.py +2 -2
  14. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/c2ndps.py +2 -2
  15. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/cdist.py +2 -2
  16. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/cqt.py +3 -3
  17. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/dct.py +2 -2
  18. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/decimate.py +2 -2
  19. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/delay.py +2 -2
  20. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/delta.py +2 -2
  21. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/dequantize.py +4 -4
  22. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/df2.py +2 -2
  23. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/dfs.py +2 -2
  24. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/entropy.py +5 -5
  25. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/excite.py +4 -4
  26. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/fbank.py +5 -5
  27. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/fftcep.py +2 -2
  28. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/frame.py +2 -2
  29. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/freqt.py +2 -2
  30. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/freqt2.py +2 -2
  31. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/gmm.py +4 -4
  32. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/gnorm.py +2 -2
  33. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/grpdelay.py +2 -2
  34. diffsptk-2.0.1/diffsptk/modules/histogram.py +114 -0
  35. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/ialaw.py +2 -2
  36. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/icqt.py +5 -5
  37. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/idct.py +2 -2
  38. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/ifreqt2.py +2 -2
  39. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/ignorm.py +2 -2
  40. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/imglsadf.py +2 -2
  41. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/imsvq.py +2 -2
  42. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/interpolate.py +2 -2
  43. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/ipqmf.py +2 -2
  44. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/istft.py +2 -2
  45. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/iulaw.py +3 -3
  46. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/ivq.py +2 -2
  47. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/lar2par.py +2 -2
  48. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/lbg.py +2 -2
  49. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/levdur.py +2 -2
  50. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/linear_intpl.py +4 -4
  51. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/lpc.py +2 -2
  52. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/lpc2lsp.py +6 -6
  53. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/lpc2par.py +2 -2
  54. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/lpccheck.py +2 -2
  55. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/lsp2lpc.py +2 -2
  56. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/lsp2sp.py +6 -6
  57. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/lspcheck.py +2 -2
  58. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/magic_intpl.py +5 -5
  59. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/mc2b.py +2 -2
  60. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/mcep.py +3 -3
  61. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/mcpf.py +2 -2
  62. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/mfcc.py +6 -6
  63. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/mgc2mgc.py +7 -7
  64. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/mgc2sp.py +9 -9
  65. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/mgcep.py +5 -5
  66. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/mglsadf.py +5 -5
  67. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/mlpg.py +2 -2
  68. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/mlsacheck.py +2 -2
  69. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/mpir2c.py +2 -2
  70. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/msvq.py +2 -2
  71. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/ndps2c.py +2 -2
  72. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/norm0.py +2 -2
  73. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/par2lar.py +2 -2
  74. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/par2lpc.py +2 -2
  75. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/pca.py +5 -5
  76. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/phase.py +2 -2
  77. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/pitch.py +9 -9
  78. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/plp.py +6 -6
  79. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/pol_root.py +2 -2
  80. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/poledf.py +2 -2
  81. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/pqmf.py +2 -2
  82. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/quantize.py +4 -4
  83. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/rlevdur.py +3 -3
  84. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/rmse.py +2 -2
  85. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/root_pol.py +4 -4
  86. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/smcep.py +3 -3
  87. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/snr.py +2 -2
  88. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/spec.py +6 -6
  89. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/stft.py +2 -2
  90. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/ulaw.py +2 -2
  91. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/unframe.py +3 -3
  92. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/vq.py +2 -2
  93. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/window.py +11 -11
  94. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/yingram.py +3 -3
  95. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/zcross.py +13 -7
  96. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/modules/zerodf.py +2 -2
  97. diffsptk-2.0.1/diffsptk/version.py +1 -0
  98. {diffsptk-2.0.0 → diffsptk-2.0.1}/pyproject.toml +6 -3
  99. diffsptk-2.0.0/.github/workflows/ci.yml +0 -57
  100. diffsptk-2.0.0/.github/workflows/stale.yml +0 -23
  101. diffsptk-2.0.0/Makefile +0 -122
  102. diffsptk-2.0.0/UPLOAD +0 -18
  103. diffsptk-2.0.0/codecov.yml +0 -11
  104. diffsptk-2.0.0/diffsptk/version.py +0 -1
  105. {diffsptk-2.0.0 → diffsptk-2.0.1}/LICENSE +0 -0
  106. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/__init__.py +0 -0
  107. {diffsptk-2.0.0 → diffsptk-2.0.1}/diffsptk/misc/__init__.py +0 -0
  108. {diffsptk-2.0.0 → diffsptk-2.0.1}/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.0.1
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,6 +17,7 @@ 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
23
  Requires-Dist: numpy
@@ -28,7 +29,6 @@ Requires-Dist: torchlpc>=0.2.0
28
29
  Requires-Dist: vector-quantize-pytorch<=1.12.12,>=0.8.0
29
30
  Provides-Extra: dev
30
31
  Requires-Dist: build; extra == 'dev'
31
- Requires-Dist: grayskull; extra == 'dev'
32
32
  Requires-Dist: isort; extra == 'dev'
33
33
  Requires-Dist: numpydoc; extra == 'dev'
34
34
  Requires-Dist: pydata-sphinx-theme; extra == 'dev'
@@ -44,10 +44,10 @@ diffsptk
44
44
  *diffsptk* is a differentiable version of [SPTK](https://github.com/sp-nitech/SPTK) based on the PyTorch framework.
45
45
 
46
46
  [![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/)
47
+ [![Stable Manual](https://img.shields.io/badge/docs-stable-blue.svg)](https://sp-nitech.github.io/diffsptk/2.0.1/)
48
48
  [![Downloads](https://static.pepy.tech/badge/diffsptk)](https://pepy.tech/project/diffsptk)
49
49
  [![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)
50
+ [![PyTorch Version](https://img.shields.io/badge/pytorch-1.11.0%20%7C%202.3.0-orange.svg)](https://pypi.python.org/pypi/diffsptk)
51
51
  [![PyPI Version](https://img.shields.io/pypi/v/diffsptk.svg)](https://pypi.python.org/pypi/diffsptk)
52
52
  [![Codecov](https://codecov.io/gh/sp-nitech/diffsptk/branch/master/graph/badge.svg)](https://app.codecov.io/gh/sp-nitech/diffsptk)
53
53
  [![License](https://img.shields.io/github/license/sp-nitech/diffsptk.svg)](https://github.com/sp-nitech/diffsptk/blob/master/LICENSE)
@@ -259,8 +259,8 @@ License
259
259
  This software is released under the Apache License 2.0.
260
260
 
261
261
 
262
- Reference
263
- ---------
262
+ Citation
263
+ --------
264
264
  ```bibtex
265
265
  @InProceedings{sp-nitech2023sptk,
266
266
  author = {Takenori Yoshimura and Takato Fujimoto and Keiichiro Oura and Keiichi Tokuda},
@@ -3,10 +3,10 @@ diffsptk
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.0.1/)
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.11.0%20%7C%202.3.0-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)
@@ -218,8 +218,8 @@ License
218
218
  This software is released under the Apache License 2.0.
219
219
 
220
220
 
221
- Reference
222
- ---------
221
+ Citation
222
+ --------
223
223
  ```bibtex
224
224
  @InProceedings{sp-nitech2023sptk,
225
225
  author = {Takenori Yoshimura and Takato Fujimoto and Keiichiro Oura and Keiichi Tokuda},
@@ -599,6 +599,46 @@ def grpdelay(b=None, a=None, *, fft_length=512, alpha=1, gamma=1, **kwargs):
599
599
  )
600
600
 
601
601
 
602
+ def histogram(x, n_bin=10, lower_bound=0, upper_bound=1, norm=False, softness=1e-3):
603
+ """Compute histogram.
604
+
605
+ Parameters
606
+ ----------
607
+ x : Tensor [shape=(..., T)]
608
+ Input data.
609
+
610
+ n_bin : int >= 1
611
+ Number of bins, :math:`K`.
612
+
613
+ lower_bound : float < U
614
+ Lower bound of the histogram, :math:`L`.
615
+
616
+ upper_bound : float > L
617
+ Upper bound of the histogram, :math:`U`.
618
+
619
+ norm : bool
620
+ If True, normalize the histogram.
621
+
622
+ softness : float > 0
623
+ A smoothing parameter. The smaller value makes the output closer to the true
624
+ histogram, but the gradient vanishes.
625
+
626
+ Returns
627
+ -------
628
+ out : Tensor [shape=(..., K)]
629
+ Histogram in [L, U].
630
+
631
+ """
632
+ return nn.Histogram._func(
633
+ x,
634
+ n_bin=n_bin,
635
+ lower_bound=lower_bound,
636
+ upper_bound=upper_bound,
637
+ norm=norm,
638
+ softness=softness,
639
+ )
640
+
641
+
602
642
  def ialaw(y, abs_max=1, a=87.6):
603
643
  """Expand waveform by A-law algorithm.
604
644
 
@@ -1846,7 +1886,7 @@ def yingram(x, sample_rate=22050, lag_min=22, lag_max=None, n_bin=20):
1846
1886
  )
1847
1887
 
1848
1888
 
1849
- def zcross(x, frame_length, norm=False):
1889
+ def zcross(x, frame_length, norm=False, softness=1e-3):
1850
1890
  """Compute zero-crossing rate.
1851
1891
 
1852
1892
  Parameters
@@ -1860,13 +1900,19 @@ def zcross(x, frame_length, norm=False):
1860
1900
  norm : bool
1861
1901
  If True, divide zero-crossing rate by frame length.
1862
1902
 
1903
+ softness : float > 0
1904
+ A smoothing parameter. The smaller value makes the output closer to the true
1905
+ zero-crossing rate, but the gradient vanishes.
1906
+
1863
1907
  Returns
1864
1908
  -------
1865
1909
  out : Tensor [shape=(..., T/L)]
1866
1910
  Zero-crossing rate.
1867
1911
 
1868
1912
  """
1869
- return nn.ZeroCrossingAnalysis._func(x, frame_length=frame_length, norm=norm)
1913
+ return nn.ZeroCrossingAnalysis._func(
1914
+ x, frame_length=frame_length, norm=norm, softness=softness
1915
+ )
1870
1916
 
1871
1917
 
1872
1918
  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
 
@@ -20,6 +20,7 @@ from .dfs import InfiniteImpulseResponseDigitalFilter as IIR
20
20
  from .entropy import Entropy
21
21
  from .excite import ExcitationGeneration
22
22
  from .fbank import MelFilterBankAnalysis
23
+ from .fbank import MelFilterBankAnalysis as FBANK
23
24
  from .fftcep import CepstralAnalysis
24
25
  from .frame import Frame
25
26
  from .freqt import FrequencyTransform
@@ -28,6 +29,7 @@ from .gmm import GaussianMixtureModeling
28
29
  from .gmm import GaussianMixtureModeling as GMM
29
30
  from .gnorm import GeneralizedCepstrumGainNormalization
30
31
  from .grpdelay import GroupDelay
32
+ from .histogram import Histogram
31
33
  from .ialaw import ALawExpansion
32
34
  from .icqt import InverseConstantQTransform
33
35
  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()
@@ -17,7 +17,7 @@
17
17
  import math
18
18
 
19
19
  import torch
20
- import torch.nn as nn
20
+ from torch import nn
21
21
 
22
22
 
23
23
  class ALawCompression(nn.Module):
@@ -35,7 +35,7 @@ class ALawCompression(nn.Module):
35
35
  """
36
36
 
37
37
  def __init__(self, abs_max=1, a=87.6):
38
- super(ALawCompression, self).__init__()
38
+ super().__init__()
39
39
 
40
40
  assert 0 < abs_max
41
41
  assert 1 <= a
@@ -16,7 +16,7 @@
16
16
 
17
17
  import numpy as np
18
18
  import torch
19
- import torch.nn as nn
19
+ from torch import nn
20
20
  import torch.nn.functional as F
21
21
 
22
22
  from ..misc.utils import UNVOICED_SYMBOL
@@ -67,7 +67,7 @@ class Aperiodicity(nn.Module):
67
67
  out_format="a",
68
68
  **kwargs,
69
69
  ):
70
- super(Aperiodicity, self).__init__()
70
+ super().__init__()
71
71
 
72
72
  assert 1 <= frame_period
73
73
  assert 1 <= sample_rate
@@ -79,13 +79,13 @@ class Aperiodicity(nn.Module):
79
79
  else:
80
80
  raise ValueError(f"algorithm {algorithm} is not supported.")
81
81
 
82
- if out_format == 0 or out_format == "a":
82
+ if out_format in (0, "a"):
83
83
  self.convert = lambda x: x
84
- elif out_format == 1 or out_format == "p":
84
+ elif out_format in (1, "p"):
85
85
  self.convert = lambda x: 1 - x
86
- elif out_format == 2 or out_format == "a/p":
86
+ elif out_format in (2, "a/p"):
87
87
  self.convert = lambda x: x / (1 - x)
88
- elif out_format == 3 or out_format == "p/a":
88
+ elif out_format in (3, "p/a"):
89
89
  self.convert = lambda x: (1 - x) / x
90
90
  else:
91
91
  raise ValueError(f"out_format {out_format} is not supported.")
@@ -149,7 +149,7 @@ class AperiodicityExtractionByTandem(nn.Module):
149
149
  window_length_ms=30,
150
150
  eps=1e-5,
151
151
  ):
152
- super(AperiodicityExtractionByTandem, self).__init__()
152
+ super().__init__()
153
153
 
154
154
  assert fft_length % 2 == 0
155
155
  assert 0 <= lower_bound < upper_bound <= 1
@@ -246,7 +246,7 @@ class AperiodicityExtractionByTandem(nn.Module):
246
246
 
247
247
  H = torch.cat((H_alpha, H_beta), dim=-1) # (B, N, J, 6)
248
248
  w = self.window[i, : self.segment_length[i]] # (J,)
249
- Hw = H.mT * w # (B, N, 6, J)
249
+ Hw = H.transpose(-2, -1) * w # (B, N, 6, J)
250
250
  R = torch.matmul(Hw, H) # (B, N, 6, 6)
251
251
 
252
252
  index_gamma = origin.unsqueeze(-1) + j[..., 1:-1] # (B, N, J)
@@ -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
  import torch.nn.functional as F
20
20
 
21
21
  from ..misc.utils import check_size
@@ -37,7 +37,7 @@ class MLSADigitalFilterCoefficientsToMelCepstrum(nn.Module):
37
37
  """
38
38
 
39
39
  def __init__(self, cep_order, alpha=0):
40
- super(MLSADigitalFilterCoefficientsToMelCepstrum, self).__init__()
40
+ super().__init__()
41
41
 
42
42
  assert 0 <= cep_order
43
43
  assert abs(alpha) < 1
@@ -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
 
@@ -38,7 +38,7 @@ class CepstrumToAutocorrelation(nn.Module):
38
38
  """
39
39
 
40
40
  def __init__(self, cep_order, acr_order, n_fft=512):
41
- super(CepstrumToAutocorrelation, self).__init__()
41
+ super().__init__()
42
42
 
43
43
  assert 0 <= cep_order
44
44
  assert 0 <= acr_order
@@ -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 cexp
21
21
  from ..misc.utils import check_size
@@ -39,7 +39,7 @@ class CepstrumToMinimumPhaseImpulseResponse(nn.Module):
39
39
  """
40
40
 
41
41
  def __init__(self, cep_order, ir_length, n_fft=512):
42
- super(CepstrumToMinimumPhaseImpulseResponse, self).__init__()
42
+ super().__init__()
43
43
 
44
44
  assert 0 <= cep_order
45
45
  assert 1 <= ir_length
@@ -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
  from ..misc.utils import to
@@ -36,7 +36,7 @@ class CepstrumToNegativeDerivativeOfPhaseSpectrum(nn.Module):
36
36
  """
37
37
 
38
38
  def __init__(self, cep_order, fft_length):
39
- super(CepstrumToNegativeDerivativeOfPhaseSpectrum, self).__init__()
39
+ super().__init__()
40
40
 
41
41
  assert 0 <= cep_order
42
42
  assert max(1, cep_order) <= fft_length // 2
@@ -17,7 +17,7 @@
17
17
  import math
18
18
 
19
19
  import torch
20
- import torch.nn as nn
20
+ from torch import nn
21
21
 
22
22
 
23
23
  class CepstralDistance(nn.Module):
@@ -38,7 +38,7 @@ class CepstralDistance(nn.Module):
38
38
  """
39
39
 
40
40
  def __init__(self, full=False, reduction="mean", eps=1e-8):
41
- super(CepstralDistance, self).__init__()
41
+ super().__init__()
42
42
 
43
43
  assert reduction in ("none", "mean", "batchmean", "sum")
44
44
  assert 0 <= eps
@@ -32,7 +32,7 @@
32
32
 
33
33
  import numpy as np
34
34
  import torch
35
- import torch.nn as nn
35
+ from torch import nn
36
36
  import torchaudio
37
37
 
38
38
  from ..misc.utils import Lambda
@@ -96,12 +96,12 @@ class ConstantQTransform(nn.Module):
96
96
  tuning=0,
97
97
  filter_scale=1,
98
98
  norm=1,
99
- sparsity=0.01,
99
+ sparsity=1e-2,
100
100
  window="hann",
101
101
  scale=True,
102
102
  **kwargs,
103
103
  ):
104
- super(ConstantQTransform, self).__init__()
104
+ super().__init__()
105
105
 
106
106
  import librosa
107
107
 
@@ -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
  from ..misc.utils import to
@@ -33,7 +33,7 @@ class DiscreteCosineTransform(nn.Module):
33
33
  """
34
34
 
35
35
  def __init__(self, dct_length):
36
- super(DiscreteCosineTransform, self).__init__()
36
+ super().__init__()
37
37
 
38
38
  assert 1 <= dct_length
39
39
 
@@ -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
 
21
21
  class Decimation(nn.Module):
@@ -36,7 +36,7 @@ class Decimation(nn.Module):
36
36
  """
37
37
 
38
38
  def __init__(self, period, start=0, dim=-1):
39
- super(Decimation, self).__init__()
39
+ super().__init__()
40
40
 
41
41
  assert 1 <= period
42
42
  assert 0 <= start
@@ -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
 
21
21
  class Delay(nn.Module):
@@ -36,7 +36,7 @@ class Delay(nn.Module):
36
36
  """
37
37
 
38
38
  def __init__(self, start, keeplen=False, dim=-1):
39
- super(Delay, self).__init__()
39
+ super().__init__()
40
40
 
41
41
  self.start = start
42
42
  self.keeplen = keeplen
@@ -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
  import torch.nn.functional as F
20
20
 
21
21
  from ..misc.utils import to
@@ -36,7 +36,7 @@ class Delta(nn.Module):
36
36
  """
37
37
 
38
38
  def __init__(self, seed=[[-0.5, 0, 0.5], [1, -2, 1]], static_out=True):
39
- super(Delta, self).__init__()
39
+ super().__init__()
40
40
 
41
41
  self.register_buffer("window", self._precompute(seed, static_out))
42
42
 
@@ -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
 
21
21
  class InverseUniformQuantization(nn.Module):
@@ -36,7 +36,7 @@ class InverseUniformQuantization(nn.Module):
36
36
  """
37
37
 
38
38
  def __init__(self, abs_max=1, n_bit=8, quantizer="mid-rise"):
39
- super(InverseUniformQuantization, self).__init__()
39
+ super().__init__()
40
40
 
41
41
  assert 0 < abs_max
42
42
  assert 1 <= n_bit
@@ -85,10 +85,10 @@ class InverseUniformQuantization(nn.Module):
85
85
 
86
86
  @staticmethod
87
87
  def _precompute(n_bit, quantizer):
88
- if quantizer == 0 or quantizer == "mid-rise":
88
+ if quantizer in (0, "mid-rise"):
89
89
  level = 1 << n_bit
90
90
  return level, lambda y: y - (level // 2 - 0.5)
91
- elif quantizer == 1 or quantizer == "mid-tread":
91
+ elif quantizer in (1, "mid-tread"):
92
92
  level = (1 << n_bit) - 1
93
93
  return level, lambda y: y - (level // 2)
94
94
  raise ValueError(f"quantizer {quantizer} is not supported.")
@@ -16,7 +16,7 @@
16
16
 
17
17
  import math
18
18
 
19
- import torch.nn as nn
19
+ from torch import nn
20
20
 
21
21
  from .dfs import InfiniteImpulseResponseDigitalFilter
22
22
 
@@ -56,7 +56,7 @@ class SecondOrderDigitalFilter(nn.Module):
56
56
  zero_bandwidth=None,
57
57
  **kwargs,
58
58
  ):
59
- super(SecondOrderDigitalFilter, self).__init__()
59
+ super().__init__()
60
60
 
61
61
  def get_filter_coefficients(frequency, bandwidth, sample_rate):
62
62
  assert 0 < frequency
@@ -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
  import torch.nn.functional as F
20
20
 
21
21
  from ..misc.utils import iir
@@ -44,7 +44,7 @@ class InfiniteImpulseResponseDigitalFilter(nn.Module):
44
44
  """
45
45
 
46
46
  def __init__(self, b=None, a=None, ir_length=None, learnable=False):
47
- super(InfiniteImpulseResponseDigitalFilter, self).__init__()
47
+ super().__init__()
48
48
 
49
49
  if b is None:
50
50
  b = [1]
@@ -17,7 +17,7 @@
17
17
  import math
18
18
 
19
19
  import torch
20
- import torch.nn as nn
20
+ from torch import nn
21
21
 
22
22
 
23
23
  class Entropy(nn.Module):
@@ -32,7 +32,7 @@ class Entropy(nn.Module):
32
32
  """
33
33
 
34
34
  def __init__(self, out_format="nat"):
35
- super(Entropy, self).__init__()
35
+ super().__init__()
36
36
 
37
37
  self.const = self._precompute(out_format)
38
38
 
@@ -74,10 +74,10 @@ class Entropy(nn.Module):
74
74
 
75
75
  @staticmethod
76
76
  def _precompute(out_format):
77
- if out_format == 0 or out_format == "bit":
77
+ if out_format in (0, "bit"):
78
78
  return math.log2(math.e)
79
- elif out_format == 1 or out_format == "nat":
79
+ elif out_format in (1, "nat"):
80
80
  return 1
81
- elif out_format == 2 or out_format == "dit":
81
+ elif out_format in (2, "dit"):
82
82
  return math.log10(math.e)
83
83
  raise ValueError(f"out_format {out_format} is not supported.")
@@ -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
  import torch.nn.functional as F
20
20
 
21
21
  from ..misc.utils import TWO_PI
@@ -41,7 +41,7 @@ class ExcitationGeneration(nn.Module):
41
41
  """
42
42
 
43
43
  def __init__(self, frame_period, voiced_region="pulse", unvoiced_region="gauss"):
44
- super(ExcitationGeneration, self).__init__()
44
+ super().__init__()
45
45
 
46
46
  assert 1 <= frame_period
47
47
  assert voiced_region in ("pulse", "sinusoidal", "sawtooth")
@@ -91,10 +91,10 @@ class ExcitationGeneration(nn.Module):
91
91
 
92
92
  # Interpolate pitch.
93
93
  if p.dim() != 1:
94
- p = p.mT
94
+ p = p.transpose(-2, -1)
95
95
  p = LinearInterpolation._func(p, frame_period)
96
96
  if p.dim() != 1:
97
- p = p.mT
97
+ p = p.transpose(-2, -1)
98
98
  p *= mask
99
99
 
100
100
  # Compute phase.