Skip to content

voxcom-us/fireredvad-dart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fireredvad

Streaming Voice Activity Detection (VAD) + Audio Event Detection (AED) using DFSMN. Pure Dart implementation — no native dependencies.

Features

  • Real-time streaming VAD with configurable thresholds
  • Audio Event Detection (AED) classifying segments as speech, music, or noise
  • Pure Dart — works on iOS, Android, macOS, web, and any Dart platform
  • Independent processing streams for concurrent audio sources

Installation

dependencies:
  fireredvad:
    git:
      url: https://github.com/voxcom-us/fireredvad-dart.git

Model Assets

This package requires two model files that must be provided by the consuming application:

  • weights.bin (~4.4 MB) — DFSMN model weights for VAD and AED
  • cmvn.json — Cepstral mean and variance normalization stats

Both files are included in the repository's assets/ directory. Copy them into your app's assets directory and declare them in your pubspec.yaml:

flutter:
  assets:
    - assets/weights.bin
    - assets/cmvn.json

Usage

import 'package:fireredvad/fireredvad.dart';
import 'package:flutter/services.dart' show rootBundle;

// Load model
final weightsData = await rootBundle.load('assets/weights.bin');
final cmvnJson = await rootBundle.loadString('assets/cmvn.json');

final vad = FireRedVad.load(weightsData, cmvnJson);
final stream = vad.createStream();

// Feed 16-bit PCM audio (16kHz, mono)
for (final chunk in audioChunks) {
  final events = stream.processChunk(chunk);
  for (final event in events) {
    print(event); // VadEvent(speech_start, ...) or VadEvent(speech_end, ...)
  }
}

// Flush at end of audio
final finalEvent = stream.flush();

Custom Thresholds

final stream = vad.createStream(
  speechThreshold: 0.5,   // default: 0.4
  minSpeechFrames: 10,    // default: 8
  minSilenceFrames: 30,   // default: 20
  maxSpeechFrames: 3000,  // default: 2000
);

Audio Event Detection (AED)

Classify a speech segment as speech, music, or noise:

final vad = FireRedVad.load(weightsData, cmvnJson, enableAed: true);

// After detecting a speech segment, classify it
final result = vad.classifySegment(segmentPcm);
if (result != null) {
  print(result.label);  // "speech", "music", or "noise"
  print(result.probs);  // [speechProb, musicProb, noiseProb]
}

Example

See the example/ directory for a Flutter demo app with:

  • Real-time microphone recording with live waveform
  • Speech segment detection and saving
  • AED classification of detected segments
  • Configurable VAD thresholds
cd example
flutter run

Audio Format

All audio input must be 16-bit signed PCM, 16kHz sample rate, mono channel.

License

See LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors