danielr-ceva commited on
Commit
16aeec3
·
verified ·
1 Parent(s): 1366be9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +65 -1
README.md CHANGED
@@ -51,6 +51,7 @@ It builds on **DeepFilterNet2** by adding **Dual‑Path RNN (DPRNN)** blocks in
51
  | Model | DPRNN blocks | Params (M) | MACs (G) |
52
  |---|:---:|:---:|:---:|
53
  | `dpdfnet2_48khz_hr` | 2 | 2.58 | 2.42 |
 
54
 
55
  ---
56
 
@@ -67,7 +68,7 @@ pip install dpdfnet
67
  dpdfnet enhance noisy.wav enhanced.wav --model dpdfnet4
68
 
69
  # Enhance a directory
70
- dpdfnet enhance-dir ./noisy_wavs ./enhanced_wavs --model dpdfnet2
71
 
72
  # Download models
73
  dpdfnet download
@@ -99,6 +100,69 @@ dpdfnet.download() # All models
99
  dpdfnet.download("dpdfnet4") # Specific model
100
  ```
101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  ---
103
 
104
  ## Citation
 
51
  | Model | DPRNN blocks | Params (M) | MACs (G) |
52
  |---|:---:|:---:|:---:|
53
  | `dpdfnet2_48khz_hr` | 2 | 2.58 | 2.42 |
54
+ | `dpdfnet8_48khz_hr` | 8 | 3.63 | 7.17 |
55
 
56
  ---
57
 
 
68
  dpdfnet enhance noisy.wav enhanced.wav --model dpdfnet4
69
 
70
  # Enhance a directory
71
+ dpdfnet enhance-dir ./noisy_wavs ./enhanced_wavs --model dpdfnet2 --workers 5
72
 
73
  # Download models
74
  dpdfnet download
 
100
  dpdfnet.download("dpdfnet4") # Specific model
101
  ```
102
 
103
+ ### Real-time Microphone Enhancement
104
+
105
+ Install `sounddevice` (not included in `dpdfnet` dependencies):
106
+
107
+ ```bash
108
+ pip install sounddevice
109
+ ```
110
+
111
+ `StreamEnhancer` processes audio chunk-by-chunk, preserving RNN state across
112
+ calls. Any chunk size works; enhanced samples are returned as soon as enough
113
+ data has accumulated for the first model frame (20 ms).
114
+
115
+ ```python
116
+ import numpy as np
117
+ import sounddevice as sd
118
+ import dpdfnet
119
+
120
+ INPUT_SR = 48000
121
+ # Use one model hop (10 ms) as the block size so process() returns
122
+ # exactly one hop's worth of enhanced audio on every callback.
123
+ BLOCK_SIZE = int(INPUT_SR * 0.010) # 480 samples at 48 kHz
124
+
125
+ enhancer = dpdfnet.StreamEnhancer(model="dpdfnet2_48khz_hr")
126
+
127
+ def callback(indata, outdata, frames, time, status):
128
+ mono_in = indata[:, 0] if indata.ndim > 1 else indata.ravel()
129
+ enhanced = enhancer.process(mono_in, sample_rate=INPUT_SR)
130
+ n = min(len(enhanced), frames)
131
+ outdata[:n, 0] = enhanced[:n]
132
+ if n < frames:
133
+ outdata[n:] = 0.0 # silence while the first window accumulates
134
+
135
+ with sd.Stream(
136
+ samplerate=INPUT_SR,
137
+ blocksize=BLOCK_SIZE,
138
+ channels=1,
139
+ dtype="float32",
140
+ callback=callback,
141
+ ):
142
+ print("Enhancing microphone input - press Ctrl+C to stop")
143
+ try:
144
+ while True:
145
+ sd.sleep(100)
146
+ except KeyboardInterrupt:
147
+ pass
148
+
149
+ # Optional: drain the final partial window at the end of a recording
150
+ tail = enhancer.flush()
151
+ ```
152
+
153
+ > [!NOTE]
154
+ > **Latency**
155
+ > The first enhanced output arrives after one full model window (~20 ms) has been buffered. All subsequent blocks are returned with ~10 ms additional delay.
156
+ >
157
+ > **Sample rate**
158
+ > `StreamEnhancer` resamples internally. Pass your device's native rate as `sample_rate`; the return value is at the same rate.
159
+ >
160
+ > **Block size**
161
+ > Using `BLOCK_SIZE = int(SR * 0.010)` (one model hop) gives one enhanced block per callback. Other sizes also work but may produce empty returns while the buffer fills.
162
+ >
163
+ > **Multiple streams**
164
+ > Create a separate `StreamEnhancer` per stream. Call `enhancer.reset()` between independent audio segments to clear RNN state.
165
+
166
  ---
167
 
168
  ## Citation