Repository navigation
Commit 778c507
authored
refactor(vad): store duration constants in ms instead of hops (#1200)
## Description
`kMinSpeechDuration`, `kMinSilenceDuration` and `kSpeechPad` were stored
as hop counts with trailing comments hinting the ms equivalent. The unit
implicitly depended on `kHopLengthMs`, and the comments would rot the
moment someone changed it.
Rename to `*Ms` to match the `kWindowSizeMs` / `kHopLengthMs` convention
and convert to hops at the use site via `/ kHopLengthMs`. Now
`kHopLengthMs` changes propagate automatically and the source-of-truth
unit is explicit in the name.
### Introduces a breaking change?
- [ ] Yes
- [x] No
### Type of change
- [ ] Bug fix (change which fixes an issue)
- [ ] New feature (change which adds functionality)
- [ ] Documentation update (improves or adds clarity to existing
documentation)
- [x] Other (chores, tests, code style improvements etc.)
### Tested on
- [ ] iOS
- [ ] Android
### Testing instructions
Refactor only — values are unchanged (`250 / 10 = 25`, `100 / 10 = 10`,
`30 / 10 = 3`). Existing VAD behavior should be identical.
### Screenshots
### Related issues
Closes #1172
### Checklist
- [x] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have updated the documentation accordingly
- [x] My changes generate no new warnings
### Additional notes
Per discussion in the issue, picked option 2 (ms-based source of truth)
over the rename-with-`Hops`-suffix option because it survives changes to
`kHopLengthMs`.1 parent d488d1b commit 778c507
2 files changed
Lines changed: 9 additions & 8 deletions
File tree
- packages/react-native-executorch/common/rnexecutorch/models/voice_activity_detection
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
| 212 | + | |
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
| 224 | + | |
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
| 240 | + | |
240 | 241 | | |
241 | | - | |
| 242 | + | |
242 | 243 | | |
243 | | - | |
244 | | - | |
| 244 | + | |
| 245 | + | |
245 | 246 | | |
246 | 247 | | |
247 | 248 | | |
| |||
0 commit comments