jennyxue commited on
Commit
0544b5c
·
verified ·
1 Parent(s): 05c8659

Model card and the original license

Browse files
Files changed (4) hide show
  1. LICENSE +12 -0
  2. LICENSE-APACHE +201 -0
  3. LICENSE-MIT +19 -0
  4. README.md +446 -0
LICENSE ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## License
2
+
3
+ Licensed under either of
4
+ * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
5
+ * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
6
+ at your option.
7
+
8
+ ### Contribution
9
+
10
+ Unless you explicitly state otherwise, any contribution intentionally submitted
11
+ for inclusion in the work by you, as defined in the Apache-2.0 license, shall
12
+ be dual licensed as above, without any additional terms or conditions.
LICENSE-APACHE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2021 Hendrik Schröter
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
LICENSE-MIT ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+ Copyright (c) 2021 Hendrik Schröter
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
5
+ this software and associated documentation files (the "Software"), to deal in
6
+ the Software without restriction, including without limitation the rights to
7
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8
+ the Software, and to permit persons to whom the Software is furnished to do so,
9
+ subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
README.md ADDED
@@ -0,0 +1,446 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ pipeline_tag: audio-to-audio
4
+ library_name: tensorrt
5
+ tags:
6
+ - tensorrt
7
+ - moonbox
8
+ - deepfilternet
9
+ - speech-enhancement
10
+ - denoising
11
+ - noise-suppression
12
+ - 48khz
13
+ - real-time
14
+ ---
15
+
16
+ # DeepFilterNet3 TensorRT
17
+
18
+ TensorRT engines of [DeepFilterNet3](https://github.com/Rikorose/DeepFilterNet), made by Moonbox for NVIDIA RTX GPUs. Each precision is one folder holding the
19
+ engine, `trt_runner.py` (a small numpy runner: TensorRT plus Polygraphy, no PyTorch) and a script that does the rest
20
+ of the pipeline. What the engine takes and returns is under *How to run*.
21
+
22
+ **Compatibility.** The engines are built *hardware compatible* (Ampere and newer: RTX 30, 40 and 50 series) and
23
+ *version compatible* (any TensorRT 10.x from 10.13 on, through its lean runtime). That costs a little speed against an
24
+ engine built for one GPU, but no rebuild is needed. Install the runtime with
25
+ `pip install "tensorrt-cu12>=10.13,<11" "tensorrt-lean-cu12>=10.13,<11" polygraphy numpy`.
26
+
27
+ ## Files
28
+
29
+ The last column is the benchmark (details under *How to run*).
30
+
31
+ | Precision | File | Size | sha256 | Benchmark |
32
+ |---|---|---|---|---|
33
+ | fp16 | [`fp16/df_dec.engine`](https://huggingface.co/moonbox-dev/DeepFilterNet3-TensorRT/blob/main/fp16/df_dec.engine) | 52.1 MB | `ae36125e7748` | PESQ 3.163, STOI 0.9452, SI-SDR 18.91 dB; vs original 76.9 dB mean / 61.7 worst, worst file -0.008 dB; RTF 0.036 (ONNX fp16 0.041) |
34
+ | fp16 | [`fp16/enc.engine`](https://huggingface.co/moonbox-dev/DeepFilterNet3-TensorRT/blob/main/fp16/enc.engine) | 50.6 MB | `85732e2dbcda` | PESQ 3.163, STOI 0.9452, SI-SDR 18.91 dB; vs original 76.9 dB mean / 61.7 worst, worst file -0.008 dB; RTF 0.036 (ONNX fp16 0.041) |
35
+ | fp16 | [`fp16/erb_dec.engine`](https://huggingface.co/moonbox-dev/DeepFilterNet3-TensorRT/blob/main/fp16/erb_dec.engine) | 52.3 MB | `d32a83bb3c6d` | PESQ 3.163, STOI 0.9452, SI-SDR 18.91 dB; vs original 76.9 dB mean / 61.7 worst, worst file -0.008 dB; RTF 0.036 (ONNX fp16 0.041) |
36
+ | fp16 | [`fp16/trt_runner.py`](https://huggingface.co/moonbox-dev/DeepFilterNet3-TensorRT/blob/main/fp16/trt_runner.py) | 2.2 kB | `efa8ba97631b` | PESQ 3.163, STOI 0.9452, SI-SDR 18.91 dB; vs original 76.9 dB mean / 61.7 worst, worst file -0.008 dB; RTF 0.036 (ONNX fp16 0.041) |
37
+
38
+ ## How to run
39
+
40
+ DeepFilterNet3 (real-time speech enhancement at 48 kHz: ERB-band gains plus deep filtering of the low band) as
41
+ TensorRT engines of its three networks: `enc.engine` (encoder), `erb_dec.engine` (ERB-gain decoder) and
42
+ `df_dec.engine` (deep-filter decoder). They are built from Moonbox's fp16 ONNX graphs of the official export.
43
+ - **Inputs and outputs:** the same names and shapes as the official graphs.
44
+ - **Time axis:** 1 to 3,000 frames (30 s at the model's 10 ms hop), so a whole file runs in one call.
45
+
46
+ The engines are the neural network only. The STFT, the ERB and complex features, applying the gains and the deep
47
+ filter, and the ISTFT go around them. The official `deepfilternet` package, with its three networks swapped for these
48
+ engines, does all of that exactly as the original (and is how this repository was benchmarked):
49
+
50
+ ```python
51
+ import sys, numpy as np, soundfile as sf, torch
52
+ from df.enhance import enhance, init_df # pip install deepfilternet==0.5.6 (torch / torchaudio 2.1)
53
+ sys.path.insert(0, "fp16")
54
+ from trt_runner import Engine
55
+
56
+ model, df_state, _ = init_df() # the official DeepFilterNet3 checkpoint
57
+ IO = {"enc": (["feat_erb", "feat_spec"], ["e0", "e1", "e2", "e3", "emb", "c0", "lsnr"]),
58
+ "erb_dec": (["emb", "e3", "e2", "e1", "e0"], ["m"]), "df_dec": (["emb", "c0"], ["coefs"])}
59
+
60
+ class Net(torch.nn.Module):
61
+ def __init__(self, name, first_only):
62
+ super().__init__()
63
+ self.e, (self.ins, self.outs), self.first_only = Engine(f"fp16/{name}.engine"), IO[name], first_only
64
+ def forward(self, *xs):
65
+ o = self.e({n: x.numpy().astype(np.float32) for n, x in zip(self.ins, xs)})
66
+ out = [torch.from_numpy(o[n].astype(np.float32)) for n in self.outs]
67
+ return out[0] if self.first_only else tuple(out)
68
+
69
+ model.enc, model.erb_dec, model.df_dec = Net("enc", False), Net("erb_dec", True), Net("df_dec", True)
70
+ noisy, sr = sf.read("noisy_48k.wav", dtype="float32") # 48 kHz mono
71
+ with torch.no_grad():
72
+ clean = enhance(model, df_state, torch.from_numpy(noisy)[None]).squeeze(0).numpy()
73
+ sf.write("enhanced.wav", clean, 48000)
74
+ ```
75
+
76
+ **Precisions.** `fp16/`, built from the fp16 ONNX graphs:
77
+ - `erb_dec`: strongly typed, so every tensor keeps the ONNX graph's precision.
78
+ - `enc` and `df_dec`: weakly typed, so TensorRT chooses each layer's precision. Strongly typed, TensorRT 10.13 has no
79
+ fp16 kernel for their padded grouped convolutions.
80
+
81
+ No int8: TensorRT's int8 needs calibrated activations, and the ONNX int8 build is weight-only.
82
+
83
+ **Benchmark.**
84
+ - **Data:** the VoiceBank-DEMAND test set (824 utterances by two unseen speakers, 48 kHz), through the official
85
+ `deepfilternet` 0.5.6 pipeline, on an RTX 3080 Laptop GPU.
86
+ - **Scores:** PESQ wide-band (at 16 kHz), STOI, and SI-SDR against the clean speech.
87
+ - **Agreement:** the SI-SDR of each output against the PyTorch original's (fp32, CPU).
88
+ - **Pass mark:** no file's SI-SDR more than 0.5 dB below the original's.
89
+
90
+ | | PESQ | STOI | SI-SDR (dB) | vs original: mean / worst file (dB) | worst-file SI-SDR change | real-time factor |
91
+ |---|---|---|---|---|---|---|
92
+ | original (PyTorch fp32, CPU) | 3.163 | 0.9452 | 18.91 | - | - | 0.034 |
93
+ | ONNX `fp16/` (CUDA) | 3.163 | 0.9452 | 18.91 | 65.2 / 55.2 | -0.024 | 0.041 |
94
+ | TensorRT `fp16/` | 3.163 | 0.9452 | 18.91 | 76.9 / 61.7 | -0.008 | 0.036 |
95
+
96
+ The real-time factor is for the whole pipeline. Most of DeepFilterNet3's time goes to libDF's feature code on the CPU,
97
+ so the GPU builds save little here.
98
+
99
+ ## How these were made
100
+
101
+ From [DeepFilterNet3](https://github.com/Rikorose/DeepFilterNet) at revision `7b14b895fe`: each engine was built with TensorRT's builder from Moonbox's published
102
+ ONNX graph of the same model and precision. The network is *strongly typed*: every tensor keeps the precision the
103
+ ONNX graph gives it, so an fp16 engine computes what the fp16 ONNX build computes. Built on an RTX 3080 Laptop GPU,
104
+ it was benchmarked against the original before upload, and the `sha256` column above is what the files must hash to.
105
+
106
+ ## License
107
+
108
+ MIT/Apache-2.0. These files are a derivative of the original model and carry its license: it is copied in this
109
+ repository, and it governs your use of these files. The original model card follows unchanged.
110
+
111
+ ---
112
+
113
+ # Original model card
114
+
115
+ # DeepFilterNet
116
+ A Low Complexity Speech Enhancement Framework for Full-Band Audio (48kHz) using on Deep Filtering.
117
+
118
+ ![deepfilternet3](https://user-images.githubusercontent.com/16517898/225623209-a54fea75-ca00-404c-a394-c91d2d1146d2.svg)
119
+
120
+ For PipeWire integration as a virtual noise suppression microphone look [here](https://github.com/Rikorose/DeepFilterNet/blob/main/ladspa/README.md).
121
+
122
+ ### Demo
123
+
124
+ https://github.com/Rikorose/DeepFilterNet/assets/16517898/79679fd7-de73-4c22-948c-891927c7d2ca
125
+
126
+ To run the demo (linux only) use:
127
+ ```bash
128
+ cargo +nightly run -p df-demo --features ui --bin df-demo --release
129
+ ```
130
+
131
+ ### News
132
+
133
+ - New DeepFilterNet Demo: *DeepFilterNet: Perceptually Motivated Real-Time Speech Enhancement*
134
+ - Paper: https://arxiv.org/abs/2305.08227
135
+ - Video: https://youtu.be/EO7n96YwnyE
136
+
137
+ - New Multi-Frame Filtering Paper: *Deep Multi-Frame Filtering for Hearing Aids*
138
+ - Paper: https://arxiv.org/abs/2305.08225
139
+
140
+ - Real-time version and a LADSPA plugin
141
+ - [Pre-compiled binary](#deep-filter), no python dependencies. Usage: `deep-filter audio-file.wav`
142
+ - [LADSPA plugin](https://raw.githubusercontent.com/Rikorose/DeepFilterNet/7b14b895fe7fc42cab72b4a4c1e49c982bd6404b/ladspa/) with pipewire filter-chain integration for real-time noise reduction on your mic.
143
+
144
+ - DeepFilterNet2 Paper: *DeepFilterNet2: Towards Real-Time Speech Enhancement on Embedded Devices for Full-Band Audio*
145
+ - Paper: https://arxiv.org/abs/2205.05474
146
+ - Samples: https://rikorose.github.io/DeepFilterNet2-Samples/
147
+ - Demo: https://huggingface.co/spaces/hshr/DeepFilterNet2
148
+
149
+ - Original DeepFilterNet Paper: *DeepFilterNet: A Low Complexity Speech Enhancement Framework for Full-Band Audio based on Deep Filtering*
150
+ - Paper: https://arxiv.org/abs/2110.05588
151
+ - Samples: https://rikorose.github.io/DeepFilterNet-Samples/
152
+ - Demo: https://huggingface.co/spaces/hshr/DeepFilterNet
153
+ - Video Lecture: https://youtu.be/it90gBqkY6k
154
+
155
+ ## Usage
156
+
157
+ ### deep-filter
158
+
159
+ Download a pre-compiled deep-filter binary from the [release page](https://github.com/Rikorose/DeepFilterNet/releases/).
160
+ You can use `deep-filter` to suppress noise in noisy .wav audio files. Currently, only wav files with a sampling rate of 48kHz are supported.
161
+
162
+ ```bash
163
+ USAGE:
164
+ deep-filter [OPTIONS] [FILES]...
165
+
166
+ ARGS:
167
+ <FILES>...
168
+
169
+ OPTIONS:
170
+ -D, --compensate-delay
171
+ Compensate delay of STFT and model lookahead
172
+ -h, --help
173
+ Print help information
174
+ -m, --model <MODEL>
175
+ Path to model tar.gz. Defaults to DeepFilterNet2.
176
+ -o, --out-dir <OUT_DIR>
177
+ [default: out]
178
+ --pf
179
+ Enable postfilter
180
+ -v, --verbose
181
+ Logging verbosity
182
+ -V, --version
183
+ Print version information
184
+ ```
185
+
186
+ If you want to use the pytorch backend e.g. for GPU processing, see further below for the Python usage.
187
+
188
+ ### DeepFilterNet Framework
189
+
190
+ This framework supports Linux, MacOS and Windows. Training is only tested under Linux. The framework is structured as follows:
191
+
192
+ * `libDF` contains Rust code used for data loading and augmentation.
193
+ * `DeepFilterNet` contains DeepFilterNet code training, evaluation and visualization as well as pretrained model weights.
194
+ * `pyDF` contains a Python wrapper of libDF STFT/ISTFT processing loop.
195
+ * `pyDF-data` contains a Python wrapper of libDF dataset functionality and provides a pytorch data loader.
196
+ * `ladspa` contains a LADSPA plugin for real-time noise suppression.
197
+ * `models` contains pretrained for usage in DeepFilterNet (Python) or libDF/deep-filter (Rust)
198
+
199
+ ### DeepFilterNet Python: PyPI
200
+
201
+ Install the DeepFilterNet Python wheel via pip:
202
+ ```bash
203
+ # Install cpu/cuda pytorch (>=1.9) dependency from pytorch.org, e.g.:
204
+ pip install torch torchaudio -f https://download.pytorch.org/whl/cpu/torch_stable.html
205
+ # Install DeepFilterNet
206
+ pip install deepfilternet
207
+ # Or install DeepFilterNet including data loading functionality for training (Linux only)
208
+ pip install deepfilternet[train]
209
+ ```
210
+
211
+ To enhance noisy audio files using DeepFilterNet run
212
+ ```bash
213
+ # Specify an output directory with --output-dir [OUTPUT_DIR]
214
+ deepFilter path/to/noisy_audio.wav
215
+ ```
216
+
217
+ ### Manual Installation
218
+
219
+ Install cargo via [rustup](https://rustup.rs/). Usage of a `conda` or `virtualenv` recommended.
220
+ Please read the comments and only execute the commands that you need.
221
+
222
+ Installation of python dependencies and libDF:
223
+ ```bash
224
+ cd path/to/DeepFilterNet/ # cd into repository
225
+ # Recommended: Install or activate a python env
226
+ # Mandatory: Install cpu/cuda pytorch (>=1.8) dependency from pytorch.org, e.g.:
227
+ pip install torch torchaudio -f https://download.pytorch.org/whl/cpu/torch_stable.html
228
+ # Install build dependencies used to compile libdf and DeepFilterNet python wheels
229
+ pip install maturin poetry
230
+
231
+ # Install remaining DeepFilterNet python dependencies
232
+ # *Option A:* Install DeepFilterNet python wheel globally within your environment. Do this if you want use
233
+ # this repos as is, and don't want to develop within this repository.
234
+ poetry -C DeepFilterNet install -E train -E eval
235
+ # *Option B:* If you want to develop within this repo, install only dependencies and work with the repository version
236
+ poetry -C DeepFilterNet install -E train -E eval --no-root
237
+ export PYTHONPATH=$PWD/DeepFilterNet # And set the python path correctly
238
+
239
+ # Build and install libdf python package required for enhance.py
240
+ maturin develop --release -m pyDF/Cargo.toml
241
+ # *Optional*: Install libdfdata python package with dataset and dataloading functionality for training
242
+ # Required build dependency: HDF5 headers (e.g. ubuntu: libhdf5-dev)
243
+ maturin develop --release -m pyDF-data/Cargo.toml
244
+ # If you have troubles with hdf5 you may try to build and link hdf5 statically:
245
+ maturin develop --release --features hdf5-static -m pyDF-data/Cargo.toml
246
+ ```
247
+
248
+ ### Use DeepFilterNet from command line
249
+
250
+ To enhance noisy audio files using DeepFilterNet run
251
+ ```bash
252
+ $ python DeepFilterNet/df/enhance.py --help
253
+ usage: enhance.py [-h] [--model-base-dir MODEL_BASE_DIR] [--pf] [--output-dir OUTPUT_DIR] [--log-level LOG_LEVEL] [--compensate-delay]
254
+ noisy_audio_files [noisy_audio_files ...]
255
+
256
+ positional arguments:
257
+ noisy_audio_files List of noise files to mix with the clean speech file.
258
+
259
+ optional arguments:
260
+ -h, --help show this help message and exit
261
+ --model-base-dir MODEL_BASE_DIR, -m MODEL_BASE_DIR
262
+ Model directory containing checkpoints and config.
263
+ To load a pretrained model, you may just provide the model name, e.g. `DeepFilterNet`.
264
+ By default, the pretrained DeepFilterNet2 model is loaded.
265
+ --pf Post-filter that slightly over-attenuates very noisy sections.
266
+ --output-dir OUTPUT_DIR, -o OUTPUT_DIR
267
+ Directory in which the enhanced audio files will be stored.
268
+ --log-level LOG_LEVEL
269
+ Logger verbosity. Can be one of (debug, info, error, none)
270
+ --compensate-delay, -D
271
+ Add some paddig to compensate the delay introduced by the real-time STFT/ISTFT implementation.
272
+
273
+ # Enhance audio with original DeepFilterNet
274
+ python DeepFilterNet/df/enhance.py -m DeepFilterNet path/to/noisy_audio.wav
275
+
276
+ # Enhance audio with DeepFilterNet2
277
+ python DeepFilterNet/df/enhance.py -m DeepFilterNet2 path/to/noisy_audio.wav
278
+ ```
279
+
280
+ ### Use DeepFilterNet within your Python script
281
+
282
+ ```py
283
+ from df import enhance, init_df
284
+
285
+ model, df_state, _ = init_df() # Load default model
286
+ enhanced_audio = enhance(model, df_state, noisy_audio)
287
+ ```
288
+
289
+ See [here](https://github.com/Rikorose/DeepFilterNet/blob/main/scripts/external_usage.py) for a full example.
290
+
291
+ ### Training
292
+
293
+ The entry point is `DeepFilterNet/df/train.py`. It expects a data directory containing HDF5 dataset
294
+ as well as a dataset configuration json file.
295
+
296
+ So, you first need to create your datasets in HDF5 format. Each dataset typically only
297
+ holds training, validation, or test set of noise, speech or RIRs.
298
+ ```py
299
+ # Install additional dependencies for dataset creation
300
+ pip install h5py librosa soundfile
301
+ # Go to DeepFilterNet python package
302
+ cd path/to/DeepFilterNet/DeepFilterNet
303
+ # Prepare text file (e.g. called training_set.txt) containing paths to .wav files
304
+ #
305
+ # usage: prepare_data.py [-h] [--num_workers NUM_WORKERS] [--max_freq MAX_FREQ] [--sr SR] [--dtype DTYPE]
306
+ # [--codec CODEC] [--mono] [--compression COMPRESSION]
307
+ # type audio_files hdf5_db
308
+ #
309
+ # where:
310
+ # type: One of `speech`, `noise`, `rir`
311
+ # audio_files: Text file containing paths to audio files to include in the dataset
312
+ # hdf5_db: Output HDF5 dataset.
313
+ python df/scripts/prepare_data.py --sr 48000 speech training_set.txt TRAIN_SET_SPEECH.hdf5
314
+ ```
315
+ All datasets should be made available in one dataset folder for the train script.
316
+
317
+ The dataset configuration file should contain 3 entries: "train", "valid", "test". Each of those
318
+ contains a list of datasets (e.g. a speech, noise and a RIR dataset). You can use multiple speech
319
+ or noise dataset. Optionally, a sampling factor may be specified that can be used to over/under-sample
320
+ the dataset. Say, you have a specific dataset with transient noises and want to increase the amount
321
+ of non-stationary noises by oversampling. In most cases you want to set this factor to 1.
322
+
323
+ <details>
324
+ <summary>Dataset config example:</summary>
325
+ <p>
326
+
327
+ `dataset.cfg`
328
+
329
+ ```json
330
+ {
331
+ "train": [
332
+ [
333
+ "TRAIN_SET_SPEECH.hdf5",
334
+ 1.0
335
+ ],
336
+ [
337
+ "TRAIN_SET_NOISE.hdf5",
338
+ 1.0
339
+ ],
340
+ [
341
+ "TRAIN_SET_RIR.hdf5",
342
+ 1.0
343
+ ]
344
+ ],
345
+ "valid": [
346
+ [
347
+ "VALID_SET_SPEECH.hdf5",
348
+ 1.0
349
+ ],
350
+ [
351
+ "VALID_SET_NOISE.hdf5",
352
+ 1.0
353
+ ],
354
+ [
355
+ "VALID_SET_RIR.hdf5",
356
+ 1.0
357
+ ]
358
+ ],
359
+ "test": [
360
+ [
361
+ "TEST_SET_SPEECH.hdf5",
362
+ 1.0
363
+ ],
364
+ [
365
+ "TEST_SET_NOISE.hdf5",
366
+ 1.0
367
+ ],
368
+ [
369
+ "TEST_SET_RIR.hdf5",
370
+ 1.0
371
+ ]
372
+ ]
373
+ }
374
+ ```
375
+
376
+ </p>
377
+ </details>
378
+
379
+ Finally, start the training script. The training script may create a model `base_dir` if not
380
+ existing used for logging, some audio samples, model checkpoints, and config. If no config file is
381
+ found, it will create a default config. See
382
+ [DeepFilterNet/pretrained_models/DeepFilterNet](https://github.com/Rikorose/DeepFilterNet/blob/main/DeepFilterNet/pretrained_models/DeepFilterNet/config.ini)
383
+ for a config file.
384
+ ```py
385
+ # usage: train.py [-h] [--debug] data_config_file data_dir base_dir
386
+ python df/train.py path/to/dataset.cfg path/to/data_dir/ path/to/base_dir/
387
+ ```
388
+
389
+ ## Citation Guide
390
+
391
+ To reproduce any metrics, we recomend to use the python implementation via `pip install deepfilternet`.
392
+
393
+ If you use this framework, please cite: *DeepFilterNet: A Low Complexity Speech Enhancement Framework for Full-Band Audio based on Deep Filtering*
394
+ ```bibtex
395
+ @inproceedings{schroeter2022deepfilternet,
396
+ title={{DeepFilterNet}: A Low Complexity Speech Enhancement Framework for Full-Band Audio based on Deep Filtering},
397
+ author = {Schröter, Hendrik and Escalante-B., Alberto N. and Rosenkranz, Tobias and Maier, Andreas},
398
+ booktitle={ICASSP 2022 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)},
399
+ year={2022},
400
+ organization={IEEE}
401
+ }
402
+ ```
403
+
404
+ If you use the DeepFilterNet2 model, please cite: *DeepFilterNet2: Towards Real-Time Speech Enhancement on Embedded Devices for Full-Band Audio*
405
+
406
+ ```bibtex
407
+ @inproceedings{schroeter2022deepfilternet2,
408
+ title = {{DeepFilterNet2}: Towards Real-Time Speech Enhancement on Embedded Devices for Full-Band Audio},
409
+ author = {Schröter, Hendrik and Escalante-B., Alberto N. and Rosenkranz, Tobias and Maier, Andreas},
410
+ booktitle={17th International Workshop on Acoustic Signal Enhancement (IWAENC 2022)},
411
+ year = {2022},
412
+ }
413
+ ```
414
+
415
+ If you use the DeepFilterNet3 model, please cite: *DeepFilterNet: Perceptually Motivated Real-Time Speech Enhancement*
416
+
417
+ ```bibtex
418
+ @inproceedings{schroeter2023deepfilternet3,
419
+ title = {{DeepFilterNet}: Perceptually Motivated Real-Time Speech Enhancement},
420
+ author = {Schröter, Hendrik and Rosenkranz, Tobias and Escalante-B., Alberto N. and Maier, Andreas},
421
+ booktitle={INTERSPEECH},
422
+ year = {2023},
423
+ }
424
+ ```
425
+
426
+ If you use the multi-frame beamforming algorithms. please cite *Deep Multi-Frame Filtering for Hearing Aids*
427
+
428
+ ```bibtex
429
+ @inproceedings{schroeter2023deep_mf,
430
+ title = {Deep Multi-Frame Filtering for Hearing Aids},
431
+ author = {Schröter, Hendrik and Rosenkranz, Tobias and Escalante-B., Alberto N. and Maier, Andreas},
432
+ booktitle={INTERSPEECH},
433
+ year = {2023},
434
+ }
435
+ ```
436
+
437
+ ## License
438
+
439
+ DeepFilterNet is free and open source! All code and model weights in this repository are dual-licensed under either:
440
+
441
+ * MIT License ([LICENSE-MIT](https://raw.githubusercontent.com/Rikorose/DeepFilterNet/7b14b895fe7fc42cab72b4a4c1e49c982bd6404b/LICENSE-MIT) or [http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT))
442
+ * Apache License, Version 2.0 ([LICENSE-APACHE](https://raw.githubusercontent.com/Rikorose/DeepFilterNet/7b14b895fe7fc42cab72b4a4c1e49c982bd6404b/LICENSE-APACHE) or [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0))
443
+
444
+ at your option. This means you can select the license you prefer!
445
+
446
+ Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.