Summary
In Constants.h, three duration constants are expressed in hops (one hop = 10 ms), while the surrounding constants are explicit milliseconds:
inline constexpr uint32_t kWindowSizeMs = 25;
inline constexpr uint32_t kHopLengthMs = 10;
...
inline constexpr size_t kMinSpeechDuration = 25; // 250 ms
inline constexpr size_t kMinSilenceDuration = 10; // 100 ms
inline constexpr size_t kSpeechPad = 3; // 30 ms
A reader has to know the unit is "10 ms per tick" to interpret 25 as 250 ms. The trailing comments are the only hint, and they will rot the first time someone changes kHopLengthMs.
What should be done
Pick one convention and apply it consistently. Either:
- Rename to make the unit explicit:
kMinSpeechDurationHops, kMinSilenceDurationHops, kSpeechPadHops, or
- Store values in ms (
kMinSpeechDurationMs = 250, …) and divide by kHopLengthMs at the use site.
Option 2 is more robust to changes in kHopLengthMs.
Context
Follow-up to PR #1160 review: #1160 (comment)
Summary
In
Constants.h, three duration constants are expressed in hops (one hop = 10 ms), while the surrounding constants are explicit milliseconds:A reader has to know the unit is "10 ms per tick" to interpret
25as 250 ms. The trailing comments are the only hint, and they will rot the first time someone changeskHopLengthMs.What should be done
Pick one convention and apply it consistently. Either:
kMinSpeechDurationHops,kMinSilenceDurationHops,kSpeechPadHops, orkMinSpeechDurationMs = 250, …) and divide bykHopLengthMsat the use site.Option 2 is more robust to changes in
kHopLengthMs.Context
Follow-up to PR #1160 review: #1160 (comment)