AlexaClientSDK  1.25.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
SensoryKeywordDetector.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef ALEXA_CLIENT_SDK_KWD_SENSORY_INCLUDE_SENSORY_SENSORYKEYWORDDETECTOR_H_
17 #define ALEXA_CLIENT_SDK_KWD_SENSORY_INCLUDE_SENSORY_SENSORYKEYWORDDETECTOR_H_
18 
19 #include <atomic>
20 #include <string>
21 #include <thread>
22 #include <unordered_set>
23 
28 
30 #include "snsr.h"
31 
32 namespace alexaClientSDK {
33 namespace kwd {
34 
35 using namespace avsCommon;
36 using namespace avsCommon::avs;
37 using namespace avsCommon::sdkInterfaces;
38 
40 public:
57  static std::unique_ptr<SensoryKeywordDetector> create(
58  std::shared_ptr<AudioInputStream> stream,
60  std::unordered_set<std::shared_ptr<KeyWordObserverInterface>> keyWordObservers,
61  std::unordered_set<std::shared_ptr<KeyWordDetectorStateObserverInterface>> keyWordDetectorStateObservers,
62  const std::string& modelFilePath,
63  std::chrono::milliseconds msToPushPerIteration = std::chrono::milliseconds(10));
64 
68  ~SensoryKeywordDetector() override;
69 
70 private:
86  std::shared_ptr<AudioInputStream> stream,
87  std::unordered_set<std::shared_ptr<KeyWordObserverInterface>> keyWordObservers,
88  std::unordered_set<std::shared_ptr<KeyWordDetectorStateObserverInterface>> keyWordDetectorStateObservers,
90  std::chrono::milliseconds msToPushPerIteration = std::chrono::milliseconds(10));
91 
99  bool init(const std::string& modelFilePath);
100 
108  bool setUpRuntimeSettings(SnsrSession* session);
109 
111  void detectionLoop();
112 
121  static SnsrRC keyWordDetectedCallback(SnsrSession s, const char* key, void* userData);
122 
124  std::atomic<bool> m_isShuttingDown;
125 
127  const std::shared_ptr<avsCommon::avs::AudioInputStream> m_stream;
128 
130  std::shared_ptr<avsCommon::avs::AudioInputStream::Reader> m_streamReader;
131 
136  avsCommon::avs::AudioInputStream::Index m_beginIndexOfStreamReader;
137 
139  std::thread m_detectionThread;
140 
142  SnsrSession m_session;
143 
148  const size_t m_maxSamplesPerPush;
149 };
150 
151 } // namespace kwd
152 } // namespace alexaClientSDK
153 
154 #endif // ALEXA_CLIENT_SDK_KWD_SENSORY_INCLUDE_SENSORY_SENSORYKEYWORDDETECTOR_H_
Index
Index used for setting access.
Definition: StateReportGeneratorTest.cpp:41
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
Definition: AbstractKeywordDetector.h:30
Definition: SensoryKeywordDetector.h:39
static const std::string key
The database key to be used by the protocol given the METADATA object.
Definition: SharedAVSSettingProtocolTest.cpp:58

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