AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
AbstractKeywordDetector.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 ACSDKKWDIMPLEMENTATIONS_ABSTRACTKEYWORDDETECTOR_H_
17 #define ACSDKKWDIMPLEMENTATIONS_ABSTRACTKEYWORDDETECTOR_H_
18 
19 #include <mutex>
20 #include <unordered_set>
21 
28 
29 namespace alexaClientSDK {
30 namespace acsdkKWDImplementations {
31 
33 public:
39  void addKeyWordObserver(std::shared_ptr<avsCommon::sdkInterfaces::KeyWordObserverInterface> keyWordObserver);
40 
46  void removeKeyWordObserver(std::shared_ptr<avsCommon::sdkInterfaces::KeyWordObserverInterface> keyWordObserver);
47 
55  std::shared_ptr<avsCommon::sdkInterfaces::KeyWordDetectorStateObserverInterface> keyWordDetectorStateObserver);
56 
63  std::shared_ptr<avsCommon::sdkInterfaces::KeyWordDetectorStateObserverInterface> keyWordDetectorStateObserver);
64 
68  virtual ~AbstractKeywordDetector() = default;
69 
70 protected:
79  std::unordered_set<std::shared_ptr<avsCommon::sdkInterfaces::KeyWordObserverInterface>> keyWordObservers =
80  std::unordered_set<std::shared_ptr<avsCommon::sdkInterfaces::KeyWordObserverInterface>>(),
81  std::unordered_set<std::shared_ptr<avsCommon::sdkInterfaces::KeyWordDetectorStateObserverInterface>>
82  keyWordDetectorStateObservers =
83  std::unordered_set<std::shared_ptr<avsCommon::sdkInterfaces::KeyWordDetectorStateObserverInterface>>(),
84  bool supportsDavs = false);
85 
94  std::shared_ptr<acsdkKWDInterfaces::KeywordNotifierInterface> keywordNotifier,
95  std::shared_ptr<acsdkKWDInterfaces::KeywordDetectorStateNotifierInterface> keyWordDetectorStateNotifier,
96  bool supportsDavs = false);
97 
108  std::shared_ptr<avsCommon::avs::AudioInputStream> stream,
109  std::string keyword,
112  std::shared_ptr<const std::vector<char>> KWDMetadata = nullptr) const;
113 
121 
133  ssize_t readFromStream(
134  std::shared_ptr<avsCommon::avs::AudioInputStream::Reader> reader,
135  std::shared_ptr<avsCommon::avs::AudioInputStream> stream,
136  void* buf,
137  size_t nWords,
138  std::chrono::milliseconds timeout,
139  bool* errorOccurred);
140 
147  static bool isByteswappingRequired(avsCommon::utils::AudioFormat audioFormat);
148 
154  bool isDavsSupported();
155 
156 private:
160  std::shared_ptr<acsdkKWDInterfaces::KeywordNotifierInterface> m_keywordNotifier;
161 
166  std::shared_ptr<acsdkKWDInterfaces::KeywordDetectorStateNotifierInterface> m_keywordDetectorStateNotifier;
167 
173 
175  mutable std::mutex m_detectorStateMutex;
176 
178  bool m_supportsDavs;
179 };
180 
181 } // namespace acsdkKWDImplementations
182 } // namespace alexaClientSDK
183 
184 #endif // ACSDKKWDIMPLEMENTATIONS_ABSTRACTKEYWORDDETECTOR_H_
KeyWordDetectorState
Definition: KeyWordDetectorStateObserverInterface.h:32
ssize_t readFromStream(std::shared_ptr< avsCommon::avs::AudioInputStream::Reader > reader, std::shared_ptr< avsCommon::avs::AudioInputStream > stream, void *buf, size_t nWords, std::chrono::milliseconds timeout, bool *errorOccurred)
static bool isByteswappingRequired(avsCommon::utils::AudioFormat audioFormat)
::std::string string
Definition: gtest-port.h:1097
void addKeyWordObserver(std::shared_ptr< avsCommon::sdkInterfaces::KeyWordObserverInterface > keyWordObserver)
void notifyKeyWordDetectorStateObservers(avsCommon::sdkInterfaces::KeyWordDetectorStateObserverInterface::KeyWordDetectorState state)
void removeKeyWordDetectorStateObserver(std::shared_ptr< avsCommon::sdkInterfaces::KeyWordDetectorStateObserverInterface > keyWordDetectorStateObserver)
void addKeyWordDetectorStateObserver(std::shared_ptr< avsCommon::sdkInterfaces::KeyWordDetectorStateObserverInterface > keyWordDetectorStateObserver)
Index
Index used for setting access.
Definition: StateReportGeneratorTest.cpp:41
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
AbstractKeywordDetector(std::unordered_set< std::shared_ptr< avsCommon::sdkInterfaces::KeyWordObserverInterface >> keyWordObservers=std::unordered_set< std::shared_ptr< avsCommon::sdkInterfaces::KeyWordObserverInterface >>(), std::unordered_set< std::shared_ptr< avsCommon::sdkInterfaces::KeyWordDetectorStateObserverInterface >> keyWordDetectorStateObservers=std::unordered_set< std::shared_ptr< avsCommon::sdkInterfaces::KeyWordDetectorStateObserverInterface >>(), bool supportsDavs=false)
void removeKeyWordObserver(std::shared_ptr< avsCommon::sdkInterfaces::KeyWordObserverInterface > keyWordObserver)
void notifyKeyWordObservers(std::shared_ptr< avsCommon::avs::AudioInputStream > stream, std::string keyword, avsCommon::avs::AudioInputStream::Index beginIndex, avsCommon::avs::AudioInputStream::Index endIndex, std::shared_ptr< const std::vector< char >> KWDMetadata=nullptr) const

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