AlexaClientSDK  1.26.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Namespaces | Macros | Functions | Variables
AudioInputProcessor.cpp File Reference
#include <algorithm>
#include <cctype>
#include <functional>
#include <list>
#include <sstream>
#include <AVSCommon/AVS/CapabilityConfiguration.h>
#include <AVSCommon/AVS/FocusState.h>
#include <AVSCommon/AVS/MessageRequest.h>
#include <AVSCommon/Utils/JSON/JSONGenerator.h>
#include <AVSCommon/Utils/JSON/JSONUtils.h>
#include <AVSCommon/Utils/Logger/Logger.h>
#include <AVSCommon/Utils/Memory/Memory.h>
#include <AVSCommon/Utils/Metrics.h>
#include <AVSCommon/Utils/Metrics/DataPointDurationBuilder.h>
#include <AVSCommon/Utils/Metrics/DataPointCounterBuilder.h>
#include <AVSCommon/Utils/Metrics/DataPointStringBuilder.h>
#include <AVSCommon/Utils/Metrics/MetricEventBuilder.h>
#include <AVSCommon/Utils/String/StringUtils.h>
#include <AVSCommon/Utils/UUIDGeneration/UUIDGeneration.h>
#include <AVSCommon/AVS/Attachment/AttachmentUtils.h>
#include <Settings/SettingEventMetadata.h>
#include <Settings/SharedAVSSettingProtocol.h>
#include <SpeechEncoder/SpeechEncoder.h>
#include <AVSCommon/AVS/Attachment/DefaultAttachmentReader.h>
#include "AIP/AudioInputProcessor.h"
Include dependency graph for AudioInputProcessor.cpp:

Namespaces

 alexaClientSDK
 Whether or not curl logs should be emitted.
 
 alexaClientSDK::capabilityAgents
 
 alexaClientSDK::capabilityAgents::aip
 

Macros

#define LX(event)   alexaClientSDK::avsCommon::utils::logger::LogEntry(TAG, event)
 

Functions

static const std::string alexaClientSDK::capabilityAgents::aip::TAG ("AudioInputProcessor")
 String to identify log entries originating from this file. More...
 
static std::string alexaClientSDK::capabilityAgents::aip::encodingFormatToString (avsCommon::utils::AudioFormat::Encoding encoding)
 
static void alexaClientSDK::capabilityAgents::aip::submitMetric (const std::shared_ptr< MetricRecorderInterface > &metricRecorder, MetricEventBuilder &metricEventBuilder, const std::string &dialogRequestId="")
 
static void alexaClientSDK::capabilityAgents::aip::submitMetric (const std::shared_ptr< MetricRecorderInterface > metricRecorder, const std::string &activityName, const DataPoint &dataPoint, const std::shared_ptr< AVSDirective > &directive=nullptr)
 
static void alexaClientSDK::capabilityAgents::aip::submitInstanceEntryMetric (const std::shared_ptr< MetricRecorderInterface > &metricRecorder, const std::string &segmentId, const std::string &name, const std::map< std::string, std::string > &metadata={})
 
static std::shared_ptr< avsCommon::avs::CapabilityConfiguration > alexaClientSDK::capabilityAgents::aip::getSpeechRecognizerCapabilityConfiguration (const LocaleAssetsManagerInterface &assetsManager)
 
static bool alexaClientSDK::capabilityAgents::aip::resolveMessageRequest (const std::shared_ptr< avsCommon::avs::EditableMessageRequest > &request, const std::string &resolveKey, AudioInputProcessor::EncodingFormatResponse encodingFormats, const std::unordered_map< std::string, std::vector< std::shared_ptr< avsCommon::avs::MessageRequest::NamedReader >>> &attachmentReaders, const std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > &metricRecorder)
 
std::string alexaClientSDK::capabilityAgents::aip::generateSupportedWakeWordsJson (const std::string &scope, const LocaleAssetsManagerInterface::WakeWordsSets &wakeWordsCombination)
 
bool alexaClientSDK::capabilityAgents::aip::resolveMessageRequest (const std::shared_ptr< EditableMessageRequest > &request, const std::string &resolveKey, AudioInputProcessor::EncodingFormatResponse encodingFormats, const std::unordered_map< std::string, std::vector< std::shared_ptr< MessageRequest::NamedReader >>> &attachmentReaders, const std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > &metricRecorder)
 

Variables

static const std::string alexaClientSDK::capabilityAgents::aip::SPEECHRECOGNIZER_CAPABILITY_INTERFACE_TYPE = "AlexaInterface"
 
static const std::string alexaClientSDK::capabilityAgents::aip::SPEECHRECOGNIZER_CAPABILITY_INTERFACE_NAME = "SpeechRecognizer"
 SpeechRecognizer interface name. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::SPEECHRECOGNIZER_CAPABILITY_INTERFACE_VERSION = "2.3"
 SpeechRecognizer interface version. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::CAPABILITY_INTERFACE_CONFIGURATIONS_KEY = "configurations"
 Configuration key used to give more details about the device configuration. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::CAPABILITY_INTERFACE_WAKE_WORDS_KEY = "wakeWords"
 Supported wake words key. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::CAPABILITY_MAXIMUM_CONCURRENT_WAKEWORDS_KEY = "maximumConcurrentWakeWords"
 Supported maximum number of concurrent wakewords key. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::CAPABILITY_INTERFACE_SCOPES_KEY = "scopes"
 The scope key for each wake words set. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::CAPABILITY_INTERFACE_VALUES_KEY = "values"
 The wake word values for a given scope. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::CAPABILITY_INTERFACE_DEFAULT_LOCALE = "DEFAULT"
 The scope configuration used as default locale wake words support. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::CHANNEL_NAME = FocusManagerInterface::DIALOG_CHANNEL_NAME
 The name of the FocusManager channel used by AudioInputProvider. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::NAMESPACE = "SpeechRecognizer"
 The namespace for this capability agent. More...
 
static const avsCommon::avs::NamespaceAndName alexaClientSDK::capabilityAgents::aip::STOP_CAPTURE {NAMESPACE, "StopCapture"}
 The StopCapture directive signature. More...
 
static const avsCommon::avs::NamespaceAndName alexaClientSDK::capabilityAgents::aip::EXPECT_SPEECH {NAMESPACE, "ExpectSpeech"}
 The ExpectSpeech directive signature. More...
 
static const avsCommon::avs::NamespaceAndName alexaClientSDK::capabilityAgents::aip::SET_END_OF_SPEECH_OFFSET {NAMESPACE, "SetEndOfSpeechOffset"}
 The SetEndOfSpeechOffset directive signature. More...
 
static const avsCommon::avs::NamespaceAndName alexaClientSDK::capabilityAgents::aip::SET_WAKE_WORD_CONFIRMATION {NAMESPACE, "SetWakeWordConfirmation"}
 The SetWakeWordConfirmation directive signature. More...
 
static const avsCommon::avs::NamespaceAndName alexaClientSDK::capabilityAgents::aip::SET_SPEECH_CONFIRMATION {NAMESPACE, "SetSpeechConfirmation"}
 The SetSpeechConfirmation directive signature. More...
 
static const avsCommon::avs::NamespaceAndName alexaClientSDK::capabilityAgents::aip::SET_WAKE_WORDS {NAMESPACE, "SetWakeWords"}
 The SetWakeWords directive signature. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::INITIATOR_KEY = "initiator"
 The field identifying the initiator. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::PROFILE_KEY = "profile"
 The field identifying the initiator's profile. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::FORMAT_KEY = "format"
 The field identifying the initiator's format. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::TYPE_KEY = "type"
 The field identifying the initiator's type. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::TOKEN_KEY = "token"
 The field identifying the initiator's token. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::PAYLOAD_KEY = "payload"
 The field identifying the initiator's payload. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::WAKEWORD_INDICES_KEY = "wakeWordIndices"
 The field identifying the initiator's wakeword indices. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::START_INDEX_KEY = "startIndexInSamples"
 The field identifying the initiator's wakeword start index. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::END_INDEX_KEY = "endIndexInSamples"
 The field identifying the initiator's wakeword end index. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::WAKE_WORD_KEY = "wakeWord"
 The field identifying the initiator's wake word. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::AUDIO_ATTACHMENT_FIELD_NAME = "audio"
 The field name for the user voice attachment. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::KWD_METADATA_FIELD_NAME = "wakewordEngineMetadata"
 The field name for the wake word engine metadata. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::START_OF_SPEECH_TIMESTAMP_FIELD_NAME = "startOfSpeechTimestamp"
 
static const std::string alexaClientSDK::capabilityAgents::aip::END_OF_SPEECH_OFFSET_FIELD_NAME = "endOfSpeechOffsetInMilliseconds"
 The field name for the end of speech offset, reported in milliseconds, as part of SetEndOfSpeechOffset payload. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::WAKE_WORD_CONFIRMATION_CHANGED_EVENT_NAME = "WakeWordConfirmationChanged"
 The value of the WakeWordConfirmationChanged Event name. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::WAKE_WORD_CONFIRMATION_REPORT_EVENT_NAME = "WakeWordConfirmationReport"
 The value of the WakeWordConfirmationReport Event name. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::WAKE_WORD_CONFIRMATION_PAYLOAD_KEY = "wakeWordConfirmation"
 The value of the payload key for wakeWordConfirmation. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::SPEECH_CONFIRMATION_CHANGED_EVENT_NAME = "SpeechConfirmationChanged"
 The value of the SpeechConfirmationChanged Event name. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::SPEECH_CONFIRMATION_REPORT_EVENT_NAME = "SpeechConfirmationReport"
 The value of the SpeechConfirmationReport Event name. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::SPEECH_CONFIRMATION_PAYLOAD_KEY = "speechConfirmation"
 The value of the payload key for speechConfirmation. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::WAKE_WORDS_CHANGED_EVENT_NAME = "WakeWordsChanged"
 The value of the WakeWordsChanged Event name. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::WAKE_WORDS_REPORT_EVENT_NAME = "WakeWordsReport"
 The value of the WakeWordsReport Event name. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::WAKE_WORDS_PAYLOAD_KEY = "wakeWords"
 The value of the payload key for wake words. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::POWER_RESOURCE_COMPONENT_NAME = "AudioInputProcessor"
 The component name of power management. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::METRIC_ACTIVITY_NAME_PREFIX_AIP = "AIP-"
 Metric Activity Name Prefix for AIP metric source. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::START_OF_UTTERANCE = "START_OF_UTTERANCE"
 Start of Utterance Activity Name for AIP metric source. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::START_OF_UTTERANCE_ACTIVITY_NAME = METRIC_ACTIVITY_NAME_PREFIX_AIP + START_OF_UTTERANCE
 
static const std::string alexaClientSDK::capabilityAgents::aip::WAKEWORD_DETECTION_SEGMENT_UPLOADED_OPUS = "AIP_WAKEWORD_DETECTION_SEGMENT_UPLOADED_OPUS"
 Name of audio bytes stream metric Opus. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::WAKEWORD_DETECTION_SEGMENT_UPLOADED_PCM = "AIP_WAKEWORD_DETECTION_SEGMENT_UPLOADED_PCM"
 Name of audio bytes stream metric PCM. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::RECOGNIZE_START_SEND_MESSAGE = "RECOGNIZE_EVENT_IS_BUILT"
 Recognize EVENT is built for AIP metric source. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::START_OF_STREAM_TIMESTAMP = "START_OF_STREAM_TIMESTAMP"
 Wakeword Activity Name for AIP metric source. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::WW_DURATION = "WW_DURATION"
 
static const std::string alexaClientSDK::capabilityAgents::aip::WW_DURATION_ACTIVITY_NAME = METRIC_ACTIVITY_NAME_PREFIX_AIP + WW_DURATION
 
static const std::string alexaClientSDK::capabilityAgents::aip::STOP_CAPTURE_RECEIVED = "STOP_CAPTURE"
 Stop Capture Received Activity Name for AIP metric source. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::STOP_CAPTURE_RECEIVED_ACTIVITY_NAME = METRIC_ACTIVITY_NAME_PREFIX_AIP + STOP_CAPTURE_RECEIVED
 
static const std::string alexaClientSDK::capabilityAgents::aip::ACQUIRE_POWER_RESOURCE = "ACQUIRE_POWER_RESOURCE"
 The duration metric for acquire power resource. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::ACQUIRE_POWER_RESOURCE_ACTIVITY = METRIC_ACTIVITY_NAME_PREFIX_AIP + ACQUIRE_POWER_RESOURCE
 
static const std::string alexaClientSDK::capabilityAgents::aip::RELEASE_POWER_RESOURCE = "RELEASE_POWER_RESOURCE"
 The duration metric for release power resource. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::RELEASE_POWER_RESOURCE_ACTIVITY = METRIC_ACTIVITY_NAME_PREFIX_AIP + RELEASE_POWER_RESOURCE
 
static const std::string alexaClientSDK::capabilityAgents::aip::END_OF_SPEECH_OFFSET_RECEIVED = "END_OF_SPEECH_OFFSET"
 End of Speech Offset Received Activity Name for AIP metric source. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::END_OF_SPEECH_OFFSET_RECEIVED_ACTIVITY_NAME
 
static const std::string alexaClientSDK::capabilityAgents::aip::STOP_CAPTURE_TO_END_OF_SPEECH_METRIC_NAME = "STOP_CAPTURE_TO_END_OF_SPEECH"
 The duration metric for short time out. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::STOP_CAPTURE_TO_END_OF_SPEECH_ACTIVITY_NAME
 
static const std::string alexaClientSDK::capabilityAgents::aip::INITIATOR_PREFIX = "INITIATOR_"
 The recognize request initiator metric. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::INITIATOR_ACTIVITY_NAME_PREFIX = METRIC_ACTIVITY_NAME_PREFIX_AIP + INITIATOR_PREFIX
 
static const std::string alexaClientSDK::capabilityAgents::aip::AUDIO_ENCODING_FORMAT_METRIC_NAME = "AUDIO_ENCODING_FORMAT"
 AudioEncodingFormat Activity Name for AIP metric source. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::AUDIO_ENCODING_FORMAT_ACTIVITY_NAME
 
static const std::string alexaClientSDK::capabilityAgents::aip::AUDIO_ENCODING_FORMAT_OPUS = "OPUSAudioEncoding"
 
static const std::string alexaClientSDK::capabilityAgents::aip::AUDIO_ENCODING_FORMAT_LPCM = "LPCMAudioEncoding"
 
static const std::string alexaClientSDK::capabilityAgents::aip::DEFAULT_RESOLVE_KEY = "DEFAULT_RESOLVE_KEY"
 The default resolveKey used as a placeholder when only one encoding format is configured for AudioInputProcessor. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::ENTRY_METRIC_ACTOR_NAME = "AudioInputProcessor"
 Keys for instance entry metric specific fields. More...
 
static const std::string alexaClientSDK::capabilityAgents::aip::ENTRY_METRIC_ACTIVITY_NAME = METRIC_ACTIVITY_NAME_PREFIX_AIP + ENTRY_METRIC_ACTOR_NAME
 
static const std::string alexaClientSDK::capabilityAgents::aip::ENTRY_METRIC_KEY_SEGMENT_ID = "segment_id"
 
static const std::string alexaClientSDK::capabilityAgents::aip::ENTRY_METRIC_KEY_ACTOR = "actor"
 
static const std::string alexaClientSDK::capabilityAgents::aip::ENTRY_METRIC_KEY_ENTRY_TYPE = "entry_type"
 
static const std::string alexaClientSDK::capabilityAgents::aip::ENTRY_METRIC_KEY_ENTRY_NAME = "entry_name"
 
static const std::string alexaClientSDK::capabilityAgents::aip::ENTRY_METRIC_NAME_STATE_CHANGE = "StateChange"
 
static const std::chrono::milliseconds alexaClientSDK::capabilityAgents::aip::PREROLL_DURATION = std::chrono::milliseconds(500)
 Preroll duration is a fixed 500ms. More...
 
static const int alexaClientSDK::capabilityAgents::aip::MILLISECONDS_PER_SECOND = 1000
 
static const int alexaClientSDK::capabilityAgents::aip::WAKEWORD_DETECTION_SEGMENT_SIZE_BYTES_OPUS = 5209
 Threshold number of bytes for OPUS Encoded Wakeword detection. More...
 
static const int alexaClientSDK::capabilityAgents::aip::WAKEWORD_DETECTION_SEGMENT_SIZE_BYTES_PCM = 40480
 Threshold number of bytes for PCM Encoded Wakeword detection. More...
 

Macro Definition Documentation

◆ LX

#define LX (   event)    alexaClientSDK::avsCommon::utils::logger::LogEntry(TAG, event)

Create a LogEntry using this file's TAG and the specified event string.

Parameters
Theevent string for this LogEntry.

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