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

#include <AbstractKeywordDetector.h>

Inheritance diagram for alexaClientSDK::acsdkKWDImplementations::AbstractKeywordDetector:
Inheritance graph
[legend]

Public Member Functions

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
 

Protected Member Functions

 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 >>(), bool supportsDavs=false)
 
 AbstractKeywordDetector (std::shared_ptr< acsdkKWDInterfaces::KeywordNotifierInterface > keywordNotifier, std::shared_ptr< acsdkKWDInterfaces::KeywordDetectorStateNotifierInterface > keyWordDetectorStateNotifier, bool supportsDavs=false)
 
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)
 
bool isDavsSupported ()
 

Static Protected Member Functions

static bool isByteswappingRequired (avsCommon::utils::AudioFormat audioFormat)
 

Constructor & Destructor Documentation

◆ ~AbstractKeywordDetector()

virtual alexaClientSDK::acsdkKWDImplementations::AbstractKeywordDetector::~AbstractKeywordDetector ( )
virtualdefault

Destructor.

◆ AbstractKeywordDetector() [1/2]

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 >>(),
bool  supportsDavs = false 
)
protected
Deprecated:
Constructor.
Parameters
keyWordObserversThe observers to notify of keyword detections.
keyWordDetectorStateObserversThe observers to notify of state changes in the engine.
supportsDavsBoolean to indicate whether keyword detector supports Davs or not.

◆ AbstractKeywordDetector() [2/2]

alexaClientSDK::acsdkKWDImplementations::AbstractKeywordDetector::AbstractKeywordDetector ( std::shared_ptr< acsdkKWDInterfaces::KeywordNotifierInterface keywordNotifier,
std::shared_ptr< acsdkKWDInterfaces::KeywordDetectorStateNotifierInterface keyWordDetectorStateNotifier,
bool  supportsDavs = false 
)
protected

Constructor.

Parameters
keyWordNotifierThe object with which to notifiy observers of keyword detections.
KeyWordDetectorStateNotifierThe object with which to notify observers of state changes in the engine.
supportsDavsBoolean to indicate whether keyword detector supports Davs or not.

Member Function Documentation

◆ addKeyWordDetectorStateObserver()

void alexaClientSDK::acsdkKWDImplementations::AbstractKeywordDetector::addKeyWordDetectorStateObserver ( std::shared_ptr< avsCommon::sdkInterfaces::KeyWordDetectorStateObserverInterface keyWordDetectorStateObserver)

Adds the specified observer to the list of observers to notify of key word detector state changes. Observer will have onStateChanged called upon being added to notify of current detector state.

Parameters
keyWordDetectorStateObserverThe observer to add.

◆ addKeyWordObserver()

void alexaClientSDK::acsdkKWDImplementations::AbstractKeywordDetector::addKeyWordObserver ( std::shared_ptr< avsCommon::sdkInterfaces::KeyWordObserverInterface keyWordObserver)

Adds the specified observer to the list of observers to notify of key word detection events.

Parameters
keyWordObserverThe observer to add.

◆ isByteswappingRequired()

static bool alexaClientSDK::acsdkKWDImplementations::AbstractKeywordDetector::isByteswappingRequired ( avsCommon::utils::AudioFormat  audioFormat)
staticprotected

Checks to see if the audioFormat matches the platform endianness.

Parameters
audioFormatThe audio format to check
Returns
true if the endiannesses don't match and false otherwise.

◆ isDavsSupported()

bool alexaClientSDK::acsdkKWDImplementations::AbstractKeywordDetector::isDavsSupported ( )
protected

Checks to see whether keyword detector is compatible with DAVS.

Returns
true if Davs is supported false otherwise.

◆ notifyKeyWordDetectorStateObservers()

void alexaClientSDK::acsdkKWDImplementations::AbstractKeywordDetector::notifyKeyWordDetectorStateObservers ( avsCommon::sdkInterfaces::KeyWordDetectorStateObserverInterface::KeyWordDetectorState  state)
protected

Notifies all keyword detector state observers of state changes in the derived detector.

Parameters
stateThe state of the detector.

◆ notifyKeyWordObservers()

void alexaClientSDK::acsdkKWDImplementations::AbstractKeywordDetector::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
protected

Notifies all keyword observers of the keyword detection.

Parameters
streamThe stream in which the keyword was detected.
keywordThe keyword detected.
beginIndexThe absolute begin index of the first part of the keyword found within the stream.
endIndexThe absolute end index of the last part of the keyword within the stream of the stream.
KWDMetadataWake word engine metadata.

◆ readFromStream()

ssize_t alexaClientSDK::acsdkKWDImplementations::AbstractKeywordDetector::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 
)
protected

Reads from the specified stream into the specified buffer and does the appropriate error checking and observer notifications.

Parameters
readerThe stream reader. This should be a blocking reader.
bufThe buffer to read into.
nWordsThe number of words to read.
timeoutThe amount of time to wait for data to become available.
[out]errorOccurredLets caller know if there were any errors that occurred with the read call.
Returns
The number of words successfully read.

◆ removeKeyWordDetectorStateObserver()

void alexaClientSDK::acsdkKWDImplementations::AbstractKeywordDetector::removeKeyWordDetectorStateObserver ( std::shared_ptr< avsCommon::sdkInterfaces::KeyWordDetectorStateObserverInterface keyWordDetectorStateObserver)

Removes the specified observer to the list of observers to notify of key word detector state changes.

Parameters
keyWordDetectorStateObserverThe observer to remove.

◆ removeKeyWordObserver()

void alexaClientSDK::acsdkKWDImplementations::AbstractKeywordDetector::removeKeyWordObserver ( std::shared_ptr< avsCommon::sdkInterfaces::KeyWordObserverInterface keyWordObserver)

Removes the specified observer to the list of observers to notify of key word detection events.

Parameters
keyWordObserverThe observer to remove.

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

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