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 ENROLL_INTELL_VOICE_ENGINE_H 17 #define ENROLL_INTELL_VOICE_ENGINE_H 18 19 #include "i_intell_voice_engine.h" 20 #include "engine_callback_inner.h" 21 #include "intell_voice_info.h" 22 23 namespace OHOS { 24 namespace IntellVoice { 25 using OHOS::IntellVoiceEngine::IIntellVoiceEngineEventCallback; 26 using OHOS::IntellVoiceEngine::IIntellVoiceEngine; 27 using OHOS::IntellVoiceEngine::EngineCallbackInner; 28 using OHOS::HDI::IntelligentVoice::Engine::V1_2::EvaluationResultInfo; 29 30 struct EnrollIntelligentVoiceEngineDescriptor { 31 std::string wakeupPhrase; 32 }; 33 34 struct EngineConfig { 35 std::string language; 36 std::string region; 37 }; 38 39 class EnrollIntellVoiceEngine { 40 public: 41 EnrollIntellVoiceEngine(const EnrollIntelligentVoiceEngineDescriptor &descriptor); 42 ~EnrollIntellVoiceEngine(); 43 44 int32_t Init(const EngineConfig &config); 45 int32_t Start(const bool &isLast); 46 int32_t Stop(); 47 int32_t Commit(); 48 int32_t SetSensibility(const int32_t &sensibility); 49 int32_t SetWakeupHapInfo(const WakeupHapInfo &info); 50 int32_t SetParameter(const std::string &key, const std::string &value); 51 int32_t GetParameter(const std::string &key); 52 int32_t Release(); 53 int32_t SetCallback(std::shared_ptr<IIntellVoiceEngineEventCallback> callback); 54 int32_t Evaluate(const std::string &word, EvaluationResultInfo &info); 55 56 private: 57 sptr<IIntellVoiceEngine> engine_ = nullptr; 58 std::unique_ptr<EnrollIntelligentVoiceEngineDescriptor> descriptor_ = nullptr; 59 sptr<EngineCallbackInner> callback_ = nullptr; 60 }; 61 } // namespace IntellVoice 62 } // namespace OHOS 63 64 #endif 65