KeywordSpotting<T>
Models & Types · AiDotNet.SpeechRecognition.Specialized
Keyword Spotting: lightweight wake-word and command detection
Inheritance: NeuralNetworkBase<T> → AudioNeuralNetworkBase<T> → KeywordSpotting<T>
Implements: ISpeechRecognizer<T>
For Beginners
Keyword Spotting provides lightweight, always-on detection of specific keywords and voice commands using a small feed-forward neural network.
How It Works
References:
- Paper: “Small-footprint Keyword Spotting Using Deep Neural Networks” (2014)
The cited Deep KWS model stacks log-filterbank frames, passes them through fully connected ReLU layers, and produces frame-level keyword-label posteriors with a softmax output layer.
Example
// Create a Keyword Spotting model for wake-word detection
var architecture = new NeuralNetworkArchitecture<double>(
inputType: InputType.OneDimensional,
taskType: NeuralNetworkTaskType.SpeechRecognition,
inputHeight: 16000, inputWidth: 1, inputDepth: 1, outputSize: 32);
var model = new KeywordSpotting<double>(architecture);
// Or load a pre-trained ONNX model for edge-device keyword detection
var onnxModel = new KeywordSpotting<double>(architecture, "keywordspotting.onnx");
Constructors
| Constructor | Summary |
|---|---|
KeywordSpotting(NeuralNetworkArchitecture<T> architecture, KeywordSpottingOptions options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer) |
|
KeywordSpotting(NeuralNetworkArchitecture<T> architecture, string modelPath, KeywordSpottingOptions options) |
Properties
| Property | Summary |
|---|---|
IReadOnlyList<string> SupportedLanguages { get; } |
|
bool SupportsStreaming { get; } |
|
bool SupportsWordTimestamps { get; } |
Methods
| Method | Summary |
|---|---|
IReadOnlyDictionary<string, T> DetectLanguageProbabilities(Tensor<T> audio) |
|
IStreamingTranscriptionSession<T> StartStreamingSession(string language) |
|
ModelMetadata<T> GetModelMetadata() |
|
Task<TranscriptionResult<T>> TranscribeAsync(Tensor<T> audio, string language, bool? includeTimestamps, CancellationToken cancellationToken) |
|
TranscriptionResult<T> Transcribe(Tensor<T> audio, string language, bool? includeTimestamps) |
Detects keywords using the paper’s compact feed-forward Deep KWS network. |
string DetectLanguage(Tensor<T> audio) |