textual-echo-cancellation 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.
- textual_echo_cancellation-0.1.0/LICENSE +176 -0
- textual_echo_cancellation-0.1.0/PKG-INFO +308 -0
- textual_echo_cancellation-0.1.0/README.md +278 -0
- textual_echo_cancellation-0.1.0/scripts/evaluate.py +350 -0
- textual_echo_cancellation-0.1.0/scripts/export_tflite.py +94 -0
- textual_echo_cancellation-0.1.0/scripts/inference.py +100 -0
- textual_echo_cancellation-0.1.0/scripts/prepare_data.py +190 -0
- textual_echo_cancellation-0.1.0/scripts/train.py +171 -0
- textual_echo_cancellation-0.1.0/setup.cfg +4 -0
- textual_echo_cancellation-0.1.0/setup.py +37 -0
- textual_echo_cancellation-0.1.0/tec/__init__.py +78 -0
- textual_echo_cancellation-0.1.0/tec/aec_model.py +124 -0
- textual_echo_cancellation-0.1.0/tec/configs.py +231 -0
- textual_echo_cancellation-0.1.0/tec/data_prep.py +426 -0
- textual_echo_cancellation-0.1.0/tec/decoder.py +602 -0
- textual_echo_cancellation-0.1.0/tec/encoder_speech.py +46 -0
- textual_echo_cancellation-0.1.0/tec/encoder_text.py +108 -0
- textual_echo_cancellation-0.1.0/tec/evaluation.py +190 -0
- textual_echo_cancellation-0.1.0/tec/inference.py +118 -0
- textual_echo_cancellation-0.1.0/tec/input_generator.py +201 -0
- textual_echo_cancellation-0.1.0/tec/layers.py +61 -0
- textual_echo_cancellation-0.1.0/tec/multi_source_attention_steps.py +98 -0
- textual_echo_cancellation-0.1.0/tec/tec_model.py +139 -0
- textual_echo_cancellation-0.1.0/tec/tflite_export.py +146 -0
- textual_echo_cancellation-0.1.0/tec/tokenizer.py +68 -0
- textual_echo_cancellation-0.1.0/tec/waveform_processor.py +272 -0
- textual_echo_cancellation-0.1.0/textual_echo_cancellation.egg-info/PKG-INFO +308 -0
- textual_echo_cancellation-0.1.0/textual_echo_cancellation.egg-info/SOURCES.txt +29 -0
- textual_echo_cancellation-0.1.0/textual_echo_cancellation.egg-info/dependency_links.txt +1 -0
- textual_echo_cancellation-0.1.0/textual_echo_cancellation.egg-info/requires.txt +4 -0
- textual_echo_cancellation-0.1.0/textual_echo_cancellation.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,308 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: textual-echo-cancellation
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Textual Echo Cancellation (TEC) with Multi-Source Attention
|
|
5
|
+
Home-page: https://github.com/wq2012/tec
|
|
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.8
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: lingvo>=0.10.0
|
|
17
|
+
Requires-Dist: numpy>=1.19.5
|
|
18
|
+
Requires-Dist: scipy>=1.5.4
|
|
19
|
+
Requires-Dist: tensorflow>=2.4.0
|
|
20
|
+
Dynamic: author
|
|
21
|
+
Dynamic: author-email
|
|
22
|
+
Dynamic: classifier
|
|
23
|
+
Dynamic: description
|
|
24
|
+
Dynamic: description-content-type
|
|
25
|
+
Dynamic: home-page
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
Dynamic: requires-dist
|
|
28
|
+
Dynamic: requires-python
|
|
29
|
+
Dynamic: summary
|
|
30
|
+
|
|
31
|
+
# Textual Echo Cancellation (TEC)
|
|
32
|
+
|
|
33
|
+
[](https://github.com/wq2012/tec/actions/workflows/pythonapp.yml)
|
|
34
|
+
[](https://pypi.org/project/textual-echo-cancellation/)
|
|
35
|
+
[](https://pypi.org/project/textual-echo-cancellation/)
|
|
36
|
+
[](https://www.pepy.tech/projects/textual-echo-cancellation)
|
|
37
|
+
|
|
38
|
+
## Introduction
|
|
39
|
+
|
|
40
|
+
This repository provides a standalone, open-source Python reproduction of
|
|
41
|
+
**Textual Echo Cancellation (TEC)** based on the IEEE SLT 2021 paper:
|
|
42
|
+
|
|
43
|
+
> **Textual Echo Cancellation**
|
|
44
|
+
> *Shaojin Ding, Ye Jia, Ke Hu, Quan Wang*
|
|
45
|
+
> Paper: [https://arxiv.org/pdf/2008.06006](https://arxiv.org/pdf/2008.06006) | Audio Demo Page: [https://google.github.io/speaker-id/publications/TEC/](https://google.github.io/speaker-id/publications/TEC/)
|
|
46
|
+
|
|
47
|
+
> [!NOTE]
|
|
48
|
+
> **Open-Source Reproduction Notice**: This library is an independent
|
|
49
|
+
> open-source reproduction of the published paper above. It does **not** use the
|
|
50
|
+
> exact same codebase as the original paper, which was developed on top of
|
|
51
|
+
> Google's internal software infrastructure (including internal training
|
|
52
|
+
> frameworks, acoustic frontends, room simulators, WaveRNN vocoders, and ASR
|
|
53
|
+
> evaluation pipelines). Instead, all modules in this repository are newly
|
|
54
|
+
> implemented from scratch using open-source [`lingvo`](https://github.com/tensorflow/lingvo)
|
|
55
|
+
> and `tensorflow` to make the architecture, data preparation, training,
|
|
56
|
+
> evaluation, and TFLite export accessible to the broader research community.
|
|
57
|
+
|
|
58
|
+
When a user speaks to a smart speaker or voice-enabled device while the device
|
|
59
|
+
is playing back a Text-to-Speech (TTS) response, the microphone captures a
|
|
60
|
+
reverberant mixture of the user's speech and the device's TTS playback.
|
|
61
|
+
Classical Acoustic Echo Cancellation (AEC) requires streaming the full
|
|
62
|
+
high-bandwidth TTS reference waveform to the echo canceller. **Textual Echo
|
|
63
|
+
Cancellation (TEC)** instead uses the lightweight **text transcript of the
|
|
64
|
+
interfering TTS prompt** (< 1 KB) as a side input to a multi-source attention
|
|
65
|
+
sequence-to-sequence neural network, canceling the interfering TTS echo and
|
|
66
|
+
reconstructing the clean user speech spectrogram and waveform.
|
|
67
|
+
|
|
68
|
+
<p align="center">
|
|
69
|
+
<img src="resources/TEC_use_case.png" alt="Fig. 1: Acoustic echoes caused by TTS playback overlapping with user query" width="340" />
|
|
70
|
+
|
|
71
|
+
<img src="resources/TEC_diagram.png" alt="Fig. 2: Diagram of the Textual Echo Cancellation framework" width="520" />
|
|
72
|
+
</p>
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Features
|
|
77
|
+
|
|
78
|
+
- **Complete Model Suite**:
|
|
79
|
+
- `TecModel`: Multi-source sequence-to-sequence model taking noisy/reverberant
|
|
80
|
+
speech (`SpeechEncoderV1`) and interfering TTS text (`TtsEncoderV2`) with
|
|
81
|
+
`MultiSourceFbeDecoderV1` (`GmmMonotonicAttention` or `AdditiveAttention`).
|
|
82
|
+
- `AecModel` (`AEC-Seq2seq`): Neural baseline taking noisy/reverberant speech
|
|
83
|
+
and clean reference TTS audio with dual speech encoders and multi-source
|
|
84
|
+
attention.
|
|
85
|
+
- `VanillaSeq2SeqModel` (`NoSideInput`): Single-source sequence-to-sequence
|
|
86
|
+
speech enhancement baseline without side input.
|
|
87
|
+
- `NlmsAec` (`AEC-NLMS`): Classical Normalized Least Mean Squares adaptive
|
|
88
|
+
filter baseline.
|
|
89
|
+
- **Standalone Lingvo Implementation**: Built on open-source
|
|
90
|
+
[`lingvo`](https://github.com/tensorflow/lingvo) and `tensorflow`, with zero
|
|
91
|
+
dependencies on proprietary internal libraries.
|
|
92
|
+
|
|
93
|
+
<p align="center">
|
|
94
|
+
<img src="resources/Decoder.png" alt="Fig. 3: Diagram of the decoder with multi-source attention" width="360" />
|
|
95
|
+
</p>
|
|
96
|
+
- **End-to-End Pipelines & CLI Scripts**:
|
|
97
|
+
- **Dataset Preparation** (`scripts/prepare_data.py`): Pairs clean speech
|
|
98
|
+
(LibriTTS) with longer interfering TTS utterances (LJSpeech / VCTK),
|
|
99
|
+
simulates room impulse response (RIR) reverberation, mixes at a target SNR
|
|
100
|
+
(default 0 dB), pads trailing zeros, and writes `TFRecord` datasets.
|
|
101
|
+
- **Model Training** (`scripts/train.py`): Trains any registered Lingvo
|
|
102
|
+
configuration (`TecSingleInterfering`, `TecMultiInterfering`,
|
|
103
|
+
`AecSingleInterfering`, `NoSideInputSingleInterfering`, etc.).
|
|
104
|
+
- **Inference & Waveform Synthesis** (`scripts/inference.py`): Predicts
|
|
105
|
+
enhanced log-Mel spectrograms and synthesizes 24 kHz waveforms via
|
|
106
|
+
Griffin-Lim phase reconstruction (`WaveformProcessor`).
|
|
107
|
+
- **Evaluation** (`scripts/evaluate.py`): Computes 13-MFCC Mel Cepstral
|
|
108
|
+
Distortion (MCD) with Dynamic Time Warping (DTW), punctuation-normalized
|
|
109
|
+
Word Error Rate (WER), and model FLOPS / side-input bandwidth.
|
|
110
|
+
- **TFLite Export** (`scripts/export_tflite.py`): Exports trained models to
|
|
111
|
+
`.tflite` FlatBuffer format (with optional dynamic range quantization) and
|
|
112
|
+
validates on-device execution with `tf.lite.Interpreter`.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Installation
|
|
117
|
+
|
|
118
|
+
Install from PyPI:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
pip3 install textual-echo-cancellation
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Or install from source:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
git clone https://github.com/wq2012/tec.git
|
|
128
|
+
cd tec
|
|
129
|
+
pip3 install -r requirements.txt
|
|
130
|
+
pip3 install -e .
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Quickstart
|
|
136
|
+
|
|
137
|
+
### 1. Prepare Training & Evaluation Datasets
|
|
138
|
+
|
|
139
|
+
<p align="center">
|
|
140
|
+
<img src="resources/data_config.png" alt="Dataset Mixing Pipeline" width="540" />
|
|
141
|
+
</p>
|
|
142
|
+
|
|
143
|
+
You can prepare a `TFRecord` dataset from CSV manifests (`utt_id,wav_path,transcript`)
|
|
144
|
+
of clean speech (e.g., [LibriTTS](http://www.openslr.org/60/)) and interfering
|
|
145
|
+
TTS speech (e.g., [LJSpeech](https://keithito.com/LJ-Speech-Dataset/) or
|
|
146
|
+
[VCTK](https://datashare.ed.ac.uk/handle/10283/3443)), or generate a synthetic
|
|
147
|
+
dataset for testing:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Generate a synthetic TFRecord dataset for quick testing:
|
|
151
|
+
python3 scripts/prepare_data.py \
|
|
152
|
+
--generate_synthetic \
|
|
153
|
+
--num_synthetic 16 \
|
|
154
|
+
--snr_db 0.0 \
|
|
155
|
+
--reverb_rt60 0.25 \
|
|
156
|
+
--output_tfrecord /tmp/tec_data/train.tfrecord
|
|
157
|
+
|
|
158
|
+
# Or prepare from LibriTTS + LJSpeech CSV manifests:
|
|
159
|
+
python3 scripts/prepare_data.py \
|
|
160
|
+
--clean_manifest_csv /path/to/libritts_train.csv \
|
|
161
|
+
--interfering_manifest_csv /path/to/ljspeech_train.csv \
|
|
162
|
+
--snr_db 0.0 \
|
|
163
|
+
--reverb_rt60 0.25 \
|
|
164
|
+
--output_tfrecord /tmp/tec_data/train.tfrecord
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### 2. Train the Model
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
python3 scripts/train.py \
|
|
171
|
+
--model TecSingleInterfering \
|
|
172
|
+
--train_file_pattern "/tmp/tec_data/train.tfrecord" \
|
|
173
|
+
--logdir /tmp/tec_checkpoints \
|
|
174
|
+
--max_steps 100 \
|
|
175
|
+
--batch_size 4 \
|
|
176
|
+
--learning_rate 1e-3
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Available `--model` configurations:
|
|
180
|
+
- `TecSingleInterfering`: TEC model (speech + TTS text) for single-speaker TTS
|
|
181
|
+
interference (LibriTTS + LJSpeech).
|
|
182
|
+
- `TecMultiInterfering`: TEC model (speech + TTS text) for multi-speaker TTS
|
|
183
|
+
interference (LibriTTS + VCTK).
|
|
184
|
+
- `AecSingleInterfering` / `AecMultiInterfering`: `AEC-Seq2seq` baseline
|
|
185
|
+
(speech + TTS reference audio).
|
|
186
|
+
- `NoSideInputSingleInterfering` / `NoSideInputMultiInterfering`:
|
|
187
|
+
`Vanilla-Seq2seq` baseline (speech mixture only).
|
|
188
|
+
|
|
189
|
+
### 3. Run Inference
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
python3 scripts/inference.py \
|
|
193
|
+
--model TecSingleInterfering \
|
|
194
|
+
--checkpoint_path /tmp/tec_checkpoints/model.ckpt-100 \
|
|
195
|
+
--mixed_wav /path/to/mixed_input.wav \
|
|
196
|
+
--interfering_text "currently in mountain view it is 72 degrees" \
|
|
197
|
+
--output_wav /tmp/enhanced_clean.wav
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### 4. Evaluate MCD, WER, and Model Complexity
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
python3 scripts/evaluate.py \
|
|
204
|
+
--ref_wav /path/to/clean_reference.wav \
|
|
205
|
+
--pred_wav /tmp/enhanced_clean.wav \
|
|
206
|
+
--ref_transcript "Turn off the bedroom lights!" \
|
|
207
|
+
--hyp_transcript "turn off the bedroom lights" \
|
|
208
|
+
--print_complexity
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### 5. Export to TensorFlow Lite (`.tflite`)
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
python3 scripts/export_tflite.py \
|
|
215
|
+
--model TecSingleInterfering \
|
|
216
|
+
--output_tflite /tmp/tec_model.tflite \
|
|
217
|
+
--num_frames 32 \
|
|
218
|
+
--text_length 16 \
|
|
219
|
+
--decode_steps 8 \
|
|
220
|
+
--quantize \
|
|
221
|
+
--verify
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## Published Paper Reference Results
|
|
227
|
+
|
|
228
|
+
For reference, **Table 3** of the original paper
|
|
229
|
+
([arXiv:2008.06006v4](https://arxiv.org/pdf/2008.06006)) reported the following
|
|
230
|
+
results using Google's internal speech infrastructure on 24 kHz LibriTTS mixed
|
|
231
|
+
at 0 dB SNR with reverberant LJ Speech (single interfering voice) and VCTK
|
|
232
|
+
(multiple interfering voices):
|
|
233
|
+
|
|
234
|
+
| Condition | Method | WER (%) test-clean ↓ | WER (%) test-other ↓ | MCD (dB) test-clean ↓ | MCD (dB) test-other ↓ | MOS test-clean ↑ | MOS test-other ↑ | Side input (KB) ↓ | GFLOPS ↓ |
|
|
235
|
+
| :--- | :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|
|
236
|
+
| **Ground-truth LibriTTS** | - | 2.30 | 4.50 | 0.00 | 0.00 | 4.43 ± 0.04 | 3.82 ± 0.06 | - | - |
|
|
237
|
+
| **Single interfering voice** *(LibriTTS + LJ Speech)* | Microphone signal | 89.9 | 120.5 | 18.83 | 21.44 | - | - | - | - |
|
|
238
|
+
| | AEC-NLMS | 48.6 | 60.1 | 12.26 | 12.57 | 1.95 ± 0.10 | 1.28 ± 0.09 | 310 | 0 |
|
|
239
|
+
| | Vanilla-Seq2seq | 25.4 | 54.0 | 7.85 | 8.84 | 1.99 ± 0.06 | 1.47 ± 0.05 | 0 | 6.32 |
|
|
240
|
+
| | AEC-Seq2seq | 8.30 | 24.3 | 6.38 | 7.07 | 2.77 ± 0.07 | 1.90 ± 0.06 | 310 | 9.51 |
|
|
241
|
+
| | **TEC (proposed)** | **15.5** | **39.8** | **7.51** | **8.54** | **2.20 ± 0.07** | **1.65 ± 0.06** | **0.10** | **7.27** |
|
|
242
|
+
| **Multiple interfering voices** *(LibriTTS + VCTK)* | Microphone signal | 29.7 | 44.6 | 10.75 | 12.88 | - | - | - | - |
|
|
243
|
+
| | AEC-NLMS | 15.5 | 35.5 | 6.57 | 8.13 | 2.06 ± 0.11 | 1.60 ± 0.08 | 230 | 0 |
|
|
244
|
+
| | Vanilla-Seq2seq | 19.7 | 38.7 | 7.53 | 8.87 | 2.16 ± 0.07 | 1.50 ± 0.05 | 0 | 6.32 |
|
|
245
|
+
| | AEC-Seq2seq | 6.90 | 19.8 | 5.04 | 5.72 | 2.90 ± 0.07 | 2.03 ± 0.07 | 230 | 8.62 |
|
|
246
|
+
| | **TEC (proposed)** | **14.8** | **32.5** | **6.46** | **7.71** | **2.39 ± 0.07** | **1.70 ± 0.06** | **0.06** | **6.90** |
|
|
247
|
+
|
|
248
|
+
> **⋆ Note (Table 3 & Section 3.4–3.5 of the paper)**:
|
|
249
|
+
> - The side input size and GFLOPS in the two conditions are different since the average lengths of the echo signal are different in the two conditions (~7 seconds per utterance in LJ Speech vs. ~2 seconds per utterance in VCTK).
|
|
250
|
+
> - In the paper, models were trained on 2×2 TPU slices with a global batch size of 32 using the Adam optimizer ($\beta_1=0.9$, $\beta_2=0.999$, $\epsilon=10^{-6}$) and an initial learning rate of $10^{-4}$ exponentially decaying to $10^{-5}$ after 50,000 iterations.
|
|
251
|
+
|
|
252
|
+
<p align="center">
|
|
253
|
+
<img src="resources/results.png" alt="Table 3: Published Paper Reference Results" width="720" />
|
|
254
|
+
</p>
|
|
255
|
+
|
|
256
|
+
### Open-Source Reproduction Results
|
|
257
|
+
|
|
258
|
+
Using the standalone data preparation (`scripts/prepare_data.py`), training
|
|
259
|
+
(`scripts/train.py`), and evaluation (`scripts/evaluate.py`) pipelines in this
|
|
260
|
+
repository on the open-source **LibriTTS** (`train-clean-100`, `test-clean`,
|
|
261
|
+
`test-other`), **LJSpeech-1.1** (90%/10% split), and **VCTK-0.92** (90%/10%
|
|
262
|
+
per-speaker split across 109 speakers) datasets at 24 kHz (mixed at 0 dB SNR
|
|
263
|
+
with synthetic room impulse responses at RT60 = 0.25 s,
|
|
264
|
+
trained for 60 steps on CPU with `batch_size=4, learning_rate=1e-3`, and
|
|
265
|
+
evaluated with local `Qwen3-ASR-0.6B-F16` via `audio.cpp` on 20 utterances per
|
|
266
|
+
test split):
|
|
267
|
+
|
|
268
|
+
| Condition | Method | WER (%) test-clean ↓ | WER (%) test-other ↓ | MCD (dB) test-clean ↓ | MCD (dB) test-other ↓ | Side Input test-clean (KB) ↓ | Side Input test-other (KB) ↓ |
|
|
269
|
+
| :--- | :--- | :---: | :---: | :---: | :---: | :---: | :---: |
|
|
270
|
+
| **Ground-truth LibriTTS** | `GroundTruth` | 3.52 (7/199) | 6.78 (12/177) | 0.00 | 0.00 | 0.000 | 0.000 |
|
|
271
|
+
| **Single interfering voice** *(LibriTTS + LJSpeech)* | `MicrophoneSignal` | 90.45 (180/199) | 114.12 (202/177) | 12.86 | 14.61 | 0.000 | 0.000 |
|
|
272
|
+
| | `NlmsAec` (AEC-NLMS) | 88.44 (176/199) | 107.34 (190/177) | 12.80 | 14.48 | 243.465 | 209.085 |
|
|
273
|
+
| | `NoSideInputSingleInterfering` (Vanilla-Seq2seq) | 45.23 (90/199) | 91.53 (162/177) | 9.58 | 11.34 | 0.000 | 0.000 |
|
|
274
|
+
| | `AecSingleInterfering` (AEC-Seq2seq) | 12.06 (24/199) | 23.16 (41/177) | 8.85 | 9.86 | 243.465 | 209.085 |
|
|
275
|
+
| | **`TecSingleInterfering` (TEC)** | **21.61 (43/199)** | **46.89 (83/177)** | **8.24** | **9.28** | **0.076** | **0.068** |
|
|
276
|
+
| **Ground-truth LibriTTS (Multi split)** | `GroundTruth` | 5.03 (10/199) | 7.82 (19/243) | 0.00 | 0.00 | 0.000 | 0.000 |
|
|
277
|
+
| **Multiple interfering voices** *(LibriTTS + VCTK)* | `MicrophoneSignal` | 34.17 (68/199) | 48.97 (119/243) | 7.67 | 7.70 | 0.000 | 0.000 |
|
|
278
|
+
| | `NlmsAec` (AEC-NLMS) | 28.64 (57/199) | 34.98 (85/243) | 7.92 | 8.40 | 186.922 | 206.759 |
|
|
279
|
+
| | `NoSideInputMultiInterfering` (Vanilla-Seq2seq) | 31.16 (62/199) | 42.39 (103/243) | 7.93 | 8.72 | 0.000 | 0.000 |
|
|
280
|
+
| | `AecMultiInterfering` (AEC-Seq2seq) | 8.54 (17/199) | 22.22 (54/243) | 7.80 | 7.88 | 186.922 | 206.759 |
|
|
281
|
+
| | **`TecMultiInterfering` (TEC)** | **26.63 (53/199)** | **45.27 (110/243)** | **7.96** | **8.40** | **0.037** | **0.039** |
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
## Running Unit Tests
|
|
286
|
+
|
|
287
|
+
To run the full test suite locally:
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
bash run_tests.sh
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## Citation
|
|
296
|
+
|
|
297
|
+
If you find this library useful in your research, please cite the paper:
|
|
298
|
+
|
|
299
|
+
```bibtex
|
|
300
|
+
@inproceedings{ding2021textual,
|
|
301
|
+
title={Textual Echo Cancellation},
|
|
302
|
+
author={Ding, Shaojin and Jia, Ye and Hu, Ke and Wang, Quan},
|
|
303
|
+
booktitle={2021 IEEE Spoken Language Technology Workshop (SLT)},
|
|
304
|
+
pages={653--660},
|
|
305
|
+
year={2021},
|
|
306
|
+
organization={IEEE}
|
|
307
|
+
}
|
|
308
|
+
```
|