diff --git a/en/device-dev/subsystems/subsys-aiframework-demo-plugin.md b/en/device-dev/subsystems/subsys-aiframework-demo-plugin.md index fade965edad6eb099a69f7334608cc0954494a03..298489f6d6faf68f35c7e2b39616d0ae6c7e94b0 100644 --- a/en/device-dev/subsystems/subsys-aiframework-demo-plugin.md +++ b/en/device-dev/subsystems/subsys-aiframework-demo-plugin.md @@ -1,6 +1,6 @@ # KWS Plug-in -1. Add the API of the KWS plug-in to the **//foundation/ai/engine/services/server/plugin** directory. This API is used to call AI capabilities. The following code snippet is an example API implementation of the KWS plug-in. The reference code is available at the **//foundation/ai/engine/services/server/plugin/asr/keyword\_spotting** directory. +1. Add the API of the KWS plug-in to the **//foundation/ai/engine/services/server/plugin** directory. This API is used to call AI capabilities. The following code snippet is an example API implementation of the KWS plug-in. The reference code is available at the **//foundation/ai/engine/services/server/plugin/asr/keyword\_spotting** directory. ``` #include "plugin/i_plugin.h @@ -20,72 +20,24 @@ }; ``` - The preceding code implements the **IPlugin** API provided by the server. [Table 1](#table567211582104) shows the mapping between the client APIs and the plug-in APIs. + The preceding code implements the **IPlugin** API provided by the server. [Table 1](#table567211582104) shows the mapping between the client APIs and the plug-in APIs. - **Table 1** Mapping between the client APIs and the plug-in APIs + **Table 1** Mapping between the client APIs and the plug-in APIs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Client API

-

Plug-in API

-

Description

-

AieClientPrepare

-

Prepare

-

Initializes the inference algorithm plug-in. For KWS, this API loads the KWS model from the fixed location (/sdcard/wenwen_inst.wk) to the memory.

-

AieClientSyncProcess

-

SyncProcess

-

Executes the inference algorithm synchronously. For KWS, this API synchronously executes the audio inference algorithm to determine whether the specified wakeup keyword exists in the audio.

-

AieClientAsyncProcess

-

AsyncProcess

-

Executes the inference algorithm asynchronously. Currently, this API is not used in KWS. However, you can implement the API based on your use case.

-

AieClientSetOption

-

SetOption

-

Sets algorithm-related configuration items, such as the confidence threshold and delay. Currently, this API is not used in KWS. However, you can implement the API based on your use case.

-

AieClientGetOption

-

GetOption

-

Obtains algorithm-related configuration items. For KWS, this API can obtain the input and output scale of the KWS model. The input scale is the MFCC feature (fixed value: 4000) required by the KWS model, and the output scale is the confidence (fixed value: 2) of the result.

-

AieClientRelease

-

Release

-

Releases the algorithm model. For KWS, this API releases the specified algorithm model and clears the dynamic memory in the feature processor.

-
- - Note: - - 1. The **AieClientInit** and **AieClientDestroy** APIs are used to connect to and disconnect from the server, respectively. They are not called in the plug-in algorithm and therefore do not need to be defined in the plug-in. - - 2. The KWS plug-in needs to use the **PLUGIN\_INTERFACE\_IMPL** statement to expose the function pointer. Otherwise, the plug-in cannot be properly loaded. +| Client API | Plug-in API | Description | +| ---------- | ----------- | ----------- | +| AieClientPrepare | Prepare | Initializes the inference algorithm plug-in. For KWS, this API loads the KWS model from the fixed location (/sdcard/wenwen_inst.wk) to the memory. | +| AieClientSyncProcess | SyncProcess | Executes the inference algorithm synchronously. For KWS, this API synchronously executes the audio inference algorithm to determine whether the specified wakeup keyword exists in the audio. | +| AieClientAsyncProcess | AsyncProcess | Executes the inference algorithm asynchronously. Currently, this API is not used in KWS. However, you can implement the API based on your use case. | +| AieClientSetOption | SetOption | Sets algorithm-related configuration items, such as the confidence threshold and delay. Currently, this API is not used in KWS. However, you can implement the API based on your use case. | +| AieClientGetOption | GetOption | Obtains algorithm-related configuration items. For KWS, this API can obtain the input and output scale of the KWS model. The input scale is the MFCC feature (fixed value: 4000) required by the KWS model, and the output scale is the confidence (fixed value: 2) of the result. | +| AieClientRelease | Release | Releases the algorithm model. For KWS, this API releases the specified algorithm model and clears the dynamic memory in the feature processor. | +>![](../public_sys-resources/icon-note.gif)**NOTE** +>- The **AieClientInit** and **AieClientDestroy** APIs are used to connect to and disconnect from the server, respectively. They are not called in the plug-in algorithm and therefore do not need to be defined in the plug-in. +>- The KWS plug-in needs to use the **PLUGIN\_INTERFACE\_IMPL** statement to expose the function pointer. Otherwise, the plug-in cannot be properly loaded. + + ``` PLUGIN_INTERFACE_IMPL(KWSPlugin); - ``` - - + ``` \ No newline at end of file diff --git a/en/device-dev/subsystems/subsys-aiframework-demo-sdk.md b/en/device-dev/subsystems/subsys-aiframework-demo-sdk.md index 969d35269f74b0a7efe86fd387d4fe066409d2b2..c6e5dbe4195526413c7e86a6b48ecd956b3785e1 100644 --- a/en/device-dev/subsystems/subsys-aiframework-demo-sdk.md +++ b/en/device-dev/subsystems/subsys-aiframework-demo-sdk.md @@ -1,6 +1,6 @@ # KWS SDK -1. Add the API of the KWS SDK to the **//foundation/ai/engine /interfaces/kits** directory. This API can be called by third-party applications. The following code snippet is an example API for the KWS SDK. The reference code is available at the **//foundation/ai/engine /interfaces/kits/asr/keyword\_spotting** directory. +1. Add the API of the KWS SDK to the **//foundation/ai/engine /interfaces/kits** directory. This API can be called by third-party applications. The following code snippet is an example API for the KWS SDK. The reference code is available at the **//foundation/ai/engine /interfaces/kits/asr/keyword\_spotting** directory. ``` class KWSSdk { @@ -22,7 +22,7 @@ }; ``` -2. Add the API implementation of the SDK to the **//foundation/ai/engine/services/client/algorithm\_sdk** directory and call the APIs provided by the client to use the algorithm plug-in capabilities. The following code snippet is an example implementation of the **create** method in the API of the KWS SDK. For more details, see the reference code at **//foundation/ai/engine/services/client/algorithm\_sdk/asr/keyword\_spotting**. +2. Add the API implementation of the SDK to the **//foundation/ai/engine/services/client/algorithm\_sdk** directory and call the APIs provided by the client to use the algorithm plug-in capabilities. The following code snippet is an example implementation of the **create** method in the API of the KWS SDK. For more details, see the reference code at **//foundation/ai/engine/services/client/algorithm\_sdk/asr/keyword\_spotting**. ``` int32_t KWSSdk::KWSSdkImpl::Create() @@ -73,9 +73,8 @@ } ``` - The preceding code is the specific API implementation. The **create** function in the API of the KWS SDK calls the open **AieClientInit** and **AieClientPrepare** APIs provided by the client to connect to the server and load the algorithm model. For details, see the implementation of the **create** method in following sections. - - >![](../public_sys-resources/icon-note.gif) **NOTE:** - >The sequence for the SDK to call client APIs: **AieClientInit** -\> **AieClientPrepare** -\> **AieClientSyncProcess** or **AieClientAsyncProcess** -\> **AieClientRelease** -\> **AieClientDestroy**. An exception will be thrown if the call sequence is violated. - + The preceding code is the specific API implementation. The **create** function in the API of the KWS SDK calls the open **AieClientInit** and **AieClientPrepare** APIs provided by the client to connect to the server and load the algorithm model. For details, see the implementation of the **create** method in following sections. + >![](../public_sys-resources/icon-note.gif) **NOTE** + > + >The sequence for the SDK to call client APIs: **AieClientInit** -\> **AieClientPrepare** -\> **AieClientSyncProcess** or **AieClientAsyncProcess** -\> **AieClientRelease** -\> **AieClientDestroy**. An exception will be thrown if the call sequence is violated.