AlexaClientSDK  1.20.1
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
alexaClientSDK::capabilityAgents::aip::AudioInputProcessor Class Reference

#include <AudioInputProcessor.h>

Inheritance diagram for alexaClientSDK::capabilityAgents::aip::AudioInputProcessor:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::capabilityAgents::aip::AudioInputProcessor:
Collaboration graph
[legend]

Public Types

using ObserverInterface = avsCommon::sdkInterfaces::AudioInputProcessorObserverInterface
 Alias to the AudioInputProcessorObserverInterface for brevity. More...
 
- Public Types inherited from alexaClientSDK::avsCommon::sdkInterfaces::DialogUXStateObserverInterface
enum  DialogUXState {
  DialogUXState::IDLE, DialogUXState::LISTENING, DialogUXState::EXPECTING, DialogUXState::THINKING,
  DialogUXState::SPEAKING, DialogUXState::FINISHED
}
 The different dialog specific AVS UX states. More...
 
- Public Types inherited from alexaClientSDK::avsCommon::sdkInterfaces::MessageRequestObserverInterface
enum  Status {
  Status::PENDING, Status::SUCCESS, Status::SUCCESS_ACCEPTED, Status::SUCCESS_NO_CONTENT,
  Status::NOT_CONNECTED, Status::NOT_SYNCHRONIZED, Status::TIMEDOUT, Status::PROTOCOL_ERROR,
  Status::INTERNAL_ERROR, Status::SERVER_INTERNAL_ERROR_V2, Status::REFUSED, Status::CANCELED,
  Status::THROTTLED, Status::INVALID_AUTH, Status::BAD_REQUEST, Status::SERVER_OTHER_ERROR
}
 

Public Member Functions

void addObserver (std::shared_ptr< ObserverInterface > observer)
 
void removeObserver (std::shared_ptr< ObserverInterface > observer)
 
std::future< bool > recognize (AudioProvider audioProvider, Initiator initiator, std::chrono::steady_clock::time_point startOfSpeechTimestamp=std::chrono::steady_clock::now(), avsCommon::avs::AudioInputStream::Index begin=INVALID_INDEX, avsCommon::avs::AudioInputStream::Index keywordEnd=INVALID_INDEX, std::string keyword="", std::shared_ptr< const std::vector< char >> KWDMetadata=nullptr, const std::string &initiatorToken="")
 
std::future< bool > stopCapture ()
 
std::future< void > resetState ()
 
ContextRequesterInterface Functions
void onContextAvailable (const std::string &jsonContext) override
 
void onContextFailure (const avsCommon::sdkInterfaces::ContextRequestError error) override
 
MessageRequestObserverInterface Functions
void onSendCompleted (avsCommon::sdkInterfaces::MessageRequestObserverInterface::Status status) override
 
void onExceptionReceived (const std::string &exceptionMessage) override
 
CapabilityAgent/DirectiveHandlerInterface Functions
void handleDirectiveImmediately (std::shared_ptr< avsCommon::avs::AVSDirective > directive) override
 
void preHandleDirective (std::shared_ptr< DirectiveInfo > info) override
 
void handleDirective (std::shared_ptr< DirectiveInfo > info) override
 
void cancelDirective (std::shared_ptr< DirectiveInfo > info) override
 
void onDeregistered () override
 
avsCommon::avs::DirectiveHandlerConfiguration getConfiguration () const override
 
ChannelObserverInterface Functions
void onFocusChanged (avsCommon::avs::FocusState newFocus, avsCommon::avs::MixingBehavior behavior) override
 
DialogUXStateObserverInterface Functions
void onDialogUXStateChanged (avsCommon::sdkInterfaces::DialogUXStateObserverInterface::DialogUXState newState) override
 
CapabilityConfigurationInterface Functions
std::unordered_set< std::shared_ptr< avsCommon::avs::CapabilityConfiguration > > getCapabilityConfigurations () override
 
InternetConnectionObserverInterface Functions
void onConnectionStatusChanged (bool connected) override
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::avs::CapabilityAgent
virtual ~CapabilityAgent ()=default
 
void preHandleDirective (std::shared_ptr< AVSDirective > directive, std::unique_ptr< sdkInterfaces::DirectiveHandlerResultInterface > result) override final
 
bool handleDirective (const std::string &messageId) override final
 
void cancelDirective (const std::string &messageId) override final
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::DirectiveHandlerInterface
virtual ~DirectiveHandlerInterface ()=default
 
virtual void handleDirectiveImmediately (std::shared_ptr< avsCommon::avs::AVSDirective > directive)=0
 
virtual void preHandleDirective (std::shared_ptr< avsCommon::avs::AVSDirective > directive, std::unique_ptr< DirectiveHandlerResultInterface > result)=0
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::ChannelObserverInterface
virtual ~ChannelObserverInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::StateProviderInterface
virtual ~StateProviderInterface ()=default
 
virtual void provideState (const avs::NamespaceAndName &stateProviderName, const ContextRequestToken stateRequestToken)
 
virtual void provideState (const avs::CapabilityTag &stateProviderName, const ContextRequestToken stateRequestToken)
 
virtual bool canStateBeRetrieved ()
 
virtual bool hasReportableStateProperties ()
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::ContextRequesterInterface
virtual ~ContextRequesterInterface ()=default
 
virtual void onContextAvailable (const endpoints::EndpointIdentifier &endpointId, const avs::AVSContext &endpointContext, ContextRequestToken requestToken)
 
virtual void onContextFailure (const ContextRequestError error, ContextRequestToken token)
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::CapabilityConfigurationInterface
virtual ~CapabilityConfigurationInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::DialogUXStateObserverInterface
virtual ~DialogUXStateObserverInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::MessageRequestObserverInterface
virtual ~MessageRequestObserverInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::InternetConnectionObserverInterface
virtual ~InternetConnectionObserverInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::utils::RequiresShutdown
 RequiresShutdown (const std::string &name)
 
virtual ~RequiresShutdown ()
 Destructor. More...
 
const std::string & name () const
 
void shutdown ()
 
bool isShutdown () const
 

Static Public Member Functions

static std::shared_ptr< AudioInputProcessorcreate (std::shared_ptr< avsCommon::sdkInterfaces::DirectiveSequencerInterface > directiveSequencer, std::shared_ptr< avsCommon::sdkInterfaces::MessageSenderInterface > messageSender, std::shared_ptr< avsCommon::sdkInterfaces::ContextManagerInterface > contextManager, std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerInterface > focusManager, std::shared_ptr< avsCommon::avs::DialogUXStateAggregator > dialogUXStateAggregator, std::shared_ptr< avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface > exceptionEncounteredSender, std::shared_ptr< avsCommon::sdkInterfaces::UserInactivityMonitorInterface > userInactivityNotifier, std::shared_ptr< avsCommon::sdkInterfaces::SystemSoundPlayerInterface > systemSoundPlayer, const std::shared_ptr< avsCommon::sdkInterfaces::LocaleAssetsManagerInterface > &assetsManager, std::shared_ptr< settings::WakeWordConfirmationSetting > wakeWordConfirmation, std::shared_ptr< settings::SpeechConfirmationSetting > speechConfirmation, std::shared_ptr< settings::WakeWordsSetting > wakeWordsSetting=nullptr, std::shared_ptr< speechencoder::SpeechEncoder > speechEncoder=nullptr, AudioProvider defaultAudioProvider=AudioProvider::null(), std::shared_ptr< avsCommon::sdkInterfaces::PowerResourceManagerInterface > powerResourceManager=nullptr, std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder=nullptr)
 
static settings::SettingEventMetadata getWakeWordsEventsMetadata ()
 
static settings::SettingEventMetadata getWakeWordConfirmationMetadata ()
 
static settings::SettingEventMetadata getSpeechConfirmationMetadata ()
 
- Static Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::DialogUXStateObserverInterface
static std::string stateToString (DialogUXState state)
 

Static Public Attributes

static constexpr const char * KEYWORD_TEXT_STOP = "STOP"
 A special keyword sent by supported wakeword engines for "Alexa, Stop". More...
 
static const auto INVALID_INDEX = std::numeric_limits<avsCommon::avs::AudioInputStream::Index>::max()
 A reserved Index value which is considered invalid. More...
 

Additional Inherited Members

- Protected Member Functions inherited from alexaClientSDK::avsCommon::avs::CapabilityAgent
 CapabilityAgent (const std::string &nameSpace, std::shared_ptr< sdkInterfaces::ExceptionEncounteredSenderInterface > exceptionEncounteredSender)
 
virtual std::shared_ptr< DirectiveInfocreateDirectiveInfo (std::shared_ptr< AVSDirective > directive, std::unique_ptr< sdkInterfaces::DirectiveHandlerResultInterface > result)
 
void removeDirective (const std::string &messageId)
 
void sendExceptionEncounteredAndReportFailed (std::shared_ptr< DirectiveInfo > info, const std::string &message, avsCommon::avs::ExceptionErrorType type=avsCommon::avs::ExceptionErrorType::INTERNAL_ERROR)
 
const std::pair< std::string, std::string > buildJsonEventString (const std::string &eventName, const std::string &dialogRequestIdString="", const std::string &payload="{}", const std::string &context="") const
 
- Protected Attributes inherited from alexaClientSDK::avsCommon::avs::CapabilityAgent
const std::string m_namespace
 The namespace of the capability agent. More...
 
std::shared_ptr< sdkInterfaces::ExceptionEncounteredSenderInterfacem_exceptionEncounteredSender
 Object to use to send exceptionEncountered messages. More...
 

Detailed Description

This class implements a SpeechRecognizer capability agent.

See also
https://developer.amazon.com/public/solutions/alexa/alexa-voice-service/reference/speechrecognizer

AudioInputProcessor is a top-level component which should be instantiated in application code, and connected up to other interfaces in the Alexa Client SDK. Interfaces which are used directly by the AudioInputProcessor are passed directly to its create() function. To start sending an audio event, application code should call one of the recognize() functions. To stop sending audio, application code should call the stopCapture() function. Application code can also register objects which implement the ObserverInterface to receive notifications when the AudioInputProcessor state changes.

Member Typedef Documentation

◆ ObserverInterface

Alias to the AudioInputProcessorObserverInterface for brevity.

Member Function Documentation

◆ addObserver()

void alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::addObserver ( std::shared_ptr< ObserverInterface observer)

Adds an observer to be notified of AudioInputProcessor state changes.

Parameters
observerThe observer object to add.

◆ cancelDirective()

void alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::cancelDirective ( std::shared_ptr< DirectiveInfo info)
overridevirtual

Cancel an ongoing preHandleDirective() or handleDirective() operation for the AVSDirective in . Once this has been called the CapabilityAgent should not expect to receive further calls regarding this directive.

Note
The implementation of this method MUST be thread-safe.
The implementation of this method MUST return quickly. Failure to do so blocks the processing of subsequent AVSDirectives.
Parameters
infoThe DirectiveInfo instance for the AVSDirective to process.

Implements alexaClientSDK::avsCommon::avs::CapabilityAgent.

◆ create()

std::shared_ptr< AudioInputProcessor > alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::create ( std::shared_ptr< avsCommon::sdkInterfaces::DirectiveSequencerInterface directiveSequencer,
std::shared_ptr< avsCommon::sdkInterfaces::MessageSenderInterface messageSender,
std::shared_ptr< avsCommon::sdkInterfaces::ContextManagerInterface contextManager,
std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerInterface focusManager,
std::shared_ptr< avsCommon::avs::DialogUXStateAggregator dialogUXStateAggregator,
std::shared_ptr< avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface exceptionEncounteredSender,
std::shared_ptr< avsCommon::sdkInterfaces::UserInactivityMonitorInterface userInactivityNotifier,
std::shared_ptr< avsCommon::sdkInterfaces::SystemSoundPlayerInterface systemSoundPlayer,
const std::shared_ptr< avsCommon::sdkInterfaces::LocaleAssetsManagerInterface > &  assetsManager,
std::shared_ptr< settings::WakeWordConfirmationSetting wakeWordConfirmation,
std::shared_ptr< settings::SpeechConfirmationSetting speechConfirmation,
std::shared_ptr< settings::WakeWordsSetting wakeWordsSetting = nullptr,
std::shared_ptr< speechencoder::SpeechEncoder speechEncoder = nullptr,
AudioProvider  defaultAudioProvider = AudioProvider::null(),
std::shared_ptr< avsCommon::sdkInterfaces::PowerResourceManagerInterface powerResourceManager = nullptr,
std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface metricRecorder = nullptr 
)
static

Creates a new AudioInputProcessor instance.

Parameters
directiveSequencerThe Directive Sequencer to register with for receiving directives.
messageSenderThe object to use for sending events.
contextManagerThe AVS Context manager used to generate system context for events.
focusManagerThe channel focus manager used to manage usage of the dialog channel.
dialogUXStateAggregatorThe dialog state aggregator which tracks UX states related to dialog.
exceptionEncounteredSenderThe object to use for sending AVS Exception messages.
userInactivityNotifierThe object to use for resetting user inactivity.
systemSoundPlayerThe instance of the system sound player.
assetsManagerResponsible for retrieving and changing the wake words and locale.
wakeWordConfirmationThe wake word confirmation setting.
speechConfirmationThe end of speech confirmation setting.
wakeWordsSettingThe setting that represents the enabled wake words. This parameter is required if this device supports wake words.
speechEncoderThe Speech Encoder used to encode audio inputs. This parameter is optional and defaults to nullptr, which disable the encoding feature.
defaultAudioProviderA default avsCommon::AudioProvider to use for ExpectSpeech if the previous provider is not readable (avsCommon::AudioProvider::alwaysReadable). This parameter is optional and defaults to an invalid avsCommon::AudioProvider.
powerResourceManagerPower Resource Manager.
metricRecorderThe metric recorder.
Returns
A std::shared_ptr to the new AudioInputProcessor instance.

◆ getCapabilityConfigurations()

std::unordered_set< std::shared_ptr< avsCommon::avs::CapabilityConfiguration > > alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::getCapabilityConfigurations ( )
overridevirtual

Returns the configurations of the capability interfaces being implemented.

Returns
A set of CapabilityConfigurations

Implements alexaClientSDK::avsCommon::sdkInterfaces::CapabilityConfigurationInterface.

◆ getConfiguration()

avsCommon::avs::DirectiveHandlerConfiguration alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::getConfiguration ( ) const
overridevirtual

Returns the configuration of the directive handler.

The configuration consists of multiple directive routing rules and their respective blocking policy. The directives will be matched from the most specific rule (with all fields defined) to the least specific rule (which only matches the directive endpointId).

Returns
The avs::DirectiveHandlerConfiguration of the handler.

Implements alexaClientSDK::avsCommon::sdkInterfaces::DirectiveHandlerInterface.

◆ getSpeechConfirmationMetadata()

settings::SettingEventMetadata alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::getSpeechConfirmationMetadata ( )
static

Gets the speech confirmation events metadata.

Returns
The speech confirmation event metadata.

◆ getWakeWordConfirmationMetadata()

settings::SettingEventMetadata alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::getWakeWordConfirmationMetadata ( )
static

Gets the wake word confirmation events metadata.

Returns
The wake word confirmation event metadata.

◆ getWakeWordsEventsMetadata()

settings::SettingEventMetadata alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::getWakeWordsEventsMetadata ( )
static

Gets the wake words events metadata.

Returns
The wake words events metadata.

◆ handleDirective()

void alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::handleDirective ( std::shared_ptr< DirectiveInfo info)
overridevirtual

Handle the action specified by the AVSDirective in info. The handling of subsequent directives with the same DialogRequestId may be blocked until the DirectiveHandler calls the setSucceeded() method of the DirectiveHandlingResult present in info. If handling of this directive fails setFailed() should be called to indicate a failure.

Note
The implementation of this method MUST be thread-safe.
The implementation of this method MUST return quickly. Failure to do so blocks the processing of subsequent AVSDirectives.
Parameters
infoThe DirectiveInfo instance for the AVSDirective to process.

Implements alexaClientSDK::avsCommon::avs::CapabilityAgent.

◆ handleDirectiveImmediately()

void alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::handleDirectiveImmediately ( std::shared_ptr< avsCommon::avs::AVSDirective directive)
override

◆ onConnectionStatusChanged()

void alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::onConnectionStatusChanged ( bool  connected)
overridevirtual

Take necessary actions as a result of an internet connection change.

Parameters
connectedWhether or not we are currently connected to the internet.

Implements alexaClientSDK::avsCommon::sdkInterfaces::InternetConnectionObserverInterface.

◆ onContextAvailable()

void alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::onContextAvailable ( const std::string &  jsonContext)
overridevirtual

This is called by the ContextManager once the context is ready and available.

Deprecated:
This method is being deprecated since it cannot specify the source endpoint.
Note
The ContextRequester should perform minimum processing and return quickly. Otherwise it will block the processing of updating the of other ContextProviders.
Parameters
jsonContextContext information.Context provided is of the format {"context"[{...}, {...}]}

Reimplemented from alexaClientSDK::avsCommon::sdkInterfaces::ContextRequesterInterface.

◆ onContextFailure()

void alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::onContextFailure ( const avsCommon::sdkInterfaces::ContextRequestError  error)
overridevirtual

The contextManager calls this if it is unable to process a getContext request successfully.

Deprecated:
This method is being deprecated since it cannot specify the optional token.
Note
The ContextRequester should perform minimum processing and return quickly. Otherwise it will block the processing of updating the of other ContextProviders.
Parameters
errorThe reason why the getContext request failed.

Reimplemented from alexaClientSDK::avsCommon::sdkInterfaces::ContextRequesterInterface.

◆ onDeregistered()

void alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::onDeregistered ( )
overridevirtual

Notification that this handler has been de-registered and will not receive any more calls.

Reimplemented from alexaClientSDK::avsCommon::avs::CapabilityAgent.

◆ onDialogUXStateChanged()

void alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::onDialogUXStateChanged ( avsCommon::sdkInterfaces::DialogUXStateObserverInterface::DialogUXState  newState)
overridevirtual

This function is called whenever the AVS UX dialog state of the system changes. This function will block processing of other state changes, so any implementation of this should return quickly.

Parameters
newStateThe new dialog specific AVS UX state.

Implements alexaClientSDK::avsCommon::sdkInterfaces::DialogUXStateObserverInterface.

◆ onExceptionReceived()

void alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::onExceptionReceived ( const std::string &  exceptionMessage)
overridevirtual

◆ onFocusChanged()

void alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::onFocusChanged ( avsCommon::avs::FocusState  newFocus,
avsCommon::avs::MixingBehavior  behavior 
)
overridevirtual

Used to notify the observer of the Channel of focus changes. Once called, the client should make a user observable change only and return immediately. Any additional work that needs to be done should be done on a separate thread or after returning. "User observable change" here refers to events that the end user of the product can visibly see or hear. For example, Alexa speech or music playing would be examples of user observable changes. Other work, such as database storing, logging, or communicating via network should be done on a different thread. Not doing so could result in delays for other clients trying to access the Channel.

Parameters
newFocusThe new Focus of the channel.
behaviorThe mixingBehavior for the ChannelObserver to take as per the interrupt model
Note
when newFocus is FocusState::FOREGROUND, the MixingBehavior shall be guaranteed to be PRIMARY when newFocus is FocusState::NONE, the MixingBehavior shall be guaranteed to be MUST_STOP

Reimplemented from alexaClientSDK::avsCommon::avs::CapabilityAgent.

◆ onSendCompleted()

void alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::onSendCompleted ( avsCommon::sdkInterfaces::MessageRequestObserverInterface::Status  status)
overridevirtual

◆ preHandleDirective()

void alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::preHandleDirective ( std::shared_ptr< DirectiveInfo info)
overridevirtual

Notification that a directive has arrived. This notification gives the DirectiveHandler a chance to prepare for handling of an AVSDirective. If an error occurs during the pre-Handling phase and that error should cancel the handling of subsequent AVSDirectives with the same DialogRequestId, the DirectiveHandler should call the setFailed method on the result instance passed in to this call.

Note
The implementation of this method MUST be thread-safe.
The implementation of this method MUST return quickly. Failure to do so blocks the processing of subsequent AVSDirectives.
Parameters
infoThe DirectiveInfo instance for the AVSDirective to process.

Implements alexaClientSDK::avsCommon::avs::CapabilityAgent.

◆ recognize()

std::future< bool > alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::recognize ( AudioProvider  audioProvider,
Initiator  initiator,
std::chrono::steady_clock::time_point  startOfSpeechTimestamp = std::chrono::steady_clock::now(),
avsCommon::avs::AudioInputStream::Index  begin = INVALID_INDEX,
avsCommon::avs::AudioInputStream::Index  keywordEnd = INVALID_INDEX,
std::string  keyword = "",
std::shared_ptr< const std::vector< char >>  KWDMetadata = nullptr,
const std::string &  initiatorToken = "" 
)

This function asks the AudioInputProcessor to send a Recognize Event to AVS and start streaming from audioProvider, which transitions it to the RECOGNIZING state. This function can be called in any state except BUSY, however the flags in AudioProvider will dictate whether the call is allowed to override an ongoing Recognize Event. If the flags do not allow an override, no event will be sent, no state change will occur, and the function will fail.

A special case is that the function will also fail if the keyword passed in is equal to KEYWORD_TEXT_STOP. This check is case insensitive.

Note
This function will not pass the audio stream to MessageSenderInterface to start streaming if the the start index or any subsequent data has already expired from the buffer. In addition, it is assumed that MessageSenderInterface will stop streaming immediately if it detects an overrun, and notify AIP of this condition (through a MessageRequest callback). These requirements ensure that the begin and keywordEnd indices will remain accurate for the actual audio samples sent to AVS.

False-wakeword detection in the cloud will be used when all of the following requirements are met:

  • initiator == Initiator::WAKEWORD
  • begin != INVALID_INDEX
  • end != INVALID_INDEX
  • !keyword.empty()

If all of the above requirements are met, audio steaming will start between 0 and 500ms before begin, and the cloud will perform additional verification of the wakeword audio before proceeding to recognize the subsequent audio.

Parameters
audioProviderThe AudioProvider to stream audio from.
initiatorThe type of interface that initiated this recognize event.
startOfSpeechTimestampMoment in time when user started talking to Alexa. This parameter is optional and it is used to measure user perceived latency.
beginThe Index in audioProvider.stream where audio streaming should begin. This parameter is optional, and defaults to INVALID_INDEX. When this parameter is not specified, recognize() will stream audio starting at the time of the recognize() call. If the initiator is WAKEWORD, and this and keywordEnd are specified, streaming will begin between 0 and 500ms prior to the Index specified by this parameter to attempt false wakeword validation.
keywordEndThe Index in audioProvider.stream where the wakeword ends. This parameter is optional, and defaults to INVALID_INDEX. This parameter is ignored if initiator is not WAKEWORD.
keywordThe text of the keyword which was recognized. This parameter is optional, and defaults to an empty string. This parameter is ignored if initiator is not WAKEWORD. The only value currently accepted by AVS for keyword is "ALEXA". See https://developer.amazon.com/public/solutions/alexa/alexa-voice-service/reference/context#recognizerstate
KWDMetadataWake word engine metadata.
initiatorTokenAn optional opaque string associated with the interaction.
Returns
A future which is true if the Recognize Event was started successfully, else false.

◆ removeObserver()

void alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::removeObserver ( std::shared_ptr< ObserverInterface observer)

Removes an observer from the set of observers to be notified of AudioInputProcessor state changes.

Note
This is a synchronous call which can not be made by an observer callback. Attempting to call removeObserver() from ObserverInterface::onStateChanged() will result in a deadlock.
Parameters
observerThe observer object to remove.

◆ resetState()

std::future< void > alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::resetState ( )

This function forces the AudioInputProcessor back to the IDLE state. This function can be called in any state, and will end any Event which is currently in progress.

Returns
A future which indicates when the AudioInputProcessor is back to the IDLE state.

◆ stopCapture()

std::future< bool > alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::stopCapture ( )

This function asks the AudioInputProcessor to stop streaming audio and end an ongoing Recognize Event, which transitions it to the BUSY state. This function can only be called in the RECOGNIZING state; calling it while in another state will fail.

Returns
A future which is true if called in the correct state and a Recognize Event's audio streaming was stopped successfully, else false.

Member Data Documentation

◆ INVALID_INDEX

const auto alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::INVALID_INDEX = std::numeric_limits<avsCommon::avs::AudioInputStream::Index>::max()
static

A reserved Index value which is considered invalid.

◆ KEYWORD_TEXT_STOP

constexpr const char* alexaClientSDK::capabilityAgents::aip::AudioInputProcessor::KEYWORD_TEXT_STOP = "STOP"
static

A special keyword sent by supported wakeword engines for "Alexa, Stop".


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

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