microwakeword

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2025 License: MIT Imports: 10 Imported by: 2

README

MicroWakeWord

A Golang library for wake word detection using TensorFlow Lite and audio microfrontend processing.

Overview

MicroWakeWord is a lightweight wake word detection library for Go applications. It leverages TensorFlow Lite and the audio microfrontend to provide efficient and accurate wake word detection capabilities with minimal resource usage, making it suitable for embedded systems and IoT devices.

This library is inspired by microWakeWord and provides a simple API for detecting predefined wake words from audio input.

Prerequisites

  • Go 1.16 or higher
  • GCC or compatible C compiler
  • Bazel build system
  • Git

Installation

1. Build Dependencies

The library requires two main dependencies:

  • TensorFlow Lite C library
  • Audio Microfrontend library

Use the provided Makefile to build and install these dependencies:

# Clone the repository
git clone https://github.com/pmdroid/microwakeword.git
cd microwakeword

# Build and install dependencies (may require sudo for installation)
make
sudo make install

The Makefile will:

  1. Download TensorFlow v2.19.0
  2. Download KissFFT
  3. Build the TensorFlow Lite C and Microfrontend libraries
  4. Install the shared libraries to /usr/local/lib
2. Install the Go Library
go get github.com/pmdroid/microwakeword

Usage

Examples

The repository includes examples to help you get started:

  • examples/mic.go: A complete example showing how to use the library with microphone input for real-time wake word detection

The microphone example demonstrates:

  • Loading a wake word model
  • Initializing and configuring the microphone
  • Processing streaming audio data
  • Detecting wake words in real-time

To run the microphone example:

go run examples/mic.go

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Acknowledgements

  • This project uses TensorFlow
  • KissFFT library by Mark Borgerding

Documentation

Index

Constants

View Source
const (
	SamplesPerSecond  = 16000
	SamplesPerChunk   = 160 // 10ms
	BytesPerSample    = 2   // 16-bit
	BytesPerChunk     = SamplesPerChunk * BytesPerSample
	SecondsPerChunk   = float64(SamplesPerChunk) / float64(SamplesPerSecond)
	Stride            = 3
	DefaultRefractory = 2.0 // seconds
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClipResult

type ClipResult struct {
	Detected        bool
	DetectedSeconds *float64
	Probabilities   []float64
}

type MicroConfig

type MicroConfig struct {
	ProbabilityCutoff float64 `json:"probability_cutoff"`
	SlidingWindowSize int     `json:"sliding_window_size"`
}

type MicroWakeWord

type MicroWakeWord struct {
	// contains filtered or unexported fields
}

func FromBuiltin

func FromBuiltin(
	modelName string,
	refractorySeconds float64,
) (*MicroWakeWord, error)

func FromConfig

func FromConfig(
	configPath string,
	refractorySeconds float64,
) (*MicroWakeWord, error)

func NewMicroWakeWord

func NewMicroWakeWord(
	tfliteModel string,
	micro MicroConfig,
	refractorySeconds float64,
) (*MicroWakeWord, error)

func (*MicroWakeWord) ProcessClip

func (mww *MicroWakeWord) ProcessClip(audioBytes []byte) (*ClipResult, error)

func (*MicroWakeWord) ProcessStreaming

func (mww *MicroWakeWord) ProcessStreaming(audioBytes []byte) (bool, error)

func (*MicroWakeWord) Reset

func (mww *MicroWakeWord) Reset() error

type ModelConfig

type ModelConfig struct {
	WakeWord  string      `json:"wake_word"`
	ModelFile string      `json:"model"`
	Micro     MicroConfig `json:"micro"`
}

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL