diffsptk 3.3.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.3.0 → diffsptk-3.3.1}/PKG-INFO +4 -4
- {diffsptk-3.3.0 → diffsptk-3.3.1}/README.md +3 -3
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/functional.py +1 -1
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/drc.py +6 -4
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/excite.py +10 -1
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/griffin.py +6 -5
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/poledf.py +9 -4
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/signals.py +111 -1
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/utils/public.py +1 -1
- diffsptk-3.3.1/diffsptk/version.py +1 -0
- diffsptk-3.3.0/diffsptk/version.py +0 -1
- {diffsptk-3.3.0 → diffsptk-3.3.1}/.gitignore +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/CITATION.cff +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/LICENSE +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/__init__.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/__init__.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/acorr.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/acr2csm.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/alaw.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/ap.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/b2mc.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/base.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/c2acr.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/c2mpir.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/c2ndps.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/cdist.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/chroma.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/cqt.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/csm2acr.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/dct.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/decimate.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/delay.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/delta.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/dequantize.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/df2.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/dfs.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/dht.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/dst.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/entropy.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/fbank.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/fftcep.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/fftr.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/flux.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/frame.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/freqt.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/freqt2.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/gammatone.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/gmm.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/gnorm.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/grpdelay.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/hilbert.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/hilbert2.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/histogram.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/ialaw.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/ica.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/icqt.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/idct.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/idht.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/idst.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/ifbank.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/ifftr.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/ifreqt2.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/igammatone.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/ignorm.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/imdct.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/imdst.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/imglsadf.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/imsvq.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/interpolate.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/ipnorm.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/ipqmf.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/is2par.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/istft.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/iulaw.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/ivq.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/lar2par.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/lbg.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/levdur.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/linear_intpl.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/lpc.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/lpc2lsp.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/lpc2par.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/lpccheck.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/lsp2lpc.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/lsp2sp.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/lspcheck.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/magic_intpl.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/mc2b.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/mcep.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/mcpf.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/mdct.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/mdst.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/mfcc.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/mgc2mgc.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/mgc2sp.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/mgcep.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/mglsadf.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/mlpg.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/mlsacheck.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/mpir2c.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/msvq.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/ndps2c.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/nmf.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/norm0.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/oband.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/par2is.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/par2lar.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/par2lpc.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/pca.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/phase.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/pitch.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/pitch_spec.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/plp.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/pnorm.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/pol_root.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/pqmf.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/quantize.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/rlevdur.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/rmse.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/root_pol.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/smcep.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/snr.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/spec.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/stft.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/ulaw.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/unframe.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/vq.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/wht.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/window.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/world_synth.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/yingram.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/zcross.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/modules/zerodf.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/third_party/librosa/LICENSE +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/third_party/librosa/__init__.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/third_party/librosa/constantq.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/third_party/librosa/filters.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/third_party/librosa/typing.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/third_party/librosa/util.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/third_party/world/LICENSE +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/third_party/world/__init__.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/third_party/world/common.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/typing.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/utils/__init__.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/diffsptk/utils/private.py +0 -0
- {diffsptk-3.3.0 → diffsptk-3.3.1}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: diffsptk
|
|
3
|
-
Version: 3.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.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.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
|
|
@@ -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.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.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
|
|
@@ -16,10 +16,9 @@
|
|
|
16
16
|
|
|
17
17
|
import numpy as np
|
|
18
18
|
import torch
|
|
19
|
-
import torchcomp
|
|
20
19
|
from torch import nn
|
|
21
20
|
|
|
22
|
-
from ..typing import Precomputed
|
|
21
|
+
from ..typing import Callable, Precomputed
|
|
23
22
|
from ..utils.private import filter_values, to, to_2d
|
|
24
23
|
from .base import BaseFunctionalModule
|
|
25
24
|
|
|
@@ -161,6 +160,8 @@ class DynamicRangeCompression(BaseFunctionalModule):
|
|
|
161
160
|
device: torch.device | None,
|
|
162
161
|
dtype: torch.dtype | None,
|
|
163
162
|
) -> Precomputed:
|
|
163
|
+
import torchcomp
|
|
164
|
+
|
|
164
165
|
DynamicRangeCompression._check(
|
|
165
166
|
ratio, attack_time, release_time, sample_rate, makeup_gain, abs_max
|
|
166
167
|
)
|
|
@@ -179,12 +180,13 @@ class DynamicRangeCompression(BaseFunctionalModule):
|
|
|
179
180
|
makeup_gain = to(torch.tensor(makeup_gain, device=device), dtype=dtype)
|
|
180
181
|
makeup_gain = 10 ** (makeup_gain / 20)
|
|
181
182
|
params = torch.stack([threshold, ratio, attack_time, release_time, makeup_gain])
|
|
182
|
-
return (abs_max,), None, (params,)
|
|
183
|
+
return (abs_max, torchcomp.compexp_gain), None, (params,)
|
|
183
184
|
|
|
184
185
|
@staticmethod
|
|
185
186
|
def _forward(
|
|
186
187
|
x: torch.Tensor,
|
|
187
188
|
abs_max: float,
|
|
189
|
+
compexp_gain: Callable,
|
|
188
190
|
params: torch.Tensor,
|
|
189
191
|
) -> torch.Tensor:
|
|
190
192
|
eps = 1e-10
|
|
@@ -192,7 +194,7 @@ class DynamicRangeCompression(BaseFunctionalModule):
|
|
|
192
194
|
y = to_2d(x)
|
|
193
195
|
y_abs = y.abs() / abs_max + eps
|
|
194
196
|
|
|
195
|
-
g =
|
|
197
|
+
g = compexp_gain(
|
|
196
198
|
y_abs,
|
|
197
199
|
params[0],
|
|
198
200
|
params[1],
|
|
@@ -14,9 +14,12 @@
|
|
|
14
14
|
# limitations under the License. #
|
|
15
15
|
# ------------------------------------------------------------------------ #
|
|
16
16
|
|
|
17
|
+
import math
|
|
18
|
+
|
|
17
19
|
import torch
|
|
18
20
|
import torch.nn.functional as F
|
|
19
21
|
|
|
22
|
+
from ..signals import mseq
|
|
20
23
|
from ..typing import Precomputed
|
|
21
24
|
from ..utils.private import TAU, UNVOICED_SYMBOL, filter_values
|
|
22
25
|
from .base import BaseFunctionalModule
|
|
@@ -36,7 +39,7 @@ class ExcitationGeneration(BaseFunctionalModule):
|
|
|
36
39
|
'triangle', 'square']
|
|
37
40
|
The type of voiced region.
|
|
38
41
|
|
|
39
|
-
unvoiced_region : ['zeros', 'gauss']
|
|
42
|
+
unvoiced_region : ['zeros', 'gauss', 'm-sequence', 'uniform']
|
|
40
43
|
The type of unvoiced region.
|
|
41
44
|
|
|
42
45
|
polarity : ['auto', 'unipolar', 'bipolar']
|
|
@@ -206,6 +209,12 @@ class ExcitationGeneration(BaseFunctionalModule):
|
|
|
206
209
|
pass
|
|
207
210
|
elif unvoiced_region == "gauss":
|
|
208
211
|
e[~mask] = torch.randn(torch.sum(~mask), device=e.device, dtype=e.dtype)
|
|
212
|
+
elif unvoiced_region == "m-sequence":
|
|
213
|
+
e[~mask] = mseq(torch.sum(~mask) - 1, device=e.device, dtype=e.dtype)
|
|
214
|
+
elif unvoiced_region == "uniform":
|
|
215
|
+
e[~mask] = math.sqrt(12) * (
|
|
216
|
+
torch.rand(torch.sum(~mask), device=e.device, dtype=e.dtype) - 0.5
|
|
217
|
+
)
|
|
209
218
|
else:
|
|
210
219
|
raise ValueError(f"unvoiced_region {unvoiced_region} is not supported.")
|
|
211
220
|
return e
|
|
@@ -54,7 +54,7 @@ class GriffinLim(BaseFunctionalModule):
|
|
|
54
54
|
symmetric : bool
|
|
55
55
|
If True, the window is symmetric, otherwise periodic.
|
|
56
56
|
|
|
57
|
-
n_iter : int >=
|
|
57
|
+
n_iter : int >= 0
|
|
58
58
|
The number of iterations for phase reconstruction.
|
|
59
59
|
|
|
60
60
|
alpha : float >= 0
|
|
@@ -159,8 +159,8 @@ class GriffinLim(BaseFunctionalModule):
|
|
|
159
159
|
beta: float,
|
|
160
160
|
gamma: float,
|
|
161
161
|
) -> None:
|
|
162
|
-
if n_iter
|
|
163
|
-
raise ValueError("n_iter must be
|
|
162
|
+
if n_iter < 0:
|
|
163
|
+
raise ValueError("n_iter must be non-negative.")
|
|
164
164
|
if alpha < 0:
|
|
165
165
|
raise ValueError("alpha must be non-negative.")
|
|
166
166
|
if beta < 0:
|
|
@@ -259,7 +259,8 @@ class GriffinLim(BaseFunctionalModule):
|
|
|
259
259
|
if logger is not None:
|
|
260
260
|
logger.info(f"alpha: {alpha}, beta: {beta}, gamma: {gamma}")
|
|
261
261
|
|
|
262
|
-
|
|
262
|
+
eps = 1e-16
|
|
263
|
+
s = torch.sqrt(y + eps)
|
|
263
264
|
angle = torch.exp(1j * phase_generator(s))
|
|
264
265
|
|
|
265
266
|
t_prev = d_prev = 0 # This suppresses F821 and F841.
|
|
@@ -275,7 +276,7 @@ class GriffinLim(BaseFunctionalModule):
|
|
|
275
276
|
c = t + alpha * diff
|
|
276
277
|
d = t + beta * diff
|
|
277
278
|
|
|
278
|
-
angle = c / (c.abs() +
|
|
279
|
+
angle = c / (c.abs() + eps)
|
|
279
280
|
t_prev = t
|
|
280
281
|
d_prev = d
|
|
281
282
|
|
|
@@ -15,9 +15,8 @@
|
|
|
15
15
|
# ------------------------------------------------------------------------ #
|
|
16
16
|
|
|
17
17
|
import torch
|
|
18
|
-
from torchlpc import sample_wise_lpc
|
|
19
18
|
|
|
20
|
-
from ..typing import Precomputed
|
|
19
|
+
from ..typing import Callable, Precomputed
|
|
21
20
|
from ..utils.private import check_size, filter_values
|
|
22
21
|
from .base import BaseFunctionalModule
|
|
23
22
|
from .linear_intpl import LinearInterpolation
|
|
@@ -105,11 +104,17 @@ class AllPoleDigitalFilter(BaseFunctionalModule):
|
|
|
105
104
|
filter_order: int, frame_period: int, ignore_gain: bool = False
|
|
106
105
|
) -> Precomputed:
|
|
107
106
|
AllPoleDigitalFilter._check(filter_order, frame_period)
|
|
108
|
-
|
|
107
|
+
from torchlpc import sample_wise_lpc
|
|
108
|
+
|
|
109
|
+
return (frame_period, ignore_gain, sample_wise_lpc)
|
|
109
110
|
|
|
110
111
|
@staticmethod
|
|
111
112
|
def _forward(
|
|
112
|
-
x: torch.Tensor,
|
|
113
|
+
x: torch.Tensor,
|
|
114
|
+
a: torch.Tensor,
|
|
115
|
+
frame_period: int,
|
|
116
|
+
ignore_gain: bool,
|
|
117
|
+
sample_wise_lpc: Callable,
|
|
113
118
|
) -> torch.Tensor:
|
|
114
119
|
check_size(x.size(-1), a.size(-2) * frame_period, "sequence length")
|
|
115
120
|
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
# limitations under the License. #
|
|
15
15
|
# ------------------------------------------------------------------------ #
|
|
16
16
|
|
|
17
|
+
import math
|
|
18
|
+
|
|
17
19
|
import torch
|
|
18
20
|
|
|
19
21
|
|
|
@@ -234,10 +236,69 @@ def train(
|
|
|
234
236
|
return x
|
|
235
237
|
|
|
236
238
|
|
|
239
|
+
def mseq(*order: int, **kwargs) -> torch.Tensor:
|
|
240
|
+
"""Generate M-sequence.
|
|
241
|
+
|
|
242
|
+
See `mseq <https://sp-nitech.github.io/sptk/latest/main/mseq.html>`_
|
|
243
|
+
for details.
|
|
244
|
+
|
|
245
|
+
Parameters
|
|
246
|
+
----------
|
|
247
|
+
order : int >= 0
|
|
248
|
+
The order of the sequence, :math:`M`.
|
|
249
|
+
|
|
250
|
+
**kwargs : additional keyword arguments
|
|
251
|
+
See `torch.ones <https://pytorch.org/docs/stable/generated/torch.ones.html>`_.
|
|
252
|
+
|
|
253
|
+
Returns
|
|
254
|
+
-------
|
|
255
|
+
out : Tensor [shape=(M+1,)]
|
|
256
|
+
The random value sequence.
|
|
257
|
+
|
|
258
|
+
Examples
|
|
259
|
+
--------
|
|
260
|
+
>>> x = diffsptk.mseq(4)
|
|
261
|
+
>>> x
|
|
262
|
+
tensor([-1., 1., -1., 1., -1.])
|
|
263
|
+
|
|
264
|
+
"""
|
|
265
|
+
if any(isinstance(item, (list, tuple)) for item in order):
|
|
266
|
+
order = list(*order)
|
|
267
|
+
else:
|
|
268
|
+
order = list(order)
|
|
269
|
+
order[-1] += 1
|
|
270
|
+
|
|
271
|
+
out_length = math.prod(order)
|
|
272
|
+
out = torch.ones(out_length, **kwargs)
|
|
273
|
+
|
|
274
|
+
init = 0x55555555 # int("01010101010101010101010101010101", 2)
|
|
275
|
+
B0 = 0x00000001 # 1 << 0
|
|
276
|
+
B28 = 0x10000000 # 1 << 28
|
|
277
|
+
B31 = 0x80000000 # 1 << 31
|
|
278
|
+
B31F = 0x7FFFFFFF # ~(1 << 31) & 0xFFFFFFFF
|
|
279
|
+
|
|
280
|
+
x = init
|
|
281
|
+
for i in range(out_length):
|
|
282
|
+
x >>= 1
|
|
283
|
+
|
|
284
|
+
x0 = 1 if x & B0 else -1
|
|
285
|
+
x28 = 1 if x & B28 else -1
|
|
286
|
+
|
|
287
|
+
if x0 + x28:
|
|
288
|
+
x &= B31F
|
|
289
|
+
else:
|
|
290
|
+
x |= B31
|
|
291
|
+
|
|
292
|
+
if x0 != 1:
|
|
293
|
+
out[i] = x0
|
|
294
|
+
|
|
295
|
+
return out.reshape(order)
|
|
296
|
+
|
|
297
|
+
|
|
237
298
|
def nrand(
|
|
238
299
|
*order: int, mean: float = 0, stdv: float = 1, var: float | None = None, **kwargs
|
|
239
300
|
) -> torch.Tensor:
|
|
240
|
-
"""Generate random number sequence.
|
|
301
|
+
"""Generate Gaussian random number sequence.
|
|
241
302
|
|
|
242
303
|
See `nrand <https://sp-nitech.github.io/sptk/latest/main/nrand.html>`_
|
|
243
304
|
for details.
|
|
@@ -288,3 +349,52 @@ def nrand(
|
|
|
288
349
|
x = torch.randn(*order, **kwargs)
|
|
289
350
|
x = x * stdv + mean
|
|
290
351
|
return x
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def rand(*order: int, a: float = 0, b: float = 1, **kwargs) -> torch.Tensor:
|
|
355
|
+
"""Generate uniform random number sequence.
|
|
356
|
+
|
|
357
|
+
See `rand <https://sp-nitech.github.io/sptk/latest/main/rand.html>`_
|
|
358
|
+
for details.
|
|
359
|
+
|
|
360
|
+
Parameters
|
|
361
|
+
----------
|
|
362
|
+
order : int >= 0
|
|
363
|
+
The order of the sequence, :math:`M`.
|
|
364
|
+
|
|
365
|
+
a : float
|
|
366
|
+
The lower bound.
|
|
367
|
+
|
|
368
|
+
b : float >= 0
|
|
369
|
+
The upper bound.
|
|
370
|
+
|
|
371
|
+
**kwargs : additional keyword arguments
|
|
372
|
+
See `torch.rand <https://pytorch.org/docs/stable/generated/torch.rand.html>`_.
|
|
373
|
+
|
|
374
|
+
Returns
|
|
375
|
+
-------
|
|
376
|
+
out : Tensor [shape=(M+1,)]
|
|
377
|
+
The random value sequence.
|
|
378
|
+
|
|
379
|
+
Examples
|
|
380
|
+
--------
|
|
381
|
+
>>> x = diffsptk.rand(4)
|
|
382
|
+
>>> x
|
|
383
|
+
tensor([0.3425, 0.5997, 0.2882, 0.3961, 0.9791])
|
|
384
|
+
>>> x = diffsptk.rand(2, 4)
|
|
385
|
+
>>> x
|
|
386
|
+
tensor([[0.6170, 0.3649, 0.9397, 0.2408, 0.1868],
|
|
387
|
+
[0.6527, 0.1400, 0.3955, 0.9999, 0.8298]])
|
|
388
|
+
|
|
389
|
+
"""
|
|
390
|
+
if b <= a:
|
|
391
|
+
raise ValueError("Lower bound must be less than upper bound.")
|
|
392
|
+
|
|
393
|
+
if any(isinstance(item, (list, tuple)) for item in order):
|
|
394
|
+
order = list(*order)
|
|
395
|
+
else:
|
|
396
|
+
order = list(order)
|
|
397
|
+
order[-1] += 1
|
|
398
|
+
x = torch.rand(*order, **kwargs)
|
|
399
|
+
x = (b - a) * x + a
|
|
400
|
+
return x
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "3.3.1"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "3.3.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|