wavenet-coding 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wavenet_coding-0.1.0/LICENSE +176 -0
- wavenet_coding-0.1.0/PKG-INFO +300 -0
- wavenet_coding-0.1.0/README.md +268 -0
- wavenet_coding-0.1.0/pyproject.toml +3 -0
- wavenet_coding-0.1.0/scripts/evaluate.py +416 -0
- wavenet_coding-0.1.0/scripts/export_model.py +75 -0
- wavenet_coding-0.1.0/scripts/inference.py +110 -0
- wavenet_coding-0.1.0/scripts/prepare_data.py +108 -0
- wavenet_coding-0.1.0/scripts/train.py +377 -0
- wavenet_coding-0.1.0/setup.cfg +4 -0
- wavenet_coding-0.1.0/setup.py +45 -0
- wavenet_coding-0.1.0/wavenet_coding/__init__.py +45 -0
- wavenet_coding-0.1.0/wavenet_coding/codec2.py +563 -0
- wavenet_coding-0.1.0/wavenet_coding/configs.py +197 -0
- wavenet_coding-0.1.0/wavenet_coding/dataset.py +512 -0
- wavenet_coding-0.1.0/wavenet_coding/entropy_coding.py +266 -0
- wavenet_coding-0.1.0/wavenet_coding/evaluation.py +409 -0
- wavenet_coding-0.1.0/wavenet_coding/export.py +532 -0
- wavenet_coding-0.1.0/wavenet_coding/inference.py +394 -0
- wavenet_coding-0.1.0/wavenet_coding/loss.py +182 -0
- wavenet_coding-0.1.0/wavenet_coding/model.py +756 -0
- wavenet_coding-0.1.0/wavenet_coding.egg-info/PKG-INFO +300 -0
- wavenet_coding-0.1.0/wavenet_coding.egg-info/SOURCES.txt +24 -0
- wavenet_coding-0.1.0/wavenet_coding.egg-info/dependency_links.txt +1 -0
- wavenet_coding-0.1.0/wavenet_coding.egg-info/requires.txt +6 -0
- wavenet_coding-0.1.0/wavenet_coding.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: wavenet-coding
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: WaveNet Based Low Rate Speech Coding (Parametric & Waveform)
|
|
5
|
+
Home-page: https://github.com/wq2012/wavenet_coding
|
|
6
|
+
Author: Quan Wang
|
|
7
|
+
Author-email: quanw@google.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
|
|
12
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
13
|
+
Requires-Python: >=3.9
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: numpy>=1.21.0
|
|
17
|
+
Requires-Dist: scipy>=1.7.0
|
|
18
|
+
Requires-Dist: soundfile>=0.10.0
|
|
19
|
+
Requires-Dist: safetensors>=0.3.0
|
|
20
|
+
Requires-Dist: PyYAML>=6.0
|
|
21
|
+
Requires-Dist: tensorflow>=2.9.0
|
|
22
|
+
Dynamic: author
|
|
23
|
+
Dynamic: author-email
|
|
24
|
+
Dynamic: classifier
|
|
25
|
+
Dynamic: description
|
|
26
|
+
Dynamic: description-content-type
|
|
27
|
+
Dynamic: home-page
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
Dynamic: requires-dist
|
|
30
|
+
Dynamic: requires-python
|
|
31
|
+
Dynamic: summary
|
|
32
|
+
|
|
33
|
+
# wavenet_coding: WaveNet Based Low Rate Speech Coding
|
|
34
|
+
|
|
35
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
36
|
+
[](https://www.python.org/downloads/)
|
|
37
|
+
[](https://pypi.org/project/wavenet-coding/)
|
|
38
|
+
[](https://huggingface.co/spaces/wq2012/wavenet-coding-demo)
|
|
39
|
+
|
|
40
|
+
**This is not an officially supported Google product.**
|
|
41
|
+
|
|
42
|
+
> **Open-Source Paper Reproduction Notice**: This repository is a clean-room, open-source reproduction of the paper **W. Bastiaan Kleijn, Felicia S. C. Lim, Alejandro Luebs, Jan Skoglund, Florian Stimberg, Quan Wang, and Thomas C. Walters, *"WaveNet Based Low Rate Speech Coding,"* IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 676–680, 2018 ([arXiv:1712.01120](https://arxiv.org/abs/1712.01120))**, created after the original publication using open-source frameworks (`TensorFlow 2`, `NumPy`, `SciPy`, `SafeTensors`, `TFLite`, `GGUF`) and public speech datasets (`LibriSpeech` and `VCTK`).
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Overview
|
|
47
|
+
|
|
48
|
+
Traditional speech coders fall into two families:
|
|
49
|
+
1. **Waveform coders** (Sections 2.1 & 2.3): Reconstruct the original signal sample-by-sample with minimal distortion, typically operating above 16 kb/s.
|
|
50
|
+
2. **Parametric coders** (Sections 2.2 & 2.4): Extract compact vocal-tract, pitch, and energy parameters every 10–20 ms (e.g., **Codec 2** at **2.4 kb/s**) and synthesize a perceptually plausible waveform at the receiver.
|
|
51
|
+
|
|
52
|
+
This package implements all four core components introduced in **Kleijn et al. (ICASSP 2018)**:
|
|
53
|
+
- **Closed-Loop WaveNet Waveform Coding (`WW`, Section 2.3)**: Uses an unconditioned causal dilated WaveNet (`q^(i)(x_i | x_0, ..., x_{i-1})`) inside a closed quantization loop over 256-level 8-bit μ-law samples (`n_i = Q(x_i)`), paired with a bit-exact 32-bit integer arithmetic coder to losslessly compress 16 kHz 8-bit μ-law speech from **128 kb/s** down to **91–95 kb/s** (~5.74–5.93 bits/sample).
|
|
54
|
+
- **Codec 2 Conditioned Parametric WaveNet Coding (`WP` / `W_wo` / `W_w`, Section 2.4)**: Conditions a 16 kHz wideband causal WaveNet decoder on **2.4 kb/s Codec 2** narrow-band parameters (48 bits per 20 ms frame: 36 bits LSP spectral envelope, 7 bits fundamental frequency F0, 5 bits energy, and 2 voicing flags interpolated to 10 ms / 160-sample frames). Because the WaveNet decoder operates natively at 16 kHz while Codec 2 parameters are extracted at 8 kHz, the generative decoder performs **implicit bandwidth extension** into the 4–8 kHz upper band.
|
|
55
|
+
- **Likelihood-Guided Mode Switching (`HybridModeSwitchingCodec`, Section 2.4)**: Dynamically switches between 2.4 kb/s parametric coding and closed-loop arithmetic waveform coding on frames where the parametric conditional cross-entropy exceeds a threshold.
|
|
56
|
+
- **GE2E Speaker Verification & Triangle Discriminability (`build_speaker_verifier`, Section 3.4)**: Implements the 3-layer Projected-LSTM (`LSTMP`) speaker embedding network trained with Generalized End-to-End (`GE2E`) softmax loss to evaluate speaker identity preservation across 8-bit μ-law speech, speaker-independent Parametric WaveNet (`W_wo`), and speaker-overlapping Parametric WaveNet (`W_w`).
|
|
57
|
+
|
|
58
|
+
<p align="center">
|
|
59
|
+
<img src="resources/architecture.png" alt="Parametric WaveNet Speech Coder Architecture (Figure 1 of Kleijn et al., ICASSP 2018)" width="760"/>
|
|
60
|
+
</p>
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Pretrained Models & Interactive Demo on Hugging Face
|
|
65
|
+
|
|
66
|
+
All five pretrained models are exported in **four deployment formats** (`SafeTensors`, `TensorFlow SavedModel`, `TFLite FP32 & INT8`, and `GGUF v3 FP16 & Q4_K_M`) and hosted on the Hugging Face Hub:
|
|
67
|
+
|
|
68
|
+
| Model Name | Hugging Face Repository | Task / Paper Section | Initial Metric | Final Metric | Exported Formats |
|
|
69
|
+
| :--- | :--- | :--- | :---: | :---: | :--- |
|
|
70
|
+
| **`wavenet_waveform_coder` (`WW`)** | [`wq2012/wavenet-waveform-coder`](https://huggingface.co/wq2012/wavenet-waveform-coder) | Unconditioned Closed-Loop Waveform Coder (Sec. 2.3 & 3.2) | 5.4979 bits/sample | **5.2410 bits/sample** | `.safetensors`, `saved_model/`, `.tflite` (FP32/INT8), `.gguf` (FP16/Q4_K_M) |
|
|
71
|
+
| **`wavenet_parametric_2400_speaker_independent` (`W_wo`)** | [`wq2012/wavenet-parametric-2400-speaker-independent`](https://huggingface.co/wq2012/wavenet-parametric-2400-speaker-independent) | 2.4 kb/s Codec 2 Parametric WaveNet — Speaker-Disjoint (Sec. 2.4 & 3.3) | 5.6147 bits/sample | **5.3564 bits/sample** | `.safetensors`, `saved_model/`, `.tflite` (FP32/INT8), `.gguf` (FP16/Q4_K_M) |
|
|
72
|
+
| **`wavenet_parametric_2400_speaker_overlapping` (`W_w`)** | [`wq2012/wavenet-parametric-2400-speaker-overlapping`](https://huggingface.co/wq2012/wavenet-parametric-2400-speaker-overlapping) | 2.4 kb/s Codec 2 Parametric WaveNet — Speaker-Overlapping (Sec. 3.3 & 3.4) | 5.7620 bits/sample | **5.2905 bits/sample** | `.safetensors`, `saved_model/`, `.tflite` (FP32/INT8), `.gguf` (FP16/Q4_K_M) |
|
|
73
|
+
| **`wavenet_speaker_verifier_mulaw`** | [`wq2012/wavenet-speaker-verifier-mulaw`](https://huggingface.co/wq2012/wavenet-speaker-verifier-mulaw) | 3-Layer LSTMP GE2E Speaker Verifier on 8-bit μ-law Speech (Sec. 3.4) | 1.7116 GE2E loss | **0.4137 GE2E loss** | `.safetensors`, `saved_model/`, `.tflite` (FP32/INT8), `.gguf` (FP16/Q4_K_M) |
|
|
74
|
+
| **`wavenet_speaker_verifier_coded`** | [`wq2012/wavenet-speaker-verifier-coded`](https://huggingface.co/wq2012/wavenet-speaker-verifier-coded) | 3-Layer LSTMP GE2E Speaker Verifier on 2.4 kb/s Coded Speech (Sec. 3.4) | 2.3220 GE2E loss | **1.3837 GE2E loss** | `.safetensors`, `saved_model/`, `.tflite` (FP32/INT8), `.gguf` (FP16/Q4_K_M) |
|
|
75
|
+
|
|
76
|
+
- **Interactive Demo Space**: [**`wq2012/wavenet-coding-demo`**](https://huggingface.co/spaces/wq2012/wavenet-coding-demo)
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Reproduced Experimental Results
|
|
81
|
+
|
|
82
|
+
All benchmark evaluations below were executed using `scripts/evaluate.py` on held-out 16 kHz evaluation utterances across two open-source multi-speaker speech corpora (**LibriSpeech `test-clean`** and **CSTR VCTK Corpus**), with raw metrics saved in [`pretrained_models/evaluation_librispeech.json`](pretrained_models/evaluation_librispeech.json) and [`pretrained_models/evaluation_vctk.json`](pretrained_models/evaluation_vctk.json).
|
|
83
|
+
|
|
84
|
+
### 1. Closed-Loop WaveNet Waveform Coding Rates (Section 3.2)
|
|
85
|
+
|
|
86
|
+
In Section 3.2 of the paper, the average conditional entropy `H̄` (Eq. 4, theoretical lower bound) and average cross-entropy code rate `R` (Eq. 5, actual bit rate of an ideal arithmetic coder) are computed over non-silent speech frames at 16 kHz:
|
|
87
|
+
- `H̄ = - (1 / I) ∑_i ∑_n q^(i)(Z(n)) log₂ q^(i)(Z(n))`
|
|
88
|
+
- `R = - (1 / I) ∑_i log₂ q^(i)(Q(x_i))`
|
|
89
|
+
|
|
90
|
+
| Dataset / Split | Mean Conditional Entropy H̄ (bits/sample) | Theoretical Lower-Bound Bitrate (kb/s) | Cross-Entropy Code Rate R (bits/sample) | Achieved Bitrate (kb/s) | Uncompressed 8-bit μ-law (kb/s) | Bitrate Savings (%) | Arithmetic Coder Lossless Match Rate |
|
|
91
|
+
| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|
|
92
|
+
| **Paper Reported (WSJ0, Sec. 3.2)** | 5.7000 | 91.20 | 5.9000 | 94.40 | 128.00 | 26.25% | 100.0% |
|
|
93
|
+
| **Reproduced — LibriSpeech (`test-clean`)** | **5.7415** | **91.86** | **5.9333** | **94.93** | 128.00 | **25.84%** | **100.0%** |
|
|
94
|
+
| **Reproduced — VCTK Corpus** | **5.7457** | **91.93** | **5.8275** | **93.24** | 128.00 | **27.16%** | **100.0%** |
|
|
95
|
+
|
|
96
|
+
#### Paper Figure 2 vs. Reproduced Instantaneous Entropy Profile
|
|
97
|
+
|
|
98
|
+
As observed in Section 3.2 of the paper, the instantaneous entropy `H_i` is lowest during near-silent intervals, intermediate during quasi-periodic voiced segments (where autoregressive pitch prediction reduces uncertainty), and highest during unvoiced fricatives/plosives.
|
|
99
|
+
|
|
100
|
+
<p align="center">
|
|
101
|
+
<img src="resources/entropy.png" alt="Paper Figure 2: Instantaneous Entropy Profile" width="48%"/>
|
|
102
|
+
<img src="resources/reproduced_entropy_profile.png" alt="Reproduced Instantaneous Entropy Profile on LibriSpeech" width="48%"/>
|
|
103
|
+
</p>
|
|
104
|
+
|
|
105
|
+
### 2. Parametric 2.4 kb/s & Reference Codec Comparison (Section 3.3)
|
|
106
|
+
|
|
107
|
+
Section 3.3 compares the 16 kHz Reference, Closed-Loop WaveNet Waveform Coder (`WW`), **AMR-WB (`23.85 kb/s`)**, **Parametric WaveNet with speaker overlap (`W_w, 2.4 kb/s`)**, **Parametric WaveNet without speaker overlap (`W_wo, 2.4 kb/s`)**, **Speex (`2.15 kb/s`)**, **Codec 2 (`2.4 kb/s`)**, and **MELP (`2.4 kb/s`)**.
|
|
108
|
+
|
|
109
|
+
Our reproduction confirms both core findings of Section 3.3:
|
|
110
|
+
1. **Perceptual Quality Ranking**: At **2.4 kb/s**, both Parametric WaveNet coders (`W_w` and `W_wo`) substantially outperform all narrow-band low-rate parametric codecs (`MELP 2.4 kb/s`, `Codec 2 2.4 kb/s`, `Speex 2.15 kb/s`) and approach wideband `AMR-WB (23.85 kb/s)` at one-tenth the bitrate.
|
|
111
|
+
2. **Implicit 4–8 kHz Bandwidth Extension**: Whereas narrow-band 8 kHz codecs (`MELP`, `Codec 2`, `Speex`) contain near-zero spectral energy above 4 kHz (`< 0.07%`), the 16 kHz Parametric WaveNet decoder reconstructs the 4–8 kHz upper band (`3.671%` high-band energy for `W_w` and `1.643%` for `W_wo` on LibriSpeech, matching the `3.641%` wideband 16 kHz reference).
|
|
112
|
+
|
|
113
|
+
#### LibriSpeech (`test-clean`) Evaluation (`pretrained_models/evaluation_librispeech.json`)
|
|
114
|
+
|
|
115
|
+
| System / Codec | Bitrate (kb/s) | Objective Wideband MOS-LQO (1–5) ↑ | Mel Cepstral Distortion MCD (dB) ↓ | Log-Spectral Distance LSD (dB) ↓ | Segmental SNR (dB) ↑ | High-Band (4–8 kHz) Energy Ratio (%) |
|
|
116
|
+
| :--- | :---: | :---: | :---: | :---: | :---: | :---: |
|
|
117
|
+
| **Reference (16 kHz)** | 256.00 | **4.850** | 0.000 | 0.000 | 45.000 | 3.641% |
|
|
118
|
+
| **8-bit μ-law (128 kb/s)** | 128.00 | **4.738** | 0.305 | 0.641 | 37.484 | 3.650% |
|
|
119
|
+
| **WaveNet Waveform (`WW`)** | 94.93 | **4.738** | 0.305 | 0.641 | 37.484 | 3.650% |
|
|
120
|
+
| **AMR-WB (23.85 kb/s)** | 23.85 | **3.449** | 3.197 | 5.307 | 8.900 | 3.397% |
|
|
121
|
+
| **WaveNet Parametric (`W_w`, 2.4 kb/s)** | 2.40 | **3.245** | 3.420 | 3.565 | 3.716 | **3.671%** |
|
|
122
|
+
| **WaveNet Parametric (`W_wo`, 2.4 kb/s)** | 2.40 | **2.230** | 7.505 | 7.905 | 1.537 | **1.643%** |
|
|
123
|
+
| **Speex (2.15 kb/s)** | 2.15 | 1.893 | 7.459 | 8.219 | 0.426 | 0.069% |
|
|
124
|
+
| **Codec 2 (2.4 kb/s)** | 2.40 | 1.646 | 8.277 | 8.172 | -2.491 | 0.023% |
|
|
125
|
+
| **MELP (2.4 kb/s)** | 2.40 | 1.627 | 8.412 | 8.770 | -2.744 | 0.041% |
|
|
126
|
+
|
|
127
|
+
#### VCTK Corpus Evaluation (`pretrained_models/evaluation_vctk.json`)
|
|
128
|
+
|
|
129
|
+
| System / Codec | Bitrate (kb/s) | Objective Wideband MOS-LQO (1–5) ↑ | Mel Cepstral Distortion MCD (dB) ↓ | Log-Spectral Distance LSD (dB) ↓ | Segmental SNR (dB) ↑ | High-Band (4–8 kHz) Energy Ratio (%) |
|
|
130
|
+
| :--- | :---: | :---: | :---: | :---: | :---: | :---: |
|
|
131
|
+
| **Reference (16 kHz)** | 256.00 | **4.850** | 0.000 | 0.000 | 45.000 | 1.826% |
|
|
132
|
+
| **8-bit μ-law (128 kb/s)** | 128.00 | **4.697** | 0.501 | 0.648 | 37.162 | 1.834% |
|
|
133
|
+
| **WaveNet Waveform (`WW`)** | 93.24 | **4.697** | 0.501 | 0.648 | 37.162 | 1.834% |
|
|
134
|
+
| **AMR-WB (23.85 kb/s)** | 23.85 | **3.364** | 3.541 | 5.359 | 8.749 | 1.563% |
|
|
135
|
+
| **WaveNet Parametric (`W_w`, 2.4 kb/s)** | 2.40 | **3.110** | 4.210 | 4.056 | 4.352 | **2.064%** |
|
|
136
|
+
| **WaveNet Parametric (`W_wo`, 2.4 kb/s)** | 2.40 | **2.131** | 8.193 | 8.397 | 1.972 | **1.510%** |
|
|
137
|
+
| **Speex (2.15 kb/s)** | 2.15 | 1.722 | 8.392 | 8.341 | 0.257 | 0.038% |
|
|
138
|
+
| **MELP (2.4 kb/s)** | 2.40 | 1.454 | 9.397 | 9.090 | -2.683 | 0.033% |
|
|
139
|
+
| **Codec 2 (2.4 kb/s)** | 2.40 | 1.356 | 10.187 | 8.785 | -2.545 | 0.015% |
|
|
140
|
+
|
|
141
|
+
<p align="center">
|
|
142
|
+
<img src="resources/mushra.png" alt="Paper Figure 3: MUSHRA Perceptual Evaluation" width="44%"/>
|
|
143
|
+
<img src="resources/reproduced_codec_comparison.png" alt="Reproduced Codec Quality & Implicit Bandwidth Extension Comparison" width="54%"/>
|
|
144
|
+
</p>
|
|
145
|
+
|
|
146
|
+
### 3. Speaker Identification & Triangle Test (Section 3.4)
|
|
147
|
+
|
|
148
|
+
Section 3.4 evaluates speaker identity preservation using a 3-layer Projected-LSTM (`LSTMP`) speaker verification network trained with `GE2E` loss, plus a 3-stimulus triangle test (`Original`, `W_wo`, `W_w`) measuring how often `W_wo` is identified as the odd speaker out compared to the `33.33%` random-chance baseline:
|
|
149
|
+
|
|
150
|
+
| Benchmark / Dataset | 8-bit μ-law EER (%) [95% CI] | Parametric WaveNet `W_wo` EER (%) [95% CI] | Parametric WaveNet `W_w` EER (%) [95% CI] | Mean Cosine Similarity `cos(Orig, W_w)` vs `cos(Orig, W_wo)` | Triangle Test Odd-One-Out Rate (`W_wo` selected vs `33.33%` chance) |
|
|
151
|
+
| :--- | :---: | :---: | :---: | :---: | :---: |
|
|
152
|
+
| **Paper Reported (WSJ0, Sec. 3.4)** | 2.39% [0.99%, 4.74%] | 6.92% [3.70%, 10.58%] | — | — | **41.67%** (chance: 33.33%) |
|
|
153
|
+
| **Reproduced — LibriSpeech (`test-clean`)** | **12.05%** [2.22%, 19.64%] | **25.00%** [9.75%, 37.96%] | **25.00%** [5.36%, 50.00%] | **0.8089** vs **0.4884** (`Δ = +0.3206`) | **43.25%** (chance: 33.33%) |
|
|
154
|
+
| **Reproduced — VCTK Corpus** | **25.00%** [11.60%, 42.44%] | **37.05%** [20.04%, 50.52%] | **24.55%** [12.05%, 46.89%] | **0.5796** vs **0.2807** (`Δ = +0.2990`) | **42.60%** (chance: 33.33%) |
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Installation
|
|
159
|
+
|
|
160
|
+
Install from PyPI:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
pip install wavenet-coding
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Or install from source in editable mode:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
git clone https://github.com/wq2012/wavenet_coding.git
|
|
170
|
+
cd wavenet_coding
|
|
171
|
+
pip install -e ".[dev]"
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Quickstart & Python API
|
|
177
|
+
|
|
178
|
+
### 1. Closed-Loop WaveNet Waveform Coding (`WW`, Section 2.3)
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
import numpy as np
|
|
182
|
+
from wavenet_coding import inference
|
|
183
|
+
|
|
184
|
+
# Load pretrained or default closed-loop WaveNet waveform coder
|
|
185
|
+
codec = inference.WaveNetWaveformCodec.from_pretrained(
|
|
186
|
+
"pretrained_models/wavenet_waveform_coder"
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
# Encode and losslessly decode 16 kHz speech with 32-bit arithmetic coding
|
|
190
|
+
t = np.linspace(0.0, 0.2, 3200, endpoint=False, dtype=np.float32)
|
|
191
|
+
waveform_16k = 0.6 * np.sin(2.0 * np.pi * 180.0 * t)
|
|
192
|
+
result = codec.encode_and_decode(waveform_16k, run_arithmetic_coder=True)
|
|
193
|
+
|
|
194
|
+
print("Mean entropy H_bar (bits/sample):",
|
|
195
|
+
result["rate_metrics"]["mean_entropy_bits_per_sample"])
|
|
196
|
+
print("Cross-entropy code rate R (kb/s):",
|
|
197
|
+
result["rate_metrics"]["cross_entropy_rate_kbps"])
|
|
198
|
+
print("Bit-exact lossless reconstruction:", result["lossless_exact_match"])
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### 2. 2.4 kb/s Codec 2 Conditioned Parametric WaveNet (`W_w` / `W_wo`, Section 2.4)
|
|
202
|
+
|
|
203
|
+
```python
|
|
204
|
+
from wavenet_coding import inference
|
|
205
|
+
|
|
206
|
+
parametric_codec = inference.WaveNetParametricCodec.from_pretrained(
|
|
207
|
+
"pretrained_models/wavenet_parametric_2400_speaker_overlapping"
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
out = parametric_codec.encode_and_decode(waveform_16k, temperature=0.70)
|
|
211
|
+
reconstructed_16k = out["reconstructed_waveform"]
|
|
212
|
+
print("Codec 2 Conditioning Bitrate:", out["bitrate_kbps"], "kb/s")
|
|
213
|
+
print("Reconstructed 16 kHz Shape:", reconstructed_16k.shape)
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## End-to-End Reproduction Pipeline (CLI)
|
|
219
|
+
|
|
220
|
+
### Step 1: Prepare Speaker-Disjoint & Speaker-Overlapping Splits
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
python3 scripts/prepare_data.py \
|
|
224
|
+
--dataset_dir /path/to/LibriSpeech/test-clean \
|
|
225
|
+
--output_dir /tmp/wavenet_data_librispeech \
|
|
226
|
+
--max_speakers 24 \
|
|
227
|
+
--max_utterances_per_speaker 16
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Step 2: Train Models (`WW`, `W_wo`, `W_w`, and `GE2E` Speaker Verifiers)
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
# 1. Closed-Loop WaveNet Waveform Coder (WW)
|
|
234
|
+
python3 scripts/train.py \
|
|
235
|
+
--config configs/wavenet_waveform_coder.yml \
|
|
236
|
+
--manifest /tmp/wavenet_data_librispeech/data_manifest.json \
|
|
237
|
+
--output_dir pretrained_models/wavenet_waveform_coder \
|
|
238
|
+
--epochs 12
|
|
239
|
+
|
|
240
|
+
# 2. Parametric WaveNet without Speaker Overlap (W_wo, 2.4 kb/s)
|
|
241
|
+
python3 scripts/train.py \
|
|
242
|
+
--config configs/wavenet_parametric_2400_speaker_independent.yml \
|
|
243
|
+
--manifest /tmp/wavenet_data_librispeech/data_manifest.json \
|
|
244
|
+
--output_dir pretrained_models/wavenet_parametric_2400_speaker_independent \
|
|
245
|
+
--epochs 12
|
|
246
|
+
|
|
247
|
+
# 3. Parametric WaveNet with Speaker Overlap (W_w, 2.4 kb/s)
|
|
248
|
+
python3 scripts/train.py \
|
|
249
|
+
--config configs/wavenet_parametric_2400_speaker_overlapping.yml \
|
|
250
|
+
--manifest /tmp/wavenet_data_librispeech/data_manifest.json \
|
|
251
|
+
--output_dir pretrained_models/wavenet_parametric_2400_speaker_overlapping \
|
|
252
|
+
--epochs 12
|
|
253
|
+
|
|
254
|
+
# 4. GE2E Speaker Verifiers (mu-law and 2.4 kb/s coded domains)
|
|
255
|
+
python3 scripts/train.py \
|
|
256
|
+
--task speaker_verifier --domain mulaw \
|
|
257
|
+
--manifest /tmp/wavenet_data_librispeech/data_manifest.json \
|
|
258
|
+
--output_dir pretrained_models/wavenet_speaker_verifier_mulaw \
|
|
259
|
+
--epochs 25
|
|
260
|
+
|
|
261
|
+
python3 scripts/train.py \
|
|
262
|
+
--task speaker_verifier --domain coded \
|
|
263
|
+
--manifest /tmp/wavenet_data_librispeech/data_manifest.json \
|
|
264
|
+
--output_dir pretrained_models/wavenet_speaker_verifier_coded \
|
|
265
|
+
--epochs 25
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Step 3: Evaluate All Codecs & Generate Plots
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
python3 scripts/evaluate.py \
|
|
272
|
+
--manifest /tmp/wavenet_data_librispeech/data_manifest.json \
|
|
273
|
+
--models_dir pretrained_models \
|
|
274
|
+
--output_json pretrained_models/evaluation_librispeech.json \
|
|
275
|
+
--plots_dir resources
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Step 4: Run Unit Tests, Coverage, Linting, and API Docs
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
flake8 --indent-size 2 --max-line-length 80 .
|
|
282
|
+
bash run_tests.sh
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## Citation
|
|
288
|
+
|
|
289
|
+
If you use this library or the pretrained models in your research, please cite the original ICASSP 2018 paper:
|
|
290
|
+
|
|
291
|
+
```bibtex
|
|
292
|
+
@inproceedings{kleijn2018wavenet,
|
|
293
|
+
title={WaveNet Based Low Rate Speech Coding},
|
|
294
|
+
author={Kleijn, W. Bastiaan and Lim, Felicia S. C. and Luebs, Alejandro and Skoglund, Jan and Stimberg, Florian and Wang, Quan and Walters, Thomas C.},
|
|
295
|
+
booktitle={2018 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)},
|
|
296
|
+
pages={676--680},
|
|
297
|
+
year={2018},
|
|
298
|
+
organization={IEEE}
|
|
299
|
+
}
|
|
300
|
+
```
|