diffsptk 3.2.0__tar.gz → 3.3.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.
- {diffsptk-3.2.0 → diffsptk-3.3.1}/.gitignore +4 -0
- {diffsptk-3.2.0 → diffsptk-3.3.1}/PKG-INFO +56 -30
- {diffsptk-3.2.0 → diffsptk-3.3.1}/README.md +55 -29
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/functional.py +103 -7
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/__init__.py +3 -0
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/acorr.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/acr2csm.py +20 -6
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/alaw.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/ap.py +34 -12
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/b2mc.py +17 -5
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/c2acr.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/c2mpir.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/c2ndps.py +17 -5
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/cdist.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/chroma.py +12 -5
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/cqt.py +17 -7
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/csm2acr.py +16 -5
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/dct.py +20 -8
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/decimate.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/delay.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/delta.py +12 -4
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/dequantize.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/df2.py +15 -3
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/dfs.py +17 -6
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/dht.py +19 -7
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/drc.py +20 -8
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/dst.py +19 -7
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/entropy.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/excite.py +13 -4
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/fbank.py +109 -36
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/fftcep.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/fftr.py +16 -6
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/frame.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/freqt.py +18 -5
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/freqt2.py +12 -4
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/gammatone.py +16 -10
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/gmm.py +17 -8
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/gnorm.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/griffin.py +25 -8
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/grpdelay.py +12 -4
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/hilbert.py +17 -5
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/hilbert2.py +15 -5
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/histogram.py +12 -4
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/ialaw.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/ica.py +13 -3
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/icqt.py +17 -5
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/idct.py +17 -5
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/idht.py +17 -5
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/idst.py +17 -5
- diffsptk-3.3.1/diffsptk/modules/ifbank.py +193 -0
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/ifftr.py +24 -8
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/ifreqt2.py +12 -4
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/igammatone.py +20 -7
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/ignorm.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/imdct.py +29 -3
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/imdst.py +10 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/interpolate.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/ipnorm.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/ipqmf.py +10 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/is2par.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/istft.py +26 -6
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/iulaw.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/lar2par.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/lbg.py +6 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/levdur.py +22 -8
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/linear_intpl.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/lpc.py +22 -7
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/lpc2lsp.py +12 -4
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/lpc2par.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/lpccheck.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/lsp2lpc.py +12 -4
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/lsp2sp.py +12 -4
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/lspcheck.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/magic_intpl.py +5 -3
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/mc2b.py +17 -5
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/mcep.py +35 -9
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/mcpf.py +26 -6
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/mdct.py +33 -7
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/mdst.py +10 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/mfcc.py +36 -6
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/mgc2mgc.py +37 -10
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/mgc2sp.py +15 -3
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/mgcep.py +64 -21
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/mglsadf.py +42 -4
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/mlpg.py +12 -4
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/mlsacheck.py +12 -4
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/mpir2c.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/msvq.py +13 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/ndps2c.py +17 -5
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/nmf.py +13 -3
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/norm0.py +2 -2
- diffsptk-3.3.1/diffsptk/modules/oband.py +187 -0
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/par2is.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/par2lar.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/par2lpc.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/pca.py +12 -3
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/phase.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/pitch.py +30 -11
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/pitch_spec.py +63 -23
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/plp.py +50 -17
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/pnorm.py +20 -5
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/pol_root.py +11 -4
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/poledf.py +11 -6
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/pqmf.py +10 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/quantize.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/rlevdur.py +16 -5
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/rmse.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/root_pol.py +11 -3
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/smcep.py +23 -7
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/snr.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/spec.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/stft.py +20 -4
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/ulaw.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/unframe.py +12 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/vq.py +12 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/wht.py +18 -7
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/window.py +17 -5
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/world_synth.py +17 -7
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/yingram.py +12 -4
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/zcross.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/zerodf.py +2 -2
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/signals.py +111 -1
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/utils/private.py +95 -40
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/utils/public.py +21 -6
- diffsptk-3.3.1/diffsptk/version.py +1 -0
- {diffsptk-3.2.0 → diffsptk-3.3.1}/pyproject.toml +2 -0
- diffsptk-3.2.0/diffsptk/version.py +0 -1
- {diffsptk-3.2.0 → diffsptk-3.3.1}/CITATION.cff +0 -0
- {diffsptk-3.2.0 → diffsptk-3.3.1}/LICENSE +0 -0
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/__init__.py +0 -0
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/base.py +0 -0
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/flux.py +0 -0
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/imglsadf.py +0 -0
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/imsvq.py +0 -0
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/modules/ivq.py +0 -0
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/third_party/librosa/LICENSE +0 -0
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/third_party/librosa/__init__.py +0 -0
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/third_party/librosa/constantq.py +0 -0
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/third_party/librosa/filters.py +0 -0
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/third_party/librosa/typing.py +0 -0
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/third_party/librosa/util.py +0 -0
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/third_party/world/LICENSE +0 -0
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/third_party/world/__init__.py +0 -0
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/third_party/world/common.py +0 -0
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/typing.py +0 -0
- {diffsptk-3.2.0 → diffsptk-3.3.1}/diffsptk/utils/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: diffsptk
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.3.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/
|
|
@@ -47,11 +47,11 @@ Description-Content-Type: text/markdown
|
|
|
47
47
|
|
|
48
48
|
*diffsptk* is a differentiable version of [SPTK](https://github.com/sp-nitech/SPTK) based on the PyTorch framework.
|
|
49
49
|
|
|
50
|
-
[](https://sp-nitech.github.io/diffsptk/3.
|
|
50
|
+
[](https://sp-nitech.github.io/diffsptk/3.3.1/)
|
|
51
51
|
[](https://pepy.tech/project/diffsptk)
|
|
52
52
|
[](https://clickpy.clickhouse.com/dashboard/diffsptk)
|
|
53
53
|
[](https://pypi.python.org/pypi/diffsptk)
|
|
54
|
-
[](https://pypi.python.org/pypi/diffsptk)
|
|
55
55
|
[](https://pypi.python.org/pypi/diffsptk)
|
|
56
56
|
[](https://app.codecov.io/gh/sp-nitech/diffsptk)
|
|
57
57
|
[](https://github.com/sp-nitech/diffsptk/blob/master/LICENSE)
|
|
@@ -65,7 +65,7 @@ Description-Content-Type: text/markdown
|
|
|
65
65
|
|
|
66
66
|
## Documentation
|
|
67
67
|
|
|
68
|
-
- See [this page](https://sp-nitech.github.io/diffsptk/3.
|
|
68
|
+
- See [this page](https://sp-nitech.github.io/diffsptk/3.3.1/) for the reference manual.
|
|
69
69
|
- Our [paper](https://www.isca-speech.org/archive/ssw_2023/yoshimura23_ssw.html) is available on the ISCA Archive.
|
|
70
70
|
|
|
71
71
|
## Installation
|
|
@@ -95,13 +95,12 @@ stft_params = {"frame_length": 400, "frame_period": 80, "fft_length": 512}
|
|
|
95
95
|
x, sr = diffsptk.read("assets/data.wav", device="cuda")
|
|
96
96
|
|
|
97
97
|
# Compute spectrogram using a nn.Module class.
|
|
98
|
-
X1 = diffsptk.STFT(**stft_params
|
|
98
|
+
X1 = diffsptk.STFT(**stft_params, device="cuda")(x)
|
|
99
99
|
|
|
100
100
|
# Compute spectrogram using a functional method.
|
|
101
101
|
X2 = diffsptk.functional.stft(x, **stft_params)
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
assert X1.allclose(X2)
|
|
103
|
+
print(X1.allclose(X2))
|
|
105
104
|
```
|
|
106
105
|
|
|
107
106
|
### Mel-cepstral analysis and synthesis
|
|
@@ -174,7 +173,6 @@ import diffsptk
|
|
|
174
173
|
|
|
175
174
|
fp = 80 # Frame period.
|
|
176
175
|
n_fft = 1024 # FFT length.
|
|
177
|
-
M = 24 # Mel-cepstrum dimensions.
|
|
178
176
|
|
|
179
177
|
# Read waveform.
|
|
180
178
|
x, sr = diffsptk.read("assets/data.wav")
|
|
@@ -220,6 +218,10 @@ x_hat = world_synth(f0, A, S)
|
|
|
220
218
|
|
|
221
219
|
# Write reconstructed waveform.
|
|
222
220
|
diffsptk.write("reconst.wav", x_hat, sr)
|
|
221
|
+
|
|
222
|
+
# Compute error.
|
|
223
|
+
error = (x_hat - x).abs().sum()
|
|
224
|
+
print(error)
|
|
223
225
|
```
|
|
224
226
|
|
|
225
227
|
### LPC analysis and synthesis
|
|
@@ -237,7 +239,7 @@ x, sr = diffsptk.read("assets/data.wav")
|
|
|
237
239
|
# Estimate LPC of x.
|
|
238
240
|
frame = diffsptk.Frame(frame_length=fl, frame_period=fp)
|
|
239
241
|
window = diffsptk.Window(in_length=fl)
|
|
240
|
-
lpc = diffsptk.LPC(frame_length=fl, lpc_order=M, eps=1e-
|
|
242
|
+
lpc = diffsptk.LPC(frame_length=fl, lpc_order=M, eps=1e-5)
|
|
241
243
|
a = lpc(window(frame(x)))
|
|
242
244
|
|
|
243
245
|
# Convert to inverse filter coefficients.
|
|
@@ -257,16 +259,15 @@ error = (x_hat - x).abs().sum()
|
|
|
257
259
|
print(error)
|
|
258
260
|
```
|
|
259
261
|
|
|
260
|
-
### Mel-spectrogram
|
|
262
|
+
### Mel-spectrogram analysis and synthesis
|
|
261
263
|
|
|
262
264
|
```python
|
|
263
265
|
import diffsptk
|
|
264
266
|
|
|
265
|
-
fl = 400
|
|
266
|
-
fp = 80
|
|
267
|
-
n_fft = 512
|
|
268
|
-
n_channel =
|
|
269
|
-
M = 12 # MFCC/PLP dimensions
|
|
267
|
+
fl = 400 # Frame length.
|
|
268
|
+
fp = 80 # Frame period.
|
|
269
|
+
n_fft = 512 # FFT length.
|
|
270
|
+
n_channel = 128 # Number of channels.
|
|
270
271
|
|
|
271
272
|
# Read waveform.
|
|
272
273
|
x, sr = diffsptk.read("assets/data.wav")
|
|
@@ -276,33 +277,35 @@ stft = diffsptk.STFT(frame_length=fl, frame_period=fp, fft_length=n_fft)
|
|
|
276
277
|
X = stft(x)
|
|
277
278
|
|
|
278
279
|
# Extract log mel-spectrogram.
|
|
279
|
-
fbank = diffsptk.
|
|
280
|
+
fbank = diffsptk.FBANK(
|
|
280
281
|
fft_length=n_fft,
|
|
281
282
|
n_channel=n_channel,
|
|
282
283
|
sample_rate=sr,
|
|
283
284
|
)
|
|
284
285
|
Y = fbank(X)
|
|
285
|
-
print(Y.shape)
|
|
286
286
|
|
|
287
|
-
#
|
|
288
|
-
|
|
289
|
-
fft_length=n_fft,
|
|
290
|
-
mfcc_order=M,
|
|
287
|
+
# Reconstruct linear spectrogram.
|
|
288
|
+
ifbank = diffsptk.IFBANK(
|
|
291
289
|
n_channel=n_channel,
|
|
290
|
+
fft_length=n_fft,
|
|
292
291
|
sample_rate=sr,
|
|
293
292
|
)
|
|
294
|
-
|
|
295
|
-
print(Y.shape)
|
|
293
|
+
X_hat = ifbank(Y)
|
|
296
294
|
|
|
297
|
-
#
|
|
298
|
-
|
|
295
|
+
# Reconstruct x.
|
|
296
|
+
griffin = diffsptk.GriffinLim(
|
|
297
|
+
frame_length=fl,
|
|
298
|
+
frame_period=fp,
|
|
299
299
|
fft_length=n_fft,
|
|
300
|
-
plp_order=M,
|
|
301
|
-
n_channel=n_channel,
|
|
302
|
-
sample_rate=sr,
|
|
303
300
|
)
|
|
304
|
-
|
|
305
|
-
|
|
301
|
+
x_hat = griffin(X_hat, out_length=x.size(0))
|
|
302
|
+
|
|
303
|
+
# Write reconstructed waveform.
|
|
304
|
+
diffsptk.write("reconst.wav", x_hat, sr)
|
|
305
|
+
|
|
306
|
+
# Compute error.
|
|
307
|
+
error = (x_hat - x).abs().sum()
|
|
308
|
+
print(error)
|
|
306
309
|
```
|
|
307
310
|
|
|
308
311
|
### Subband decomposition
|
|
@@ -358,6 +361,29 @@ error = (x_hat - x).abs().sum()
|
|
|
358
361
|
print(error)
|
|
359
362
|
```
|
|
360
363
|
|
|
364
|
+
### Fractional octave band analysis and synthesis
|
|
365
|
+
|
|
366
|
+
```python
|
|
367
|
+
import diffsptk
|
|
368
|
+
|
|
369
|
+
# Read waveform.
|
|
370
|
+
x, sr = diffsptk.read("assets/data.wav")
|
|
371
|
+
|
|
372
|
+
# Decompose x.
|
|
373
|
+
oband = diffsptk.FractionalOctaveBandAnalysis(sr)
|
|
374
|
+
y = oband(x)
|
|
375
|
+
|
|
376
|
+
# Reconstruct x.
|
|
377
|
+
x_hat = y.sum(1).reshape(-1)
|
|
378
|
+
|
|
379
|
+
# Write reconstructed waveform.
|
|
380
|
+
diffsptk.write("reconst.wav", x_hat, sr)
|
|
381
|
+
|
|
382
|
+
# Compute error.
|
|
383
|
+
error = (x_hat - x).abs().sum()
|
|
384
|
+
print(error)
|
|
385
|
+
```
|
|
386
|
+
|
|
361
387
|
### Constant-Q transform
|
|
362
388
|
|
|
363
389
|
```python
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
*diffsptk* is a differentiable version of [SPTK](https://github.com/sp-nitech/SPTK) based on the PyTorch framework.
|
|
4
4
|
|
|
5
|
-
[](https://sp-nitech.github.io/diffsptk/3.
|
|
5
|
+
[](https://sp-nitech.github.io/diffsptk/3.3.1/)
|
|
6
6
|
[](https://pepy.tech/project/diffsptk)
|
|
7
7
|
[](https://clickpy.clickhouse.com/dashboard/diffsptk)
|
|
8
8
|
[](https://pypi.python.org/pypi/diffsptk)
|
|
9
|
-
[](https://pypi.python.org/pypi/diffsptk)
|
|
10
10
|
[](https://pypi.python.org/pypi/diffsptk)
|
|
11
11
|
[](https://app.codecov.io/gh/sp-nitech/diffsptk)
|
|
12
12
|
[](https://github.com/sp-nitech/diffsptk/blob/master/LICENSE)
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
## Documentation
|
|
22
22
|
|
|
23
|
-
- See [this page](https://sp-nitech.github.io/diffsptk/3.
|
|
23
|
+
- See [this page](https://sp-nitech.github.io/diffsptk/3.3.1/) for the reference manual.
|
|
24
24
|
- Our [paper](https://www.isca-speech.org/archive/ssw_2023/yoshimura23_ssw.html) is available on the ISCA Archive.
|
|
25
25
|
|
|
26
26
|
## Installation
|
|
@@ -50,13 +50,12 @@ stft_params = {"frame_length": 400, "frame_period": 80, "fft_length": 512}
|
|
|
50
50
|
x, sr = diffsptk.read("assets/data.wav", device="cuda")
|
|
51
51
|
|
|
52
52
|
# Compute spectrogram using a nn.Module class.
|
|
53
|
-
X1 = diffsptk.STFT(**stft_params
|
|
53
|
+
X1 = diffsptk.STFT(**stft_params, device="cuda")(x)
|
|
54
54
|
|
|
55
55
|
# Compute spectrogram using a functional method.
|
|
56
56
|
X2 = diffsptk.functional.stft(x, **stft_params)
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
assert X1.allclose(X2)
|
|
58
|
+
print(X1.allclose(X2))
|
|
60
59
|
```
|
|
61
60
|
|
|
62
61
|
### Mel-cepstral analysis and synthesis
|
|
@@ -129,7 +128,6 @@ import diffsptk
|
|
|
129
128
|
|
|
130
129
|
fp = 80 # Frame period.
|
|
131
130
|
n_fft = 1024 # FFT length.
|
|
132
|
-
M = 24 # Mel-cepstrum dimensions.
|
|
133
131
|
|
|
134
132
|
# Read waveform.
|
|
135
133
|
x, sr = diffsptk.read("assets/data.wav")
|
|
@@ -175,6 +173,10 @@ x_hat = world_synth(f0, A, S)
|
|
|
175
173
|
|
|
176
174
|
# Write reconstructed waveform.
|
|
177
175
|
diffsptk.write("reconst.wav", x_hat, sr)
|
|
176
|
+
|
|
177
|
+
# Compute error.
|
|
178
|
+
error = (x_hat - x).abs().sum()
|
|
179
|
+
print(error)
|
|
178
180
|
```
|
|
179
181
|
|
|
180
182
|
### LPC analysis and synthesis
|
|
@@ -192,7 +194,7 @@ x, sr = diffsptk.read("assets/data.wav")
|
|
|
192
194
|
# Estimate LPC of x.
|
|
193
195
|
frame = diffsptk.Frame(frame_length=fl, frame_period=fp)
|
|
194
196
|
window = diffsptk.Window(in_length=fl)
|
|
195
|
-
lpc = diffsptk.LPC(frame_length=fl, lpc_order=M, eps=1e-
|
|
197
|
+
lpc = diffsptk.LPC(frame_length=fl, lpc_order=M, eps=1e-5)
|
|
196
198
|
a = lpc(window(frame(x)))
|
|
197
199
|
|
|
198
200
|
# Convert to inverse filter coefficients.
|
|
@@ -212,16 +214,15 @@ error = (x_hat - x).abs().sum()
|
|
|
212
214
|
print(error)
|
|
213
215
|
```
|
|
214
216
|
|
|
215
|
-
### Mel-spectrogram
|
|
217
|
+
### Mel-spectrogram analysis and synthesis
|
|
216
218
|
|
|
217
219
|
```python
|
|
218
220
|
import diffsptk
|
|
219
221
|
|
|
220
|
-
fl = 400
|
|
221
|
-
fp = 80
|
|
222
|
-
n_fft = 512
|
|
223
|
-
n_channel =
|
|
224
|
-
M = 12 # MFCC/PLP dimensions
|
|
222
|
+
fl = 400 # Frame length.
|
|
223
|
+
fp = 80 # Frame period.
|
|
224
|
+
n_fft = 512 # FFT length.
|
|
225
|
+
n_channel = 128 # Number of channels.
|
|
225
226
|
|
|
226
227
|
# Read waveform.
|
|
227
228
|
x, sr = diffsptk.read("assets/data.wav")
|
|
@@ -231,33 +232,35 @@ stft = diffsptk.STFT(frame_length=fl, frame_period=fp, fft_length=n_fft)
|
|
|
231
232
|
X = stft(x)
|
|
232
233
|
|
|
233
234
|
# Extract log mel-spectrogram.
|
|
234
|
-
fbank = diffsptk.
|
|
235
|
+
fbank = diffsptk.FBANK(
|
|
235
236
|
fft_length=n_fft,
|
|
236
237
|
n_channel=n_channel,
|
|
237
238
|
sample_rate=sr,
|
|
238
239
|
)
|
|
239
240
|
Y = fbank(X)
|
|
240
|
-
print(Y.shape)
|
|
241
241
|
|
|
242
|
-
#
|
|
243
|
-
|
|
244
|
-
fft_length=n_fft,
|
|
245
|
-
mfcc_order=M,
|
|
242
|
+
# Reconstruct linear spectrogram.
|
|
243
|
+
ifbank = diffsptk.IFBANK(
|
|
246
244
|
n_channel=n_channel,
|
|
245
|
+
fft_length=n_fft,
|
|
247
246
|
sample_rate=sr,
|
|
248
247
|
)
|
|
249
|
-
|
|
250
|
-
print(Y.shape)
|
|
248
|
+
X_hat = ifbank(Y)
|
|
251
249
|
|
|
252
|
-
#
|
|
253
|
-
|
|
250
|
+
# Reconstruct x.
|
|
251
|
+
griffin = diffsptk.GriffinLim(
|
|
252
|
+
frame_length=fl,
|
|
253
|
+
frame_period=fp,
|
|
254
254
|
fft_length=n_fft,
|
|
255
|
-
plp_order=M,
|
|
256
|
-
n_channel=n_channel,
|
|
257
|
-
sample_rate=sr,
|
|
258
255
|
)
|
|
259
|
-
|
|
260
|
-
|
|
256
|
+
x_hat = griffin(X_hat, out_length=x.size(0))
|
|
257
|
+
|
|
258
|
+
# Write reconstructed waveform.
|
|
259
|
+
diffsptk.write("reconst.wav", x_hat, sr)
|
|
260
|
+
|
|
261
|
+
# Compute error.
|
|
262
|
+
error = (x_hat - x).abs().sum()
|
|
263
|
+
print(error)
|
|
261
264
|
```
|
|
262
265
|
|
|
263
266
|
### Subband decomposition
|
|
@@ -313,6 +316,29 @@ error = (x_hat - x).abs().sum()
|
|
|
313
316
|
print(error)
|
|
314
317
|
```
|
|
315
318
|
|
|
319
|
+
### Fractional octave band analysis and synthesis
|
|
320
|
+
|
|
321
|
+
```python
|
|
322
|
+
import diffsptk
|
|
323
|
+
|
|
324
|
+
# Read waveform.
|
|
325
|
+
x, sr = diffsptk.read("assets/data.wav")
|
|
326
|
+
|
|
327
|
+
# Decompose x.
|
|
328
|
+
oband = diffsptk.FractionalOctaveBandAnalysis(sr)
|
|
329
|
+
y = oband(x)
|
|
330
|
+
|
|
331
|
+
# Reconstruct x.
|
|
332
|
+
x_hat = y.sum(1).reshape(-1)
|
|
333
|
+
|
|
334
|
+
# Write reconstructed waveform.
|
|
335
|
+
diffsptk.write("reconst.wav", x_hat, sr)
|
|
336
|
+
|
|
337
|
+
# Compute error.
|
|
338
|
+
error = (x_hat - x).abs().sum()
|
|
339
|
+
print(error)
|
|
340
|
+
```
|
|
341
|
+
|
|
316
342
|
### Constant-Q transform
|
|
317
343
|
|
|
318
344
|
```python
|
|
@@ -561,7 +561,7 @@ def excite(
|
|
|
561
561
|
'triangle', 'square']
|
|
562
562
|
The type of voiced region.
|
|
563
563
|
|
|
564
|
-
unvoiced_region : ['zeros', 'gauss']
|
|
564
|
+
unvoiced_region : ['zeros', 'gauss', 'uniform']
|
|
565
565
|
The type of unvoiced region.
|
|
566
566
|
|
|
567
567
|
polarity : ['auto', 'unipolar', 'bipolar']
|
|
@@ -594,6 +594,8 @@ def fbank(
|
|
|
594
594
|
f_max: float | None = None,
|
|
595
595
|
floor: float = 1e-5,
|
|
596
596
|
gamma: float = 0,
|
|
597
|
+
scale: str = "htk",
|
|
598
|
+
erb_factor: float | None = None,
|
|
597
599
|
use_power: bool = False,
|
|
598
600
|
out_format: str = "y",
|
|
599
601
|
) -> tuple[Tensor, Tensor] | Tensor:
|
|
@@ -622,6 +624,13 @@ def fbank(
|
|
|
622
624
|
gamma : float in [-1, 1]
|
|
623
625
|
The parameter of the generalized logarithmic function.
|
|
624
626
|
|
|
627
|
+
scale : ['htk', 'mel', 'inverted-mel', 'bark', 'linear']
|
|
628
|
+
The type of auditory scale used to construct the filter bank.
|
|
629
|
+
|
|
630
|
+
erb_factor : float > 0 or None
|
|
631
|
+
The scale factor for the ERB scale, referred to as the E-factor. If not None,
|
|
632
|
+
the filter bandwidths are adjusted according to the scaled ERB scale.
|
|
633
|
+
|
|
625
634
|
use_power : bool
|
|
626
635
|
If True, use the power spectrum instead of the amplitude spectrum.
|
|
627
636
|
|
|
@@ -646,6 +655,8 @@ def fbank(
|
|
|
646
655
|
f_max=f_max,
|
|
647
656
|
floor=floor,
|
|
648
657
|
gamma=gamma,
|
|
658
|
+
scale=scale,
|
|
659
|
+
erb_factor=erb_factor,
|
|
649
660
|
use_power=use_power,
|
|
650
661
|
out_format=out_format,
|
|
651
662
|
)
|
|
@@ -1178,6 +1189,69 @@ def idst(y: Tensor, dst_type: int = 2) -> Tensor:
|
|
|
1178
1189
|
return nn.InverseDiscreteSineTransform._func(y, dst_type=dst_type)
|
|
1179
1190
|
|
|
1180
1191
|
|
|
1192
|
+
def ifbank(
|
|
1193
|
+
y: Tensor,
|
|
1194
|
+
fft_length: int,
|
|
1195
|
+
sample_rate: int,
|
|
1196
|
+
f_min: float = 0,
|
|
1197
|
+
f_max: float | None = None,
|
|
1198
|
+
gamma: float = 0,
|
|
1199
|
+
scale: str = "htk",
|
|
1200
|
+
erb_factor: float | None = None,
|
|
1201
|
+
use_power: bool = False,
|
|
1202
|
+
) -> Tensor:
|
|
1203
|
+
"""Reconstruct the power spectrum from the mel filter bank output.
|
|
1204
|
+
|
|
1205
|
+
Parameters
|
|
1206
|
+
----------
|
|
1207
|
+
y : Tensor [shape=(..., C)]
|
|
1208
|
+
The mel filter bank output.
|
|
1209
|
+
|
|
1210
|
+
fft_length : int >= 2
|
|
1211
|
+
The number of FFT bins, :math:`L`.
|
|
1212
|
+
|
|
1213
|
+
sample_rate : int >= 1
|
|
1214
|
+
The sample rate in Hz.
|
|
1215
|
+
|
|
1216
|
+
f_min : float >= 0
|
|
1217
|
+
The minimum frequency in Hz.
|
|
1218
|
+
|
|
1219
|
+
f_max : float <= sample_rate // 2
|
|
1220
|
+
The maximum frequency in Hz.
|
|
1221
|
+
|
|
1222
|
+
gamma : float in [-1, 1]
|
|
1223
|
+
The parameter of the generalized logarithmic function.
|
|
1224
|
+
|
|
1225
|
+
scale : ['htk', 'mel', 'inverted-mel', 'bark', 'linear']
|
|
1226
|
+
The type of auditory scale used to construct the filter bank.
|
|
1227
|
+
|
|
1228
|
+
erb_factor : float > 0 or None
|
|
1229
|
+
The scale factor for the ERB scale, referred to as the E-factor. If not None,
|
|
1230
|
+
the filter bandwidths are adjusted according to the scaled ERB scale.
|
|
1231
|
+
|
|
1232
|
+
use_power : bool
|
|
1233
|
+
Set to True if the mel filter bank output is extracted from the power spectrum
|
|
1234
|
+
instead of the amplitude spectrum.
|
|
1235
|
+
|
|
1236
|
+
Returns
|
|
1237
|
+
-------
|
|
1238
|
+
out : Tensor [shape=(..., L/2+1)]
|
|
1239
|
+
The reconstructed power spectrum.
|
|
1240
|
+
|
|
1241
|
+
"""
|
|
1242
|
+
return nn.InverseMelFilterBankAnalysis._func(
|
|
1243
|
+
y,
|
|
1244
|
+
fft_length=fft_length,
|
|
1245
|
+
sample_rate=sample_rate,
|
|
1246
|
+
f_min=f_min,
|
|
1247
|
+
f_max=f_max,
|
|
1248
|
+
gamma=gamma,
|
|
1249
|
+
scale=scale,
|
|
1250
|
+
erb_factor=erb_factor,
|
|
1251
|
+
use_power=use_power,
|
|
1252
|
+
)
|
|
1253
|
+
|
|
1254
|
+
|
|
1181
1255
|
def ifftr(y: Tensor, out_length: int | None = None) -> Tensor:
|
|
1182
1256
|
"""Compute inverse FFT of a complex spectrum.
|
|
1183
1257
|
|
|
@@ -1503,7 +1577,7 @@ def lar2par(g: Tensor) -> Tensor:
|
|
|
1503
1577
|
return nn.LogAreaRatioToParcorCoefficients._func(g)
|
|
1504
1578
|
|
|
1505
1579
|
|
|
1506
|
-
def levdur(r: Tensor, eps: float =
|
|
1580
|
+
def levdur(r: Tensor, eps: float | None = None) -> Tensor:
|
|
1507
1581
|
"""Solve a Yule-Walker linear system.
|
|
1508
1582
|
|
|
1509
1583
|
Parameters
|
|
@@ -1511,7 +1585,7 @@ def levdur(r: Tensor, eps: float = 0) -> Tensor:
|
|
|
1511
1585
|
r : Tensor [shape=(..., M+1)]
|
|
1512
1586
|
The autocorrelation.
|
|
1513
1587
|
|
|
1514
|
-
eps : float >= 0
|
|
1588
|
+
eps : float >= 0 or None
|
|
1515
1589
|
A small value to improve numerical stability.
|
|
1516
1590
|
|
|
1517
1591
|
Returns
|
|
@@ -1543,7 +1617,7 @@ def linear_intpl(x: Tensor, upsampling_factor: int = 80) -> Tensor:
|
|
|
1543
1617
|
return nn.LinearInterpolation._func(x, upsampling_factor=upsampling_factor)
|
|
1544
1618
|
|
|
1545
1619
|
|
|
1546
|
-
def lpc(x: Tensor, lpc_order: int, eps: float =
|
|
1620
|
+
def lpc(x: Tensor, lpc_order: int, eps: float | None = None) -> Tensor:
|
|
1547
1621
|
"""Perform LPC analysis.
|
|
1548
1622
|
|
|
1549
1623
|
Parameters
|
|
@@ -1554,7 +1628,7 @@ def lpc(x: Tensor, lpc_order: int, eps: float = 1e-6) -> Tensor:
|
|
|
1554
1628
|
lpc_order : int >= 0
|
|
1555
1629
|
The order of the LPC coefficients, :math:`M`.
|
|
1556
1630
|
|
|
1557
|
-
eps : float >= 0
|
|
1631
|
+
eps : float >= 0 or None
|
|
1558
1632
|
A small value to improve numerical stability.
|
|
1559
1633
|
|
|
1560
1634
|
Returns
|
|
@@ -1766,7 +1840,7 @@ def magic_intpl(x: Tensor, magic_number: float = 0) -> Tensor:
|
|
|
1766
1840
|
x : Tensor [shape=(B, N, D) or (N, D) or (N,)]
|
|
1767
1841
|
The data containing magic number.
|
|
1768
1842
|
|
|
1769
|
-
magic_number : float
|
|
1843
|
+
magic_number : float
|
|
1770
1844
|
The magic number to be interpolated.
|
|
1771
1845
|
|
|
1772
1846
|
Returns
|
|
@@ -1919,6 +1993,8 @@ def mfcc(
|
|
|
1919
1993
|
f_max: float | None = None,
|
|
1920
1994
|
floor: float = 1e-5,
|
|
1921
1995
|
gamma: float = 0,
|
|
1996
|
+
scale: str = "htk",
|
|
1997
|
+
erb_factor: float | None = None,
|
|
1922
1998
|
out_format: str = "y",
|
|
1923
1999
|
) -> Tensor:
|
|
1924
2000
|
"""Compute the MFCC from the power spectrum.
|
|
@@ -1952,6 +2028,13 @@ def mfcc(
|
|
|
1952
2028
|
gamma : float in [-1, 1]
|
|
1953
2029
|
The parameter of the generalized logarithmic function.
|
|
1954
2030
|
|
|
2031
|
+
scale : ['htk', 'mel', 'inverted-mel', 'bark', 'linear']
|
|
2032
|
+
The type of auditory scale used to construct the filter bank.
|
|
2033
|
+
|
|
2034
|
+
erb_factor : float > 0 or None
|
|
2035
|
+
The scale factor for the ERB scale, referred to as the E-factor. If not None,
|
|
2036
|
+
the filter bandwidths are adjusted according to the scaled ERB scale.
|
|
2037
|
+
|
|
1955
2038
|
out_format : ['y', 'yE', 'yc', 'ycE']
|
|
1956
2039
|
`y` is MFCC, `c` is C0, and `E` is energy.
|
|
1957
2040
|
|
|
@@ -1977,6 +2060,8 @@ def mfcc(
|
|
|
1977
2060
|
f_max=f_max,
|
|
1978
2061
|
floor=floor,
|
|
1979
2062
|
gamma=gamma,
|
|
2063
|
+
scale=scale,
|
|
2064
|
+
erb_factor=erb_factor,
|
|
1980
2065
|
out_format=out_format,
|
|
1981
2066
|
)
|
|
1982
2067
|
|
|
@@ -2360,6 +2445,8 @@ def plp(
|
|
|
2360
2445
|
f_max: float | None = None,
|
|
2361
2446
|
floor: float = 1e-5,
|
|
2362
2447
|
gamma: float = 0,
|
|
2448
|
+
scale: str = "htk",
|
|
2449
|
+
erb_factor: float | None = None,
|
|
2363
2450
|
n_fft: int = 512,
|
|
2364
2451
|
out_format: str = "y",
|
|
2365
2452
|
) -> Tensor:
|
|
@@ -2397,6 +2484,13 @@ def plp(
|
|
|
2397
2484
|
gamma : float in [-1, 1]
|
|
2398
2485
|
The parameter of the generalized logarithmic function.
|
|
2399
2486
|
|
|
2487
|
+
scale : ['htk', 'mel', 'inverted-mel', 'bark', 'linear']
|
|
2488
|
+
The type of auditory scale used to construct the filter bank.
|
|
2489
|
+
|
|
2490
|
+
erb_factor : float > 0 or None
|
|
2491
|
+
The scale factor for the ERB scale, referred to as the E-factor. If not None,
|
|
2492
|
+
the filter bandwidths are adjusted according to the scaled ERB scale.
|
|
2493
|
+
|
|
2400
2494
|
n_fft : int >> M
|
|
2401
2495
|
The number of FFT bins for the conversion from LPC to cepstrum.
|
|
2402
2496
|
|
|
@@ -2426,6 +2520,8 @@ def plp(
|
|
|
2426
2520
|
f_max=f_max,
|
|
2427
2521
|
floor=floor,
|
|
2428
2522
|
gamma=gamma,
|
|
2523
|
+
scale=scale,
|
|
2524
|
+
erb_factor=erb_factor,
|
|
2429
2525
|
n_fft=n_fft,
|
|
2430
2526
|
out_format=out_format,
|
|
2431
2527
|
)
|
|
@@ -2943,7 +3039,7 @@ def window(
|
|
|
2943
3039
|
If None, :math:`L_2 = L_1`.
|
|
2944
3040
|
|
|
2945
3041
|
window : ['blackman', 'hamming', 'hanning', 'bartlett', 'trapezoidal', \
|
|
2946
|
-
'rectangular', 'nuttall']
|
|
3042
|
+
'rectangular', 'nuttall', 'povey']
|
|
2947
3043
|
The window type.
|
|
2948
3044
|
|
|
2949
3045
|
norm : ['none', 'power', 'magnitude']
|
|
@@ -72,6 +72,8 @@ from .idht import InverseDiscreteHartleyTransform
|
|
|
72
72
|
from .idht import InverseDiscreteHartleyTransform as IDHT
|
|
73
73
|
from .idst import InverseDiscreteSineTransform
|
|
74
74
|
from .idst import InverseDiscreteSineTransform as IDST
|
|
75
|
+
from .ifbank import InverseMelFilterBankAnalysis
|
|
76
|
+
from .ifbank import InverseMelFilterBankAnalysis as IFBANK
|
|
75
77
|
from .ifftr import RealValuedInverseFastFourierTransform
|
|
76
78
|
from .ifreqt2 import SecondOrderAllPassInverseFrequencyTransform
|
|
77
79
|
from .igammatone import GammatoneFilterBankSynthesis
|
|
@@ -129,6 +131,7 @@ from .ndps2c import NegativeDerivativeOfPhaseSpectrumToCepstrum
|
|
|
129
131
|
from .nmf import NonnegativeMatrixFactorization
|
|
130
132
|
from .nmf import NonnegativeMatrixFactorization as NMF
|
|
131
133
|
from .norm0 import AllPoleToAllZeroDigitalFilterCoefficients
|
|
134
|
+
from .oband import FractionalOctaveBandAnalysis
|
|
132
135
|
from .par2is import ParcorCoefficientsToInverseSine
|
|
133
136
|
from .par2lar import ParcorCoefficientsToLogAreaRatio
|
|
134
137
|
from .par2lpc import ParcorCoefficientsToLinearPredictiveCoefficients
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import torch
|
|
18
18
|
|
|
19
19
|
from ..typing import Callable, Precomputed
|
|
20
|
-
from ..utils.private import check_size,
|
|
20
|
+
from ..utils.private import check_size, filter_values
|
|
21
21
|
from .base import BaseFunctionalModule
|
|
22
22
|
|
|
23
23
|
|
|
@@ -45,7 +45,7 @@ class Autocorrelation(BaseFunctionalModule):
|
|
|
45
45
|
|
|
46
46
|
self.in_dim = frame_length
|
|
47
47
|
|
|
48
|
-
self.values = self._precompute(
|
|
48
|
+
self.values = self._precompute(**filter_values(locals()))
|
|
49
49
|
|
|
50
50
|
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
51
51
|
"""Estimate the autocorrelation of the input waveform.
|
|
@@ -18,7 +18,7 @@ import torch
|
|
|
18
18
|
import torch.nn.functional as F
|
|
19
19
|
|
|
20
20
|
from ..typing import Precomputed
|
|
21
|
-
from ..utils.private import check_size,
|
|
21
|
+
from ..utils.private import check_size, filter_values, hankel, to, vander
|
|
22
22
|
from .base import BaseFunctionalModule
|
|
23
23
|
from .root_pol import PolynomialToRoots
|
|
24
24
|
|
|
@@ -32,6 +32,12 @@ class AutocorrelationToCompositeSinusoidalModelCoefficients(BaseFunctionalModule
|
|
|
32
32
|
acr_order : int >= 0
|
|
33
33
|
The order of the autocorrelation, :math:`M`.
|
|
34
34
|
|
|
35
|
+
device : torch.device or None
|
|
36
|
+
The device of this module.
|
|
37
|
+
|
|
38
|
+
dtype : torch.dtype or None
|
|
39
|
+
The data type of this module.
|
|
40
|
+
|
|
35
41
|
References
|
|
36
42
|
----------
|
|
37
43
|
.. [1] S. Sagayama et al., "Duality theory of composite sinusoidal modeling and
|
|
@@ -39,12 +45,17 @@ class AutocorrelationToCompositeSinusoidalModelCoefficients(BaseFunctionalModule
|
|
|
39
45
|
|
|
40
46
|
"""
|
|
41
47
|
|
|
42
|
-
def __init__(
|
|
48
|
+
def __init__(
|
|
49
|
+
self,
|
|
50
|
+
acr_order: int,
|
|
51
|
+
device: torch.device | None = None,
|
|
52
|
+
dtype: torch.dtype | None = None,
|
|
53
|
+
) -> None:
|
|
43
54
|
super().__init__()
|
|
44
55
|
|
|
45
56
|
self.in_dim = acr_order + 1
|
|
46
57
|
|
|
47
|
-
_, _, tensors = self._precompute(
|
|
58
|
+
_, _, tensors = self._precompute(**filter_values(locals()))
|
|
48
59
|
self.register_buffer("C", tensors[0])
|
|
49
60
|
|
|
50
61
|
def forward(self, r: torch.Tensor) -> torch.Tensor:
|
|
@@ -100,8 +111,8 @@ class AutocorrelationToCompositeSinusoidalModelCoefficients(BaseFunctionalModule
|
|
|
100
111
|
@staticmethod
|
|
101
112
|
def _precompute(
|
|
102
113
|
acr_order: int,
|
|
103
|
-
device: torch.device | None
|
|
104
|
-
dtype: torch.dtype | None
|
|
114
|
+
device: torch.device | None,
|
|
115
|
+
dtype: torch.dtype | None,
|
|
105
116
|
) -> Precomputed:
|
|
106
117
|
from scipy.special import comb
|
|
107
118
|
|
|
@@ -127,7 +138,10 @@ class AutocorrelationToCompositeSinusoidalModelCoefficients(BaseFunctionalModule
|
|
|
127
138
|
@staticmethod
|
|
128
139
|
def _forward(r: torch.Tensor, C: torch.Tensor) -> torch.Tensor:
|
|
129
140
|
if r.dtype != torch.double or C.dtype != torch.double:
|
|
130
|
-
raise ValueError(
|
|
141
|
+
raise ValueError(
|
|
142
|
+
"Only double precision is supported "
|
|
143
|
+
f"(input: {r.dtype}, module: {C.dtype})."
|
|
144
|
+
)
|
|
131
145
|
|
|
132
146
|
u = torch.matmul(r, C)
|
|
133
147
|
u1, u2 = torch.tensor_split(u, 2, dim=-1)
|