1 /* 2 * Copyright (c) 2021 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 /** 17 * @addtogroup kws_sdk 18 * @{ 19 * 20 * @brief Defines the basic functions, constants, and error codes for the wakeup keyword spotting (KWS) SDK. 21 * 22 * @since 2.2 23 * @version 1.0 24 */ 25 26 /** 27 * @file kws_callback.h 28 * 29 * @brief Defines the KWS callback for inference results and result codes. 30 * 31 * @since 2.2 32 * @version 1.0 33 */ 34 35 #ifndef KWS_CALLBACK_H 36 #define KWS_CALLBACK_H 37 38 #include "ai_datatype.h" 39 40 namespace OHOS { 41 namespace AI { 42 class KWSCallback { 43 public: 44 /** 45 * @brief Defines the destructor for the KWS callback. 46 * 47 * @since 2.2 48 * @version 1.0 49 */ 50 virtual ~KWSCallback() = default; 51 52 /** 53 * @brief Defines the KWS callback for inference errors. 54 * 55 * @param errorCode Indicates the error code defined by {@link KWSRetCode} for the KWS task. 56 * 57 * @since 2.2 58 * @version 1.0 59 */ 60 virtual void OnError(int32_t errorCode) = 0; 61 62 /** 63 * @brief Defines the KWS callback for inference results. 64 * 65 * @param result Indicates the result array defined by {@link Array} for the KWS task. 66 * The element type is {@link int32_t}. 67 * 68 * @since 2.2 69 * @version 1.0 70 */ 71 virtual void OnResult(const Array<int32_t> &result) = 0; 72 }; 73 } // namespace AI 74 } // namespace OHOS 75 #endif // KWS_CALLBACK_H 76 /** @} */