Wake Word Detection

fmus_vox.wakeword - Wake word detection functionality for voice applications.

This module provides interfaces and implementations for wake word detection, allowing applications to respond to specific trigger phrases.

class fmus_vox.wakeword.WakeWordDetector(wake_words: str | List[str], threshold: float = 0.5, **kwargs)[source]

Bases: ABC

Base class for wake word detection implementations.

This abstract class defines the interface that all wake word detectors must implement.

__init__(wake_words: str | List[str], threshold: float = 0.5, **kwargs)[source]

Initialize the wake word detector.

Parameters:
  • wake_words – Single wake word or list of wake words to detect.

  • threshold – Detection sensitivity threshold (0-1).

  • **kwargs – Additional detector-specific parameters.

add_callback(wake_word: str, callback: Callable[[Dict[str, Any]], None]) None[source]

Add a callback to be called when a specific wake word is detected.

Parameters:
  • wake_word – The wake word to trigger the callback.

  • callback – Function to call when the wake word is detected. Should accept a dict with metadata about the detection.

remove_callback(wake_word: str, callback: Callable | None = None) None[source]

Remove callback(s) for a specific wake word.

Parameters:
  • wake_word – The wake word to remove callbacks for.

  • callback – Specific callback to remove. If None, all callbacks for the wake word are removed.

abstract load_model() None[source]

Load the wake word detection model.

This method must be implemented by subclasses to load the specific wake word model.

Raises:

ModelLoadError – If the model cannot be loaded.

abstract detect(audio: str | Audio) bool[source]

Detect if the audio contains any of the configured wake words.

Parameters:

audio – Audio object or path to audio file to analyze.

Returns:

True if a wake word was detected, False otherwise.

start_streaming(stream_source=None) None[source]

Start continuous wake word detection from a stream.

Parameters:

stream_source – Optional audio stream source. If None, will use the default microphone.

stop_streaming() None[source]

Stop continuous wake word detection.

property is_running: bool

Return True if the detector is currently running.

fmus_vox.wakeword.detect_wake_word(audio: str | Audio, wake_word: str = 'hey assistant', threshold: float = 0.5) bool[source]

Detect if an audio file or buffer contains the wake word.

Parameters:
  • audio – Audio object or path to audio file.

  • wake_word – Wake word to detect.

  • threshold – Detection threshold (0-1).

Returns:

True if wake word was detected.

fmus_vox.wakeword.create_detector(wake_word: str | List[str] = 'hey assistant', threshold: float = 0.5, model_type: str = 'porcupine') WakeWordDetector[source]

Create a wake word detector with specified settings.

Parameters:
  • wake_word – Wake word(s) to detect.

  • threshold – Detection threshold (0-1).

  • model_type – Type of detector to use (‘porcupine’ or ‘precise’).

Returns:

Configured WakeWordDetector instance.

WakeWordDetector Class

class fmus_vox.wakeword.detector.WakeWordDetector(wake_words: str | List[str], threshold: float = 0.5, **kwargs)[source]

Bases: ABC

Base class for wake word detection implementations.

This abstract class defines the interface that all wake word detectors must implement.

__init__(wake_words: str | List[str], threshold: float = 0.5, **kwargs)[source]

Initialize the wake word detector.

Parameters:
  • wake_words – Single wake word or list of wake words to detect.

  • threshold – Detection sensitivity threshold (0-1).

  • **kwargs – Additional detector-specific parameters.

add_callback(wake_word: str, callback: Callable[[Dict[str, Any]], None]) None[source]

Add a callback to be called when a specific wake word is detected.

Parameters:
  • wake_word – The wake word to trigger the callback.

  • callback – Function to call when the wake word is detected. Should accept a dict with metadata about the detection.

remove_callback(wake_word: str, callback: Callable | None = None) None[source]

Remove callback(s) for a specific wake word.

Parameters:
  • wake_word – The wake word to remove callbacks for.

  • callback – Specific callback to remove. If None, all callbacks for the wake word are removed.

abstract load_model() None[source]

Load the wake word detection model.

This method must be implemented by subclasses to load the specific wake word model.

Raises:

ModelLoadError – If the model cannot be loaded.

abstract detect(audio: str | Audio) bool[source]

Detect if the audio contains any of the configured wake words.

Parameters:

audio – Audio object or path to audio file to analyze.

Returns:

True if a wake word was detected, False otherwise.

start_streaming(stream_source=None) None[source]

Start continuous wake word detection from a stream.

Parameters:

stream_source – Optional audio stream source. If None, will use the default microphone.

stop_streaming() None[source]

Stop continuous wake word detection.

property is_running: bool

Return True if the detector is currently running.