1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef WAKEUP_INTELL_VOICE_ENGINE_H 17 #define WAKEUP_INTELL_VOICE_ENGINE_H 18 19 #include "intell_voice_info.h" 20 #include "i_intell_voice_engine.h" 21 #include "engine_callback_inner.h" 22 23 namespace OHOS { 24 namespace IntellVoice { 25 using OHOS::IntellVoiceEngine::IIntellVoiceEngineEventCallback; 26 using OHOS::IntellVoiceEngine::IIntellVoiceEngine; 27 using OHOS::IntellVoiceEngine::EngineCallbackInner; 28 29 struct WakeupIntelligentVoiceEngineDescriptor { 30 bool needReconfirm; 31 std::string wakeupPhrase; 32 }; 33 34 class WakeupIntellVoiceEngine { 35 public: 36 WakeupIntellVoiceEngine(const WakeupIntelligentVoiceEngineDescriptor &descriptor); 37 ~WakeupIntellVoiceEngine(); 38 39 int32_t SetSensibility(const int32_t &sensibility); 40 int32_t SetWakeupHapInfo(const WakeupHapInfo &info); 41 int32_t SetParameter(const std::string &key, const std::string &value); 42 int32_t GetParameter(const std::string &key); 43 int32_t Release(); 44 int32_t SetCallback(std::shared_ptr<IIntellVoiceEngineEventCallback> callback); 45 int32_t StartCapturer(int32_t channels); 46 int32_t Read(std::vector<uint8_t> &data); 47 int32_t StopCapturer(); 48 int32_t GetWakeupPcm(std::vector<uint8_t> &data); 49 int32_t NotifyHeadsetWakeEvent(); 50 int32_t NotifyHeadsetHostEvent(int32_t event); GetEngine()51 sptr<IIntellVoiceEngine> GetEngine() 52 { 53 return engine_; 54 } 55 56 private: 57 sptr<IIntellVoiceEngine> engine_ = nullptr; 58 std::unique_ptr<WakeupIntelligentVoiceEngineDescriptor> descriptor_ = nullptr; 59 sptr<EngineCallbackInner> callback_ = nullptr; 60 }; 61 } // namespace IntellVoice 62 } // namespace OHOS 63 64 #endif 65