Skip to content

VAD: duration constants use hop units while neighbours use ms #1172

@msluszniak

Description

@msluszniak

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:

  1. Rename to make the unit explicit: kMinSpeechDurationHops, kMinSilenceDurationHops, kSpeechPadHops, or
  2. 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)

Metadata

Metadata

Assignees

Labels

improvementPRs or issues focused on improvements in the current codebaserefactoring

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions