Repository navigation
Commit 588cf05
* fix(quality_gates): #80 replace per-sample click detector with DC-step detector
The M15 click detector flagged every turn (164–1766 events vs threshold 3)
because it triggered on Hebrew sibilants (/ʃ/ /s/ /z/), not on the DC-offset
boundary clicks it was designed to catch. Diagnosis on sp_neu_a_0001 (12
turns, 8907 isolated events): 0 events near silence, 1464+ in continuous
high-energy speech — the per-sample-diff heuristic cannot discriminate
zero-mean fricative noise from a true baseline shift.
Replace the heuristic with a running-mean step detector: compare the mean
of the 40 ms window before each sample to the mean of the 40 ms window
after, count peaks where |post - pre| > 0.08, collapse adjacent positions
via non-maximum suppression. 40 ms covers ≥3 F0 cycles even at the male
low end (80 Hz), so voiced AC swing averages out and only true DC shifts
survive.
Verified on the 12 captured sp_neu_a_0001 turns: all 12 pass (0 events
each). Synthetic DC-step fixture (3 sustained 50 ms shifts) registers
6 events as expected (rising + falling edge of each).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(quality_gates): #80 self-review pass — off-by-one, semantics, real fixture
Self-review of the previous commit raised 11 issues; addressing 10 here
(skipping the float32-cumsum optimization — at 24 kHz × 30 s the float32
drift is ~0.085, on the order of the 0.08 step threshold; float64 is
load-bearing for precision and now has a comment saying so).
Code (synthbanshee/tts/quality_gates.py):
- Fix off-by-one in candidate range: idx = arange(win, n - win) (was
n - win - 1, dropping the last valid candidate position).
- Rename CLICK_COUNT_THRESHOLD → CLICK_STEP_EVENT_THRESHOLD with a
comment making it explicit the threshold counts edges, not clicks
(one sustained DC offset = 2 events: rising + falling edge).
- Hoist `from scipy.signal import find_peaks` to module top.
- Type CLICK_STEP_WINDOW_MS as int (was float = 40.0 for an integer ms).
- Surface the first 3 step-event timestamps in the failure detail string
so an operator can seek directly to the alleged click.
Tests (tests/unit/test_quality_gates.py + tests/fixtures/clicks/):
- Parametrize test_dc_offset_steps_fail and test_sibilant_like_noise_passes
over [16_000, 24_000] (gate runs at 24 kHz Azure native in production).
- Tighten DC-step assertion: 5 ≤ count ≤ 8 instead of just `not passed`,
locking in detector behaviour rather than just outcome.
- Add test_real_tts_turn_passes with two checked-in fixtures: 2 s segments
from real Azure he-IL output for sp_neu_a_0001 (turn 03 VIC/F, turn 08
AGG/M) at the highest pre-fix click density windows. The pre-#80
detector flagged 337/232 events on these segments respectively — they
are now a real regression guard against the synthetic test's blind
spots (white noise * Hanning ≠ Hebrew sibilant spectral content).
- Document test_isolated_single_sample_spikes_pass as an intentional
capability change, with the rationale (Azure he-IL does not produce
isolated impulse noise in practice).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(quality_gates): #80 address Copilot review — boundary, 24 kHz, comment
Three issues from Copilot's PR review on PR #85:
1. Boundary blind spot: pre-fix, idx = arange(win, n - win) excluded the
first/last 40 ms of the signal, so a DC step at turn onset or final
sample would never register. Now zero-pad the signal by `win` samples
on each side before cumsum so every original sample gets a valid pre
and post window. At the boundaries the offset is compared against
silence, which is the right semantic — a real DC stitching artifact
present from t=0 should fire. Added test_dc_offset_at_signal_start_caught
and test_dc_offset_at_signal_end_caught.
2. Real-fixture coverage only at 16 kHz: gate runs at 24 kHz Azure native
in production, so behaviour at the production rate must be tested with
real Hebrew TTS audio. Extracted the same 2 s window directly from
the captured 24 kHz native WAVs (no resample), committed as a second
pair of fixtures, parametrized test_real_tts_turn_passes over both SRs
(4 fixture cases total).
3. Stale "20 ms detector window" comment in test_dc_offset_steps_fail —
detector is 40 ms; updated.
All 32 click-gate tests pass; full unit + integration suite green
(1731 / 1 skip); ruff + mypy clean.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(quality_gates): #80 second Copilot pass — find_peaks boundary, tighter tests
Previous commit zero-padded the *samples* array so every original sample
got a valid pre/post window, but find_peaks itself still couldn't return
index 0 or n-1 of the step array — peaks need both neighbours by
definition. Effect: a DC offset present at sample 0 (or persisting
through the final sample) was still silently dropped.
Fix: also pad the *step* array with zero sentinels before find_peaks,
then shift returned indices back by 1. Sentinels are below threshold,
so they're never selected; the only reachable change is that step[0]
and step[n-1] become eligible peaks.
Tests: redesigned both boundary tests so the boundary edge is *required*
to push the event count above the threshold.
- test_dc_offset_at_signal_start_caught: 3 sustained offsets, first one
starting at sample 0. Without the fix: 5 events (boundary edge
missed). With the fix: 6. Test asserts count >= 6 AND that the first
peak timestamp is within one sample of t=0.
- test_dc_offset_at_signal_end_caught: symmetric. Last offset persists
through the final sample. Asserts count >= 6.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 94086a8 commit 588cf05
6 files changed
Lines changed: 221 additions & 56 deletions
File tree
- synthbanshee/tts
- tests
- fixtures/clicks
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| 23 | + | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
| |||
32 | 35 | | |
33 | 36 | | |
34 | 37 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
47 | 60 | | |
48 | 61 | | |
49 | 62 | | |
| |||
206 | 219 | | |
207 | 220 | | |
208 | 221 | | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
216 | 241 | | |
217 | 242 | | |
218 | 243 | | |
| |||
221 | 246 | | |
222 | 247 | | |
223 | 248 | | |
224 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
225 | 252 | | |
226 | 253 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
249 | 289 | | |
250 | 290 | | |
251 | 291 | | |
252 | | - | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
253 | 296 | | |
254 | 297 | | |
255 | 298 | | |
| |||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| 22 | + | |
| 23 | + | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
| |||
128 | 132 | | |
129 | 133 | | |
130 | 134 | | |
131 | | - | |
132 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
133 | 163 | | |
134 | | - | |
135 | 164 | | |
136 | | - | |
| 165 | + | |
137 | 166 | | |
138 | | - | |
139 | | - | |
| 167 | + | |
140 | 168 | | |
141 | 169 | | |
142 | | - | |
| 170 | + | |
| 171 | + | |
143 | 172 | | |
144 | | - | |
145 | | - | |
| 173 | + | |
146 | 174 | | |
147 | 175 | | |
148 | 176 | | |
149 | | - | |
150 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
151 | 226 | | |
152 | | - | |
| 227 | + | |
153 | 228 | | |
154 | 229 | | |
155 | 230 | | |
156 | 231 | | |
157 | 232 | | |
158 | 233 | | |
159 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
160 | 282 | | |
161 | 283 | | |
162 | 284 | | |
| |||
0 commit comments