16 #ifndef ALEXA_CLIENT_SDK_CAPABILITYAGENTS_AIP_INCLUDE_AIP_AUDIOINPUTPROCESSOR_H_ 17 #define ALEXA_CLIENT_SDK_CAPABILITYAGENTS_AIP_INCLUDE_AIP_AUDIOINPUTPROCESSOR_H_ 22 #include <unordered_map> 23 #include <unordered_set> 66 namespace capabilityAgents {
89 ,
public std::enable_shared_from_this<AudioInputProcessor> {
101 map<std::string, std::pair<avsCommon::utils::AudioFormat::Encoding, avsCommon::utils::AudioFormat::Encoding>>;
133 static const auto INVALID_INDEX = std::numeric_limits<avsCommon::avs::AudioInputStream::Index>::max();
165 static std::shared_ptr<AudioInputProcessor>
create(
166 std::shared_ptr<avsCommon::sdkInterfaces::DirectiveSequencerInterface> directiveSequencer,
167 std::shared_ptr<avsCommon::sdkInterfaces::MessageSenderInterface> messageSender,
168 std::shared_ptr<avsCommon::sdkInterfaces::ContextManagerInterface> contextManager,
169 std::shared_ptr<avsCommon::sdkInterfaces::FocusManagerInterface> focusManager,
170 std::shared_ptr<avsCommon::avs::DialogUXStateAggregator> dialogUXStateAggregator,
171 std::shared_ptr<avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface> exceptionEncounteredSender,
172 std::shared_ptr<avsCommon::sdkInterfaces::UserInactivityMonitorInterface> userInactivityNotifier,
173 std::shared_ptr<avsCommon::sdkInterfaces::SystemSoundPlayerInterface> systemSoundPlayer,
174 const std::shared_ptr<avsCommon::sdkInterfaces::LocaleAssetsManagerInterface>& assetsManager,
175 std::shared_ptr<settings::WakeWordConfirmationSetting> wakeWordConfirmation,
176 std::shared_ptr<settings::SpeechConfirmationSetting> speechConfirmation,
177 const std::shared_ptr<avsCommon::avs::CapabilityChangeNotifierInterface>& capabilityChangeNotifier,
178 std::shared_ptr<settings::WakeWordsSetting> wakeWordsSetting =
nullptr,
179 std::shared_ptr<audioEncoderInterfaces::AudioEncoderInterface> audioEncoder =
nullptr,
181 std::shared_ptr<avsCommon::sdkInterfaces::PowerResourceManagerInterface> powerResourceManager =
nullptr,
182 std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface>
metricRecorder =
nullptr,
183 const std::shared_ptr<ExpectSpeechTimeoutHandler>& expectSpeechTimeoutHandler =
nullptr);
190 void addObserver(std::shared_ptr<ObserverInterface> observer);
259 std::chrono::steady_clock::time_point startOfSpeechTimestamp = std::chrono::steady_clock::now(),
263 std::shared_ptr<
const std::vector<char>> KWDMetadata =
nullptr,
423 std::shared_ptr<avsCommon::sdkInterfaces::DirectiveSequencerInterface> directiveSequencer,
424 std::shared_ptr<avsCommon::sdkInterfaces::MessageSenderInterface> messageSender,
425 std::shared_ptr<avsCommon::sdkInterfaces::ContextManagerInterface> contextManager,
426 std::shared_ptr<avsCommon::sdkInterfaces::FocusManagerInterface> focusManager,
427 std::shared_ptr<avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface> exceptionEncounteredSender,
428 std::shared_ptr<avsCommon::sdkInterfaces::UserInactivityMonitorInterface> userInactivityMonitor,
429 std::shared_ptr<avsCommon::sdkInterfaces::SystemSoundPlayerInterface> systemSoundPlayer,
430 const std::shared_ptr<avsCommon::sdkInterfaces::LocaleAssetsManagerInterface>& assetsManager,
431 std::shared_ptr<audioEncoderInterfaces::AudioEncoderInterface> audioEncoder,
433 std::shared_ptr<settings::WakeWordConfirmationSetting> wakeWordConfirmation,
434 std::shared_ptr<settings::SpeechConfirmationSetting> speechConfirmation,
435 const std::shared_ptr<avsCommon::avs::CapabilityChangeNotifierInterface>& capabilityChangeNotifier,
436 std::shared_ptr<settings::WakeWordsSetting> wakeWordsSetting,
437 std::shared_ptr<avsCommon::avs::CapabilityConfiguration> capabilitiesConfiguration,
438 std::shared_ptr<avsCommon::sdkInterfaces::PowerResourceManagerInterface> powerResourceManager,
439 std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface>
metricRecorder,
440 const std::shared_ptr<ExpectSpeechTimeoutHandler>& expectSpeechTimeoutHandler);
444 void doShutdown()
override;
454 std::future<bool> expectSpeechTimedOut();
461 void handleStopCaptureDirective(std::shared_ptr<DirectiveInfo> info);
468 void handleExpectSpeechDirective(std::shared_ptr<DirectiveInfo> info);
475 void handleSetEndOfSpeechOffsetDirective(std::shared_ptr<DirectiveInfo> info);
484 void handleDirectiveFailure(
486 std::shared_ptr<DirectiveInfo> info,
517 bool executeRecognize(
520 std::chrono::steady_clock::time_point startOfSpeechTimestamp,
524 std::shared_ptr<
const std::vector<char>> KWDMetadata,
554 bool executeRecognize(
557 std::chrono::steady_clock::time_point startOfSpeechTimestamp = std::chrono::steady_clock::now(),
561 std::shared_ptr<
const std::vector<char>> KWDMetadata =
nullptr,
562 bool initiatedByWakeword =
false,
563 bool falseWakewordDetection =
false,
575 void executeOnContextAvailable(
const std::string& jsonContext);
611 bool executeStopCapture(
bool stopImmediately =
false, std::shared_ptr<DirectiveInfo> info =
nullptr);
617 void executeResetState();
632 bool executeExpectSpeech(std::chrono::milliseconds timeout, std::shared_ptr<DirectiveInfo> info);
639 bool executeExpectSpeechTimedOut();
647 void executeOnDialogUXStateChanged(
653 void executeDisconnected();
658 void executeOnLocaleAssetsChanged();
673 void removeDirective(std::shared_ptr<DirectiveInfo> info);
676 void sendRequestNow();
686 bool handleSetWakeWordConfirmation(std::shared_ptr<DirectiveInfo> info);
694 bool handleSetSpeechConfirmation(std::shared_ptr<DirectiveInfo> info);
702 bool handleSetWakeWords(std::shared_ptr<DirectiveInfo> info);
723 void closeAttachmentReaders(
739 bool isUsingEncoderLocked()
const;
746 bool multiStreamsRequestedLocked()
const;
749 std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface> m_metricRecorder;
752 std::shared_ptr<avsCommon::sdkInterfaces::DirectiveSequencerInterface> m_directiveSequencer;
755 std::shared_ptr<avsCommon::sdkInterfaces::MessageSenderInterface> m_messageSender;
758 std::shared_ptr<avsCommon::sdkInterfaces::ContextManagerInterface> m_contextManager;
761 std::shared_ptr<avsCommon::sdkInterfaces::FocusManagerInterface> m_focusManager;
764 std::shared_ptr<avsCommon::sdkInterfaces::UserInactivityMonitorInterface> m_userInactivityMonitor;
770 const std::shared_ptr<audioEncoderInterfaces::AudioEncoderInterface> m_encoder;
781 std::unordered_set<std::shared_ptr<ObserverInterface>> m_observers;
803 std::unordered_map<std::string, std::vector<std::shared_ptr<avsCommon::avs::MessageRequest::NamedReader>>>
819 std::shared_ptr<avsCommon::avs::MessageRequest> m_recognizeRequest;
822 std::shared_ptr<avsCommon::avs::MessageRequest> m_recognizeRequestSent;
834 bool m_preparingToSend;
840 std::function<void()> m_deferredStopCapture;
843 bool m_initialDialogUXStateReceived;
849 bool m_localStopCapturePerformed;
854 bool m_streamIsClosedInRecognizingState;
857 std::shared_ptr<avsCommon::sdkInterfaces::SystemSoundPlayerInterface> m_systemSoundPlayer;
860 std::shared_ptr<avsCommon::sdkInterfaces::LocaleAssetsManagerInterface> m_assetsManager;
871 std::unique_ptr<std::string> m_precedingExpectSpeechInitiator;
875 std::unordered_set<std::shared_ptr<avsCommon::avs::CapabilityConfiguration>> m_capabilityConfigurations;
878 std::shared_ptr<settings::WakeWordConfirmationSetting> m_wakeWordConfirmation;
881 std::shared_ptr<settings::SpeechConfirmationSetting> m_speechConfirmation;
884 std::shared_ptr<avsCommon::avs::CapabilityChangeNotifierInterface> m_capabilityChangeNotifier;
887 std::shared_ptr<settings::WakeWordsSetting> m_wakeWordsSetting;
890 std::shared_ptr<avsCommon::sdkInterfaces::PowerResourceManagerInterface> m_powerResourceManager;
893 std::chrono::steady_clock::time_point m_stopCaptureReceivedTime;
899 std::shared_ptr<ExpectSpeechTimeoutHandler> m_expectSpeechTimeoutHandler;
910 std::chrono::milliseconds m_timeSinceLastResumeMS;
915 std::chrono::milliseconds m_timeSinceLastPartialMS;
949 mutable std::mutex m_encodingFormatMutex;
954 unsigned int m_audioBytesForMetricThreshold;
967 std::shared_ptr<avsCommon::sdkInterfaces::PowerResourceManagerInterface::PowerResourceId> m_powerResourceId;
982 #endif // ALEXA_CLIENT_SDK_CAPABILITYAGENTS_AIP_INCLUDE_AIP_AUDIOINPUTPROCESSOR_H_
Definition: CapabilityAgent.h:47
MixingBehavior
Definition: MixingBehavior.h:25
Definition: CapabilityConfigurationInterface.h:32
::std::string string
Definition: gtest-port.h:1097
static const AudioProvider & null()
Definition: AudioProvider.h:171
Definition: DataPointDurationBuilder.h:30
ContextRequestError
Definition: ContextRequesterInterface.h:40
Single-thread executor implementation.
Definition: Executor.h:45
Definition: RequiresShutdown.h:32
ExceptionErrorType
Definition: ExceptionErrorType.h:28
Definition: AudioProvider.h:31
Definition: MessageRequestObserverInterface.h:28
FocusState
Definition: FocusState.h:29
Stop returning data when all of the data in the buffer at the time close() was called has been read...
DialogUXState
The different dialog specific AVS UX states.
Definition: DialogUXStateObserverInterface.h:32
static std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder
Metric recorder shared ptr.
Definition: BaseAPLCapabilityAgentTest.cpp:261
Initiator
Definition: Initiator.h:28
Definition: LocaleAssetsObserverInterface.h:26
std::unordered_map< directiveRoutingRule::DirectiveRoutingRule, BlockingPolicy > DirectiveHandlerConfiguration
Definition: DirectiveHandlerConfiguration.h:32
Timer to schedule task for delayed and periodic execution.
Definition: Timer.h:39
Index
Index used for setting access.
Definition: StateReportGeneratorTest.cpp:41
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
std::function< bool(const std::shared_ptr< EditableMessageRequest > &req, const std::string &resolveKey)> MessageRequestResolveFunction
Definition: MessageRequest.h:92
Definition: InternetConnectionObserverInterface.h:26
Status
Definition: MessageRequestObserverInterface.h:33
Definition: ExpectSpeechTimeoutHandlerInterface.h:31
std::bitset< PowerResourceTypeIndex::NUM_OF_TYPES > PartialStateBitSet
Definition: PowerResourceManagerInterface.h:94
ClosePoint
An enum class to indicate when the read() function should stop returning data after a call to close()...
Definition: AttachmentReader.h:59
A dialog specific UX state observer.
Definition: DialogUXStateObserverInterface.h:29