AlexaClientSDK  1.26.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Member Functions | Static Public Member Functions | List of all members
alexaClientSDK::kwd::SensoryKeywordDetector Class Reference

#include <SensoryKeywordDetector.h>

Inheritance diagram for alexaClientSDK::kwd::SensoryKeywordDetector:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::kwd::SensoryKeywordDetector:
Collaboration graph
[legend]

Public Member Functions

 ~SensoryKeywordDetector () override
 
- Public Member Functions inherited from alexaClientSDK::acsdkKWDImplementations::AbstractKeywordDetector
void addKeyWordObserver (std::shared_ptr< avsCommon::sdkInterfaces::KeyWordObserverInterface > keyWordObserver)
 
void removeKeyWordObserver (std::shared_ptr< avsCommon::sdkInterfaces::KeyWordObserverInterface > keyWordObserver)
 
void addKeyWordDetectorStateObserver (std::shared_ptr< avsCommon::sdkInterfaces::KeyWordDetectorStateObserverInterface > keyWordDetectorStateObserver)
 
void removeKeyWordDetectorStateObserver (std::shared_ptr< avsCommon::sdkInterfaces::KeyWordDetectorStateObserverInterface > keyWordDetectorStateObserver)
 
virtual ~AbstractKeywordDetector ()=default
 

Static Public Member Functions

static std::unique_ptr< SensoryKeywordDetectorcreate (const std::shared_ptr< AudioInputStream > stream, const std::shared_ptr< avsCommon::utils::AudioFormat > &audioFormat, std::shared_ptr< acsdkKWDInterfaces::KeywordNotifierInterface > keyWordNotifier, std::shared_ptr< acsdkKWDInterfaces::KeywordDetectorStateNotifierInterface > KeyWordDetectorStateNotifier, const std::string &modelFilePath, std::chrono::milliseconds msToPushPerIteration=std::chrono::milliseconds(10))
 
static std::unique_ptr< SensoryKeywordDetectorcreate (const std::shared_ptr< AudioInputStream > stream, avsCommon::utils::AudioFormat audioFormat, std::unordered_set< std::shared_ptr< KeyWordObserverInterface >> keyWordObservers, std::unordered_set< std::shared_ptr< KeyWordDetectorStateObserverInterface >> keyWordDetectorStateObservers, const std::string &modelFilePath, std::chrono::milliseconds msToPushPerIteration=std::chrono::milliseconds(10))
 

Additional Inherited Members

- Protected Member Functions inherited from alexaClientSDK::acsdkKWDImplementations::AbstractKeywordDetector
 AbstractKeywordDetector (std::unordered_set< std::shared_ptr< avsCommon::sdkInterfaces::KeyWordObserverInterface >> keyWordObservers=std::unordered_set< std::shared_ptr< avsCommon::sdkInterfaces::KeyWordObserverInterface >>(), std::unordered_set< std::shared_ptr< avsCommon::sdkInterfaces::KeyWordDetectorStateObserverInterface >> keyWordDetectorStateObservers=std::unordered_set< std::shared_ptr< avsCommon::sdkInterfaces::KeyWordDetectorStateObserverInterface >>())
 
 AbstractKeywordDetector (std::shared_ptr< acsdkKWDInterfaces::KeywordNotifierInterface > keywordNotifier, std::shared_ptr< acsdkKWDInterfaces::KeywordDetectorStateNotifierInterface > keyWordDetectorStateNotifier)
 
void notifyKeyWordObservers (std::shared_ptr< avsCommon::avs::AudioInputStream > stream, std::string keyword, avsCommon::avs::AudioInputStream::Index beginIndex, avsCommon::avs::AudioInputStream::Index endIndex, std::shared_ptr< const std::vector< char >> KWDMetadata=nullptr) const
 
void notifyKeyWordDetectorStateObservers (avsCommon::sdkInterfaces::KeyWordDetectorStateObserverInterface::KeyWordDetectorState state)
 
ssize_t readFromStream (std::shared_ptr< avsCommon::avs::AudioInputStream::Reader > reader, std::shared_ptr< avsCommon::avs::AudioInputStream > stream, void *buf, size_t nWords, std::chrono::milliseconds timeout, bool *errorOccurred)
 
- Static Protected Member Functions inherited from alexaClientSDK::acsdkKWDImplementations::AbstractKeywordDetector
static bool isByteswappingRequired (avsCommon::utils::AudioFormat audioFormat)
 

Constructor & Destructor Documentation

◆ ~SensoryKeywordDetector()

alexaClientSDK::kwd::SensoryKeywordDetector::~SensoryKeywordDetector ( )
override

Destructor.

Member Function Documentation

◆ create() [1/2]

static std::unique_ptr<SensoryKeywordDetector> alexaClientSDK::kwd::SensoryKeywordDetector::create ( const std::shared_ptr< AudioInputStream stream,
const std::shared_ptr< avsCommon::utils::AudioFormat > &  audioFormat,
std::shared_ptr< acsdkKWDInterfaces::KeywordNotifierInterface keyWordNotifier,
std::shared_ptr< acsdkKWDInterfaces::KeywordDetectorStateNotifierInterface KeyWordDetectorStateNotifier,
const std::string &  modelFilePath,
std::chrono::milliseconds  msToPushPerIteration = std::chrono::milliseconds(10) 
)
static

Creates a SensoryKeywordDetector. Requires that the AlexaClientSDKConfig.json has a modelFilePath value under sampleApp

Parameters
streamThe stream of audio data. This should be formatted in LPCM encoded with 16 bits per sample and have a sample rate of 16 kHz. Additionally, the data should be in little endian format.
audioFormatThe format of the audio data located within the stream.
keyWordNotifierThe object with which to notifiy observers of keyword detections.
KeyWordDetectorStateNotifierThe object with which to notify observers of state changes in the engine.
modelFilePathThe path to the model file.
msToPushPerIterationThe amount of data in milliseconds to push to Sensory at a time. Smaller sizes will lead to less delay but more CPU usage. Additionally, larger amounts of data fed into the engine per iteration might lead longer delays before receiving keyword detection events. This has been defaulted to 10 milliseconds as it is a good trade off between CPU usage and recognition delay. Additionally, this was the amount used by Sensory in example code.
Returns
A new SensoryKeywordDetector, or nullptr if the operation failed.

◆ create() [2/2]

static std::unique_ptr<SensoryKeywordDetector> alexaClientSDK::kwd::SensoryKeywordDetector::create ( const std::shared_ptr< AudioInputStream stream,
avsCommon::utils::AudioFormat  audioFormat,
std::unordered_set< std::shared_ptr< KeyWordObserverInterface >>  keyWordObservers,
std::unordered_set< std::shared_ptr< KeyWordDetectorStateObserverInterface >>  keyWordDetectorStateObservers,
const std::string &  modelFilePath,
std::chrono::milliseconds  msToPushPerIteration = std::chrono::milliseconds(10) 
)
static
Deprecated:
Creates a SensoryKeywordDetector. Requires that the AlexaClientSDKConfig.json has a modelFilePath value under sampleApp
Parameters
streamThe stream of audio data. This should be formatted in LPCM encoded with 16 bits per sample and have a sample rate of 16 kHz. Additionally, the data should be in little endian format.
audioFormatThe format of the audio data located within the stream.
keyWordObserversThe observers to notify of keyword detections.
keyWordDetectorStateObserversThe observers to notify of state changes in the engine.
modelFilePathThe path to the model file.
msToPushPerIterationThe amount of data in milliseconds to push to Sensory at a time. Smaller sizes will lead to less delay but more CPU usage. Additionally, larger amounts of data fed into the engine per iteration might lead longer delays before receiving keyword detection events. This has been defaulted to 10 milliseconds as it is a good trade off between CPU usage and recognition delay. Additionally, this was the amount used by Sensory in example code.
Returns
A new SensoryKeywordDetector, or nullptr if the operation failed.

The documentation for this class was generated from the following files:

AlexaClientSDK 1.26.0 - Copyright 2016-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0