Component evidence

src/vad.cpp

hermes-gadget-sdk · firmware/core/src/vad.cpp · cpp · MIT
voice

A production-ready voice activity detector with adaptive noise floor tracking for real-time speech endpointing in embedded audio applications.

Source preview first 800 characters · full source over MCP
// Source: https://github.com/Adolanium/hermes-gadget-sdk | License: MIT | Copyright 2026 Hermes Gadget SDK contributors
// Provided via justclaw.it.com; keep this notice with the code.
#include "hg/vad.hpp"

#include <cmath>

namespace hg {

float rms(const int16_t* samples, size_t count) {
  if (count == 0) return 0.0f;
  double acc = 0;
  for (size_t i = 0; i < count; ++i) acc += double(samples[i]) * samples[i];
  return static_cast<float>(std::sqrt(acc / double(count)));
}

uint8_t level_percent(float r) {
  // ~-60 dBFS -> 0, 0 dBFS -> 100.
  if (r < 1.0f) return 0;
  float db = 20.0f * std::log10(r / 32768.0f);
  float pct = (db + 60.0f) * (100.0f / 60.0f);
  if (pct < 0) pct = 0;
  if (pct > 100) pct = 100;
  return static_cast<uint8_t>(pct);
}

void Vad::reset(const Config& cfg) {


... (truncated -- full source via MCP)