jennyxue commited on
Commit
12f47a5
·
verified ·
1 Parent(s): 3052937

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 +410 -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,410 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ pipeline_tag: audio-to-audio
4
+ library_name: mlx-audio
5
+ tags:
6
+ - mlx
7
+ - moonbox
8
+ - mlx-audio
9
+ - deepfilternet
10
+ - speech-enhancement
11
+ - denoising
12
+ - 48khz
13
+ ---
14
+
15
+ # DeepFilterNet3 MLX
16
+
17
+ MLX builds of [DeepFilterNet3](https://github.com/Rikorose/DeepFilterNet), made by Moonbox for Apple Silicon Macs. Each precision is a folder; keep a folder's
18
+ files together. Only the parts listed below are converted: the rest of the pipeline comes from the original
19
+ repository unless the section below says otherwise.
20
+
21
+ ## Files
22
+
23
+ The last column is how far each build is from the original PyTorch model on the same inputs (see the section below
24
+ for what was measured).
25
+
26
+ | Precision | File | Size | sha256 | Checked against the original |
27
+ |---|---|---|---|---|
28
+ | bf16 | [`bf16/config.json`](https://huggingface.co/moonbox-dev/DeepFilterNet3-MLX/blob/main/bf16/config.json) | 0.9 kB | `cc96fe1bf688` | below threshold (experimental): SI-SDR 8.58 dB, 0.66 dB below the original on one clip; DNSMOS 2.93; output vs the original's 25.2 / 16.3 dB |
29
+ | bf16 | [`bf16/model.safetensors`](https://huggingface.co/moonbox-dev/DeepFilterNet3-MLX/blob/main/bf16/model.safetensors) | 4.3 MB | `ad9d67c69a00` | below threshold (experimental): SI-SDR 8.58 dB, 0.66 dB below the original on one clip; DNSMOS 2.93; output vs the original's 25.2 / 16.3 dB |
30
+
31
+ ## How to run
32
+
33
+ DeepFilterNet3 (real-time speech enhancement at 48 kHz: ERB-band gains plus deep filtering of the low band) for
34
+ [mlx-audio](https://github.com/Blaizzy/mlx-audio). Each folder holds `model.safetensors` (the official checkpoint's
35
+ state dict, PyTorch names, cast to the precision) and `config.json` (the model's `config.ini` as mlx-audio reads it).
36
+ Tested with `mlx-audio==0.6.5`:
37
+
38
+ ```python
39
+ from mlx_audio.sts.models.deepfilternet import DeepFilterNetModel
40
+ import soundfile as sf
41
+
42
+ model = DeepFilterNetModel.from_pretrained("fp16", subfolder=None) # a downloaded folder
43
+ model.enhance_file("noisy.wav", "clean.wav") # 48 kHz in and out
44
+ ```
45
+
46
+ Only `bf16/` and `fp16/`: the network has 2.2 M parameters, and mlx-audio's DeepFilterNet loader maps the PyTorch
47
+ weights by name and takes no quantized tensors.
48
+
49
+ **How they were checked.** 8 noisy 48 kHz clips (LibriSpeech speech with babble or pink noise, 0-10 dB SNR),
50
+ enhanced by the original (the official `deepfilternet` 0.5.6 package: PyTorch, float32, libDF's STFT and features)
51
+ and by every MLX build: SI-SDR against the clean speech, DNSMOS P.835, and how close each output is to the
52
+ original's. Pass: SI-SDR on every clip at most 0.5 dB below the original's, mean DNSMOS at most 0.1 below.
53
+ mlx-audio's DeepFilterNet3 is a reimplementation: even in float32 its output is 25 dB from the original's (17.7 dB on
54
+ the worst clip), with the same enhancement quality on these measures.
55
+
56
+ | Precision | Size | SI-SDR (dB) | DNSMOS | Output vs the original's, mean / worst clip (dB) | Real-time factor, M5 24 GB |
57
+ |---|---|---|---|---|---|
58
+ | noisy input | - | 4.99 | 2.10 | - | - |
59
+ | original (PyTorch fp32, CPU) | - | 8.71 | 2.95 | - | 0.018 |
60
+ | `fp16/` | 4.3 MB | 8.62 | 2.92 | 25.3 / 17.7 | 0.022 |
61
+ | `bf16/` (experimental) | 4.3 MB | 8.58 (0.66 below the original on one clip) | 2.93 | 25.2 / 16.3 | 0.022 |
62
+
63
+ ## How these were made
64
+
65
+ From [DeepFilterNet3](https://github.com/Rikorose/DeepFilterNet) at revision `7b14b895fe`: the original weights loaded in MLX and stored as bf16 or fp16, or
66
+ quantized with MLX's affine quantization (`8bit`, `6bit`, `4bit`, group size 64; layers MLX can't quantize, such as
67
+ convolutions and norms, stay bf16). Every build was checked against the original before upload; the `sha256` column
68
+ above is what the files must hash to.
69
+
70
+ ## License
71
+
72
+ MIT/Apache-2.0. These files are a derivative of the original model and carry its license: it is copied in this
73
+ repository, and it governs your use of these files. The original model card follows unchanged.
74
+
75
+ ---
76
+
77
+ # Original model card
78
+
79
+ # DeepFilterNet
80
+ A Low Complexity Speech Enhancement Framework for Full-Band Audio (48kHz) using on Deep Filtering.
81
+
82
+ ![deepfilternet3](https://user-images.githubusercontent.com/16517898/225623209-a54fea75-ca00-404c-a394-c91d2d1146d2.svg)
83
+
84
+ For PipeWire integration as a virtual noise suppression microphone look [here](https://github.com/Rikorose/DeepFilterNet/blob/main/ladspa/README.md).
85
+
86
+ ### Demo
87
+
88
+ https://github.com/Rikorose/DeepFilterNet/assets/16517898/79679fd7-de73-4c22-948c-891927c7d2ca
89
+
90
+ To run the demo (linux only) use:
91
+ ```bash
92
+ cargo +nightly run -p df-demo --features ui --bin df-demo --release
93
+ ```
94
+
95
+ ### News
96
+
97
+ - New DeepFilterNet Demo: *DeepFilterNet: Perceptually Motivated Real-Time Speech Enhancement*
98
+ - Paper: https://arxiv.org/abs/2305.08227
99
+ - Video: https://youtu.be/EO7n96YwnyE
100
+
101
+ - New Multi-Frame Filtering Paper: *Deep Multi-Frame Filtering for Hearing Aids*
102
+ - Paper: https://arxiv.org/abs/2305.08225
103
+
104
+ - Real-time version and a LADSPA plugin
105
+ - [Pre-compiled binary](#deep-filter), no python dependencies. Usage: `deep-filter audio-file.wav`
106
+ - [LADSPA plugin](ladspa/) with pipewire filter-chain integration for real-time noise reduction on your mic.
107
+
108
+ - DeepFilterNet2 Paper: *DeepFilterNet2: Towards Real-Time Speech Enhancement on Embedded Devices for Full-Band Audio*
109
+ - Paper: https://arxiv.org/abs/2205.05474
110
+ - Samples: https://rikorose.github.io/DeepFilterNet2-Samples/
111
+ - Demo: https://huggingface.co/spaces/hshr/DeepFilterNet2
112
+
113
+ - Original DeepFilterNet Paper: *DeepFilterNet: A Low Complexity Speech Enhancement Framework for Full-Band Audio based on Deep Filtering*
114
+ - Paper: https://arxiv.org/abs/2110.05588
115
+ - Samples: https://rikorose.github.io/DeepFilterNet-Samples/
116
+ - Demo: https://huggingface.co/spaces/hshr/DeepFilterNet
117
+ - Video Lecture: https://youtu.be/it90gBqkY6k
118
+
119
+ ## Usage
120
+
121
+ ### deep-filter
122
+
123
+ Download a pre-compiled deep-filter binary from the [release page](https://github.com/Rikorose/DeepFilterNet/releases/).
124
+ 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.
125
+
126
+ ```bash
127
+ USAGE:
128
+ deep-filter [OPTIONS] [FILES]...
129
+
130
+ ARGS:
131
+ <FILES>...
132
+
133
+ OPTIONS:
134
+ -D, --compensate-delay
135
+ Compensate delay of STFT and model lookahead
136
+ -h, --help
137
+ Print help information
138
+ -m, --model <MODEL>
139
+ Path to model tar.gz. Defaults to DeepFilterNet2.
140
+ -o, --out-dir <OUT_DIR>
141
+ [default: out]
142
+ --pf
143
+ Enable postfilter
144
+ -v, --verbose
145
+ Logging verbosity
146
+ -V, --version
147
+ Print version information
148
+ ```
149
+
150
+ If you want to use the pytorch backend e.g. for GPU processing, see further below for the Python usage.
151
+
152
+ ### DeepFilterNet Framework
153
+
154
+ This framework supports Linux, MacOS and Windows. Training is only tested under Linux. The framework is structured as follows:
155
+
156
+ * `libDF` contains Rust code used for data loading and augmentation.
157
+ * `DeepFilterNet` contains DeepFilterNet code training, evaluation and visualization as well as pretrained model weights.
158
+ * `pyDF` contains a Python wrapper of libDF STFT/ISTFT processing loop.
159
+ * `pyDF-data` contains a Python wrapper of libDF dataset functionality and provides a pytorch data loader.
160
+ * `ladspa` contains a LADSPA plugin for real-time noise suppression.
161
+ * `models` contains pretrained for usage in DeepFilterNet (Python) or libDF/deep-filter (Rust)
162
+
163
+ ### DeepFilterNet Python: PyPI
164
+
165
+ Install the DeepFilterNet Python wheel via pip:
166
+ ```bash
167
+ # Install cpu/cuda pytorch (>=1.9) dependency from pytorch.org, e.g.:
168
+ pip install torch torchaudio -f https://download.pytorch.org/whl/cpu/torch_stable.html
169
+ # Install DeepFilterNet
170
+ pip install deepfilternet
171
+ # Or install DeepFilterNet including data loading functionality for training (Linux only)
172
+ pip install deepfilternet[train]
173
+ ```
174
+
175
+ To enhance noisy audio files using DeepFilterNet run
176
+ ```bash
177
+ # Specify an output directory with --output-dir [OUTPUT_DIR]
178
+ deepFilter path/to/noisy_audio.wav
179
+ ```
180
+
181
+ ### Manual Installation
182
+
183
+ Install cargo via [rustup](https://rustup.rs/). Usage of a `conda` or `virtualenv` recommended.
184
+ Please read the comments and only execute the commands that you need.
185
+
186
+ Installation of python dependencies and libDF:
187
+ ```bash
188
+ cd path/to/DeepFilterNet/ # cd into repository
189
+ # Recommended: Install or activate a python env
190
+ # Mandatory: Install cpu/cuda pytorch (>=1.8) dependency from pytorch.org, e.g.:
191
+ pip install torch torchaudio -f https://download.pytorch.org/whl/cpu/torch_stable.html
192
+ # Install build dependencies used to compile libdf and DeepFilterNet python wheels
193
+ pip install maturin poetry
194
+
195
+ # Install remaining DeepFilterNet python dependencies
196
+ # *Option A:* Install DeepFilterNet python wheel globally within your environment. Do this if you want use
197
+ # this repos as is, and don't want to develop within this repository.
198
+ poetry -C DeepFilterNet install -E train -E eval
199
+ # *Option B:* If you want to develop within this repo, install only dependencies and work with the repository version
200
+ poetry -C DeepFilterNet install -E train -E eval --no-root
201
+ export PYTHONPATH=$PWD/DeepFilterNet # And set the python path correctly
202
+
203
+ # Build and install libdf python package required for enhance.py
204
+ maturin develop --release -m pyDF/Cargo.toml
205
+ # *Optional*: Install libdfdata python package with dataset and dataloading functionality for training
206
+ # Required build dependency: HDF5 headers (e.g. ubuntu: libhdf5-dev)
207
+ maturin develop --release -m pyDF-data/Cargo.toml
208
+ # If you have troubles with hdf5 you may try to build and link hdf5 statically:
209
+ maturin develop --release --features hdf5-static -m pyDF-data/Cargo.toml
210
+ ```
211
+
212
+ ### Use DeepFilterNet from command line
213
+
214
+ To enhance noisy audio files using DeepFilterNet run
215
+ ```bash
216
+ $ python DeepFilterNet/df/enhance.py --help
217
+ usage: enhance.py [-h] [--model-base-dir MODEL_BASE_DIR] [--pf] [--output-dir OUTPUT_DIR] [--log-level LOG_LEVEL] [--compensate-delay]
218
+ noisy_audio_files [noisy_audio_files ...]
219
+
220
+ positional arguments:
221
+ noisy_audio_files List of noise files to mix with the clean speech file.
222
+
223
+ optional arguments:
224
+ -h, --help show this help message and exit
225
+ --model-base-dir MODEL_BASE_DIR, -m MODEL_BASE_DIR
226
+ Model directory containing checkpoints and config.
227
+ To load a pretrained model, you may just provide the model name, e.g. `DeepFilterNet`.
228
+ By default, the pretrained DeepFilterNet2 model is loaded.
229
+ --pf Post-filter that slightly over-attenuates very noisy sections.
230
+ --output-dir OUTPUT_DIR, -o OUTPUT_DIR
231
+ Directory in which the enhanced audio files will be stored.
232
+ --log-level LOG_LEVEL
233
+ Logger verbosity. Can be one of (debug, info, error, none)
234
+ --compensate-delay, -D
235
+ Add some paddig to compensate the delay introduced by the real-time STFT/ISTFT implementation.
236
+
237
+ # Enhance audio with original DeepFilterNet
238
+ python DeepFilterNet/df/enhance.py -m DeepFilterNet path/to/noisy_audio.wav
239
+
240
+ # Enhance audio with DeepFilterNet2
241
+ python DeepFilterNet/df/enhance.py -m DeepFilterNet2 path/to/noisy_audio.wav
242
+ ```
243
+
244
+ ### Use DeepFilterNet within your Python script
245
+
246
+ ```py
247
+ from df import enhance, init_df
248
+
249
+ model, df_state, _ = init_df() # Load default model
250
+ enhanced_audio = enhance(model, df_state, noisy_audio)
251
+ ```
252
+
253
+ See [here](https://github.com/Rikorose/DeepFilterNet/blob/main/scripts/external_usage.py) for a full example.
254
+
255
+ ### Training
256
+
257
+ The entry point is `DeepFilterNet/df/train.py`. It expects a data directory containing HDF5 dataset
258
+ as well as a dataset configuration json file.
259
+
260
+ So, you first need to create your datasets in HDF5 format. Each dataset typically only
261
+ holds training, validation, or test set of noise, speech or RIRs.
262
+ ```py
263
+ # Install additional dependencies for dataset creation
264
+ pip install h5py librosa soundfile
265
+ # Go to DeepFilterNet python package
266
+ cd path/to/DeepFilterNet/DeepFilterNet
267
+ # Prepare text file (e.g. called training_set.txt) containing paths to .wav files
268
+ #
269
+ # usage: prepare_data.py [-h] [--num_workers NUM_WORKERS] [--max_freq MAX_FREQ] [--sr SR] [--dtype DTYPE]
270
+ # [--codec CODEC] [--mono] [--compression COMPRESSION]
271
+ # type audio_files hdf5_db
272
+ #
273
+ # where:
274
+ # type: One of `speech`, `noise`, `rir`
275
+ # audio_files: Text file containing paths to audio files to include in the dataset
276
+ # hdf5_db: Output HDF5 dataset.
277
+ python df/scripts/prepare_data.py --sr 48000 speech training_set.txt TRAIN_SET_SPEECH.hdf5
278
+ ```
279
+ All datasets should be made available in one dataset folder for the train script.
280
+
281
+ The dataset configuration file should contain 3 entries: "train", "valid", "test". Each of those
282
+ contains a list of datasets (e.g. a speech, noise and a RIR dataset). You can use multiple speech
283
+ or noise dataset. Optionally, a sampling factor may be specified that can be used to over/under-sample
284
+ the dataset. Say, you have a specific dataset with transient noises and want to increase the amount
285
+ of non-stationary noises by oversampling. In most cases you want to set this factor to 1.
286
+
287
+ <details>
288
+ <summary>Dataset config example:</summary>
289
+ <p>
290
+
291
+ `dataset.cfg`
292
+
293
+ ```json
294
+ {
295
+ "train": [
296
+ [
297
+ "TRAIN_SET_SPEECH.hdf5",
298
+ 1.0
299
+ ],
300
+ [
301
+ "TRAIN_SET_NOISE.hdf5",
302
+ 1.0
303
+ ],
304
+ [
305
+ "TRAIN_SET_RIR.hdf5",
306
+ 1.0
307
+ ]
308
+ ],
309
+ "valid": [
310
+ [
311
+ "VALID_SET_SPEECH.hdf5",
312
+ 1.0
313
+ ],
314
+ [
315
+ "VALID_SET_NOISE.hdf5",
316
+ 1.0
317
+ ],
318
+ [
319
+ "VALID_SET_RIR.hdf5",
320
+ 1.0
321
+ ]
322
+ ],
323
+ "test": [
324
+ [
325
+ "TEST_SET_SPEECH.hdf5",
326
+ 1.0
327
+ ],
328
+ [
329
+ "TEST_SET_NOISE.hdf5",
330
+ 1.0
331
+ ],
332
+ [
333
+ "TEST_SET_RIR.hdf5",
334
+ 1.0
335
+ ]
336
+ ]
337
+ }
338
+ ```
339
+
340
+ </p>
341
+ </details>
342
+
343
+ Finally, start the training script. The training script may create a model `base_dir` if not
344
+ existing used for logging, some audio samples, model checkpoints, and config. If no config file is
345
+ found, it will create a default config. See
346
+ [DeepFilterNet/pretrained_models/DeepFilterNet](https://github.com/Rikorose/DeepFilterNet/blob/main/DeepFilterNet/pretrained_models/DeepFilterNet/config.ini)
347
+ for a config file.
348
+ ```py
349
+ # usage: train.py [-h] [--debug] data_config_file data_dir base_dir
350
+ python df/train.py path/to/dataset.cfg path/to/data_dir/ path/to/base_dir/
351
+ ```
352
+
353
+ ## Citation Guide
354
+
355
+ To reproduce any metrics, we recomend to use the python implementation via `pip install deepfilternet`.
356
+
357
+ If you use this framework, please cite: *DeepFilterNet: A Low Complexity Speech Enhancement Framework for Full-Band Audio based on Deep Filtering*
358
+ ```bibtex
359
+ @inproceedings{schroeter2022deepfilternet,
360
+ title={{DeepFilterNet}: A Low Complexity Speech Enhancement Framework for Full-Band Audio based on Deep Filtering},
361
+ author = {Schröter, Hendrik and Escalante-B., Alberto N. and Rosenkranz, Tobias and Maier, Andreas},
362
+ booktitle={ICASSP 2022 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)},
363
+ year={2022},
364
+ organization={IEEE}
365
+ }
366
+ ```
367
+
368
+ If you use the DeepFilterNet2 model, please cite: *DeepFilterNet2: Towards Real-Time Speech Enhancement on Embedded Devices for Full-Band Audio*
369
+
370
+ ```bibtex
371
+ @inproceedings{schroeter2022deepfilternet2,
372
+ title = {{DeepFilterNet2}: Towards Real-Time Speech Enhancement on Embedded Devices for Full-Band Audio},
373
+ author = {Schröter, Hendrik and Escalante-B., Alberto N. and Rosenkranz, Tobias and Maier, Andreas},
374
+ booktitle={17th International Workshop on Acoustic Signal Enhancement (IWAENC 2022)},
375
+ year = {2022},
376
+ }
377
+ ```
378
+
379
+ If you use the DeepFilterNet3 model, please cite: *DeepFilterNet: Perceptually Motivated Real-Time Speech Enhancement*
380
+
381
+ ```bibtex
382
+ @inproceedings{schroeter2023deepfilternet3,
383
+ title = {{DeepFilterNet}: Perceptually Motivated Real-Time Speech Enhancement},
384
+ author = {Schröter, Hendrik and Rosenkranz, Tobias and Escalante-B., Alberto N. and Maier, Andreas},
385
+ booktitle={INTERSPEECH},
386
+ year = {2023},
387
+ }
388
+ ```
389
+
390
+ If you use the multi-frame beamforming algorithms. please cite *Deep Multi-Frame Filtering for Hearing Aids*
391
+
392
+ ```bibtex
393
+ @inproceedings{schroeter2023deep_mf,
394
+ title = {Deep Multi-Frame Filtering for Hearing Aids},
395
+ author = {Schröter, Hendrik and Rosenkranz, Tobias and Escalante-B., Alberto N. and Maier, Andreas},
396
+ booktitle={INTERSPEECH},
397
+ year = {2023},
398
+ }
399
+ ```
400
+
401
+ ## License
402
+
403
+ DeepFilterNet is free and open source! All code and model weights in this repository are dual-licensed under either:
404
+
405
+ * MIT License ([LICENSE-MIT](LICENSE-MIT) or [http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT))
406
+ * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0))
407
+
408
+ at your option. This means you can select the license you prefer!
409
+
410
+ 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.