AlexaClientSDK  1.25.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Classes | Functions | Variables
alexaClientSDK::kwd::test Namespace Reference

Classes

class  AbstractKeyWordDetectorTest
 
class  MockKeyWordDetector
 
class  MockKeyWordObserver
 A test observer that mocks out the KeyWordObserverInterface#onKeyWordDetected() call. More...
 
class  MockStateObserver
 A test observer that mocks out the KeyWordDetectorStateObserverInterface#onStateChanged() call. More...
 
class  SensoryKeywordTest
 
class  testKeyWordObserver
 A test observer that mocks out the KeyWordObserverInterface#onKeyWordDetected() call. More...
 
class  testStateObserver
 A test observer that mocks out the KeyWordDetectorStateObserverInterface#onStateChanged() call. More...
 

Functions

 TEST_F (SensoryKeywordTest, test_invalidStream)
 Tests that we don't get back a valid detector if an invalid stream is passed in. More...
 
 TEST_F (SensoryKeywordTest, test_incompatibleEndianness)
 Tests that we don't get back a valid detector if an invalid endianness is passed in. More...
 
 TEST_F (SensoryKeywordTest, test_getExpectedNumberOfDetectionsInFourAlexasAudioFileForOneObserver)
 Tests that we get back the expected number of keywords for the four_alexa.wav file for one keyword observer. More...
 
 TEST_F (SensoryKeywordTest, test_getExpectedNumberOfDetectionsInFourAlexasAudioFileForTwoObservers)
 Tests that we get back the expected number of keywords for the four_alexa.wav file for two keyword observers. More...
 
 TEST_F (SensoryKeywordTest, test_getExpectedNumberOfDetectionsInAlexaStopAlexaJokeAudioFileForOneObserver)
 
 TEST_F (SensoryKeywordTest, test_getActiveState)
 Tests that the detector state changes to ACTIVE when the detector is initialized properly. More...
 
 TEST_F (SensoryKeywordTest, test_getStreamClosedState)
 
 TEST_F (SensoryKeywordTest, test_getExpectedNumberOfDetectionsInAlexaStopAlexaJokeAudioFileWithRandomDataAtBeginning)
 
 TEST_F (AbstractKeyWordDetectorTest, test_addKeyWordObserver)
 
 TEST_F (AbstractKeyWordDetectorTest, test_addMultipleKeyWordObserver)
 
 TEST_F (AbstractKeyWordDetectorTest, test_removeKeyWordObserver)
 
 TEST_F (AbstractKeyWordDetectorTest, test_addStateObserver)
 
 TEST_F (AbstractKeyWordDetectorTest, test_addMultipleStateObservers)
 
 TEST_F (AbstractKeyWordDetectorTest, test_removeStateObserver)
 
 TEST_F (AbstractKeyWordDetectorTest, test_observersDontGetNotifiedOfSameStateTwice)
 

Variables

std::string inputsDirPath
 The path to the inputs folder that should be passed in via command line argument. More...
 
static const std::string MODEL_FILE = "/SensoryModels/spot-alexa-rpi-31000.snsr"
 The name of the Alexa model file for Sensory. More...
 
static const std::string KEYWORD = "alexa"
 The keyword that Sensory emits for the above model file. More...
 
static const std::string FOUR_ALEXAS_AUDIO_FILE = "/four_alexa.wav"
 The name of a test audio file. More...
 
static const std::string ALEXA_STOP_ALEXA_JOKE_AUDIO_FILE = "/alexa_stop_alexa_joke.wav"
 The name of a test audio file. More...
 
static const int SAMPLES_PER_MS = 16
 The number of samples per millisecond, assuming a sample rate of 16 kHz. More...
 
static const std::chrono::milliseconds MARGIN = std::chrono::milliseconds(250)
 The margin in milliseconds for testing indices of keyword detections. More...
 
static const AudioInputStream::Index MARGIN_IN_SAMPLES = MARGIN.count() * SAMPLES_PER_MS
 The margin in samples for testing indices of keyword detections. More...
 
static const size_t NUM_ALEXAS_IN_FOUR_ALEXAS_AUDIO_FILE = 4
 The number of "Alexa" keywords in the four_alexa.wav file. More...
 
std::vector< AudioInputStream::Index > BEGIN_INDICES_OF_ALEXAS_IN_FOUR_ALEXAS_AUDIO_FILE = {7520, 39680, 58880, 77120}
 The approximate begin indices of the four "Alexa" keywords in the four_alexa.wav file. More...
 
std::vector< AudioInputStream::Index > END_INDICES_OF_ALEXAS_IN_FOUR_ALEXAS_AUDIO_FILE = {21440, 52800, 72480, 91552}
 The approximate end indices of the four "Alexa" hotwords in the four_alexa.wav file. More...
 
static const size_t NUM_ALEXAS_IN_ALEXA_STOP_ALEXA_JOKE_AUDIO_FILE = 2
 The number of "Alexa" keywords in the alexa_stop_alexa_joke.wav file. More...
 
std::vector< AudioInputStream::Index > BEGIN_INDICES_OF_ALEXAS_IN_ALEXA_STOP_ALEXA_JOKE_AUDIO_FILE = {8000, 38240}
 The approximate begin indices of the two "Alexa" keywords in the alexa_stop_alexa_joke.wav file. More...
 
std::vector< AudioInputStream::Index > END_INDICES_OF_ALEXAS_IN_ALEXA_STOP_ALEXA_JOKE_AUDIO_FILE = {20960, 51312}
 The approximate end indices of the two "Alexa" keywords in the alexa_stop_alexa_joke.wav file. More...
 
static const avsCommon::utils::AudioFormat::Encoding COMPATIBLE_ENCODING
 The compatible encoding for Sensory. More...
 
static const avsCommon::utils::AudioFormat::Endianness COMPATIBLE_ENDIANNESS
 The compatible endianness for Sensory. More...
 
static const unsigned int COMPATIBLE_SAMPLE_RATE = 16000
 The compatible sample rate for Sensory. More...
 
static const unsigned int COMPATIBLE_SAMPLE_SIZE_IN_BITS = 16
 The compatible bits per sample for Sensory. More...
 
static const unsigned int COMPATIBLE_NUM_CHANNELS = 1
 The compatible number of channels for Sensory. More...
 
static const auto DEFAULT_TIMEOUT = std::chrono::milliseconds(4000)
 Timeout for expected callbacks. More...
 

Function Documentation

◆ TEST_F() [1/15]

alexaClientSDK::kwd::test::TEST_F ( AbstractKeyWordDetectorTest  ,
test_addKeyWordObserver   
)

◆ TEST_F() [2/15]

alexaClientSDK::kwd::test::TEST_F ( AbstractKeyWordDetectorTest  ,
test_addMultipleKeyWordObserver   
)

◆ TEST_F() [3/15]

alexaClientSDK::kwd::test::TEST_F ( AbstractKeyWordDetectorTest  ,
test_removeKeyWordObserver   
)

◆ TEST_F() [4/15]

alexaClientSDK::kwd::test::TEST_F ( AbstractKeyWordDetectorTest  ,
test_addStateObserver   
)

◆ TEST_F() [5/15]

alexaClientSDK::kwd::test::TEST_F ( AbstractKeyWordDetectorTest  ,
test_addMultipleStateObservers   
)

◆ TEST_F() [6/15]

alexaClientSDK::kwd::test::TEST_F ( AbstractKeyWordDetectorTest  ,
test_removeStateObserver   
)

◆ TEST_F() [7/15]

alexaClientSDK::kwd::test::TEST_F ( AbstractKeyWordDetectorTest  ,
test_observersDontGetNotifiedOfSameStateTwice   
)

◆ TEST_F() [8/15]

alexaClientSDK::kwd::test::TEST_F ( SensoryKeywordTest  ,
test_invalidStream   
)

Tests that we don't get back a valid detector if an invalid stream is passed in.

◆ TEST_F() [9/15]

alexaClientSDK::kwd::test::TEST_F ( SensoryKeywordTest  ,
test_incompatibleEndianness   
)

Tests that we don't get back a valid detector if an invalid endianness is passed in.

◆ TEST_F() [10/15]

alexaClientSDK::kwd::test::TEST_F ( SensoryKeywordTest  ,
test_getExpectedNumberOfDetectionsInFourAlexasAudioFileForOneObserver   
)

Tests that we get back the expected number of keywords for the four_alexa.wav file for one keyword observer.

◆ TEST_F() [11/15]

alexaClientSDK::kwd::test::TEST_F ( SensoryKeywordTest  ,
test_getExpectedNumberOfDetectionsInFourAlexasAudioFileForTwoObservers   
)

Tests that we get back the expected number of keywords for the four_alexa.wav file for two keyword observers.

◆ TEST_F() [12/15]

alexaClientSDK::kwd::test::TEST_F ( SensoryKeywordTest  ,
test_getExpectedNumberOfDetectionsInAlexaStopAlexaJokeAudioFileForOneObserver   
)

Tests that we get back the expected number of keywords for the alexa_stop_alexa_joke.wav file for one keyword observer.

◆ TEST_F() [13/15]

alexaClientSDK::kwd::test::TEST_F ( SensoryKeywordTest  ,
test_getActiveState   
)

Tests that the detector state changes to ACTIVE when the detector is initialized properly.

◆ TEST_F() [14/15]

alexaClientSDK::kwd::test::TEST_F ( SensoryKeywordTest  ,
test_getStreamClosedState   
)

Tests that the stream is closed and that the detector state changes to STREAM_CLOSED when we close the only writer of the SDS passed in and all keyword detections have occurred.

◆ TEST_F() [15/15]

alexaClientSDK::kwd::test::TEST_F ( SensoryKeywordTest  ,
test_getExpectedNumberOfDetectionsInAlexaStopAlexaJokeAudioFileWithRandomDataAtBeginning   
)

Tests that we get back the expected number of keywords for the alexa_stop_alexa_joke.wav file for one keyword observer even when SDS has other data prior to the audio file in it. This tests that the reference point that the Sensory wrapper uses is working as expected.

Variable Documentation

◆ ALEXA_STOP_ALEXA_JOKE_AUDIO_FILE

const std::string alexaClientSDK::kwd::test::ALEXA_STOP_ALEXA_JOKE_AUDIO_FILE = "/alexa_stop_alexa_joke.wav"
static

The name of a test audio file.

◆ BEGIN_INDICES_OF_ALEXAS_IN_ALEXA_STOP_ALEXA_JOKE_AUDIO_FILE

std::vector<AudioInputStream::Index> alexaClientSDK::kwd::test::BEGIN_INDICES_OF_ALEXAS_IN_ALEXA_STOP_ALEXA_JOKE_AUDIO_FILE = {8000, 38240}

The approximate begin indices of the two "Alexa" keywords in the alexa_stop_alexa_joke.wav file.

◆ BEGIN_INDICES_OF_ALEXAS_IN_FOUR_ALEXAS_AUDIO_FILE

std::vector<AudioInputStream::Index> alexaClientSDK::kwd::test::BEGIN_INDICES_OF_ALEXAS_IN_FOUR_ALEXAS_AUDIO_FILE = {7520, 39680, 58880, 77120}

The approximate begin indices of the four "Alexa" keywords in the four_alexa.wav file.

◆ COMPATIBLE_ENCODING

const avsCommon::utils::AudioFormat::Encoding alexaClientSDK::kwd::test::COMPATIBLE_ENCODING
static
Initial value:
=
avsCommon::utils::AudioFormat::Encoding::LPCM

The compatible encoding for Sensory.

◆ COMPATIBLE_ENDIANNESS

const avsCommon::utils::AudioFormat::Endianness alexaClientSDK::kwd::test::COMPATIBLE_ENDIANNESS
static
Initial value:
=
avsCommon::utils::AudioFormat::Endianness::LITTLE

The compatible endianness for Sensory.

◆ COMPATIBLE_NUM_CHANNELS

const unsigned int alexaClientSDK::kwd::test::COMPATIBLE_NUM_CHANNELS = 1
static

The compatible number of channels for Sensory.

◆ COMPATIBLE_SAMPLE_RATE

const unsigned int alexaClientSDK::kwd::test::COMPATIBLE_SAMPLE_RATE = 16000
static

The compatible sample rate for Sensory.

◆ COMPATIBLE_SAMPLE_SIZE_IN_BITS

const unsigned int alexaClientSDK::kwd::test::COMPATIBLE_SAMPLE_SIZE_IN_BITS = 16
static

The compatible bits per sample for Sensory.

◆ DEFAULT_TIMEOUT

const auto alexaClientSDK::kwd::test::DEFAULT_TIMEOUT = std::chrono::milliseconds(4000)
static

Timeout for expected callbacks.

◆ END_INDICES_OF_ALEXAS_IN_ALEXA_STOP_ALEXA_JOKE_AUDIO_FILE

std::vector<AudioInputStream::Index> alexaClientSDK::kwd::test::END_INDICES_OF_ALEXAS_IN_ALEXA_STOP_ALEXA_JOKE_AUDIO_FILE = {20960, 51312}

The approximate end indices of the two "Alexa" keywords in the alexa_stop_alexa_joke.wav file.

◆ END_INDICES_OF_ALEXAS_IN_FOUR_ALEXAS_AUDIO_FILE

std::vector<AudioInputStream::Index> alexaClientSDK::kwd::test::END_INDICES_OF_ALEXAS_IN_FOUR_ALEXAS_AUDIO_FILE = {21440, 52800, 72480, 91552}

The approximate end indices of the four "Alexa" hotwords in the four_alexa.wav file.

◆ FOUR_ALEXAS_AUDIO_FILE

const std::string alexaClientSDK::kwd::test::FOUR_ALEXAS_AUDIO_FILE = "/four_alexa.wav"
static

The name of a test audio file.

◆ inputsDirPath

std::string alexaClientSDK::kwd::test::inputsDirPath

The path to the inputs folder that should be passed in via command line argument.

◆ KEYWORD

const std::string alexaClientSDK::kwd::test::KEYWORD = "alexa"
static

The keyword that Sensory emits for the above model file.

◆ MARGIN

const std::chrono::milliseconds alexaClientSDK::kwd::test::MARGIN = std::chrono::milliseconds(250)
static

The margin in milliseconds for testing indices of keyword detections.

◆ MARGIN_IN_SAMPLES

const AudioInputStream::Index alexaClientSDK::kwd::test::MARGIN_IN_SAMPLES = MARGIN.count() * SAMPLES_PER_MS
static

The margin in samples for testing indices of keyword detections.

◆ MODEL_FILE

const std::string alexaClientSDK::kwd::test::MODEL_FILE = "/SensoryModels/spot-alexa-rpi-31000.snsr"
static

The name of the Alexa model file for Sensory.

◆ NUM_ALEXAS_IN_ALEXA_STOP_ALEXA_JOKE_AUDIO_FILE

const size_t alexaClientSDK::kwd::test::NUM_ALEXAS_IN_ALEXA_STOP_ALEXA_JOKE_AUDIO_FILE = 2
static

The number of "Alexa" keywords in the alexa_stop_alexa_joke.wav file.

◆ NUM_ALEXAS_IN_FOUR_ALEXAS_AUDIO_FILE

const size_t alexaClientSDK::kwd::test::NUM_ALEXAS_IN_FOUR_ALEXAS_AUDIO_FILE = 4
static

The number of "Alexa" keywords in the four_alexa.wav file.

◆ SAMPLES_PER_MS

const int alexaClientSDK::kwd::test::SAMPLES_PER_MS = 16
static

The number of samples per millisecond, assuming a sample rate of 16 kHz.

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