Skip to content

CI130X Semantic ID Description


1. Overview

The CI130X chip SDK adds the concept of semantic ID. In order to facilitate developers to quickly develop the SDK, this article aims to explain the semantic ID protocol and its use.


2. Semantic ID Purpose

2.1. Uniqueness

The semantic ID of each command word is unique, facilitating interaction between multiple products.

2.2. Convenient command word processing of the same function

Generally, in specific product applications, there are different expressions of the same meaning, such as “increase the volume”, “louder”, “louder”, “turn up the volume”, etc. Developers need to handle this logic specially. During the development process, developers may add or delete some such words at any time, and the code maintenance becomes cumbersome. The semantic ID of the command word is a good solution to this problem. You only need to modify the command word EXCLE table and ASR model, and do not need to modify the code.


3. Details of semantic ID protocol

语义ID协议详述

Figure 3-1 Details of Semantic ID Protocol
  • The semantic ID has a total of 4 bytes (32 bit), and the highest bit is reserved.

  • Figures 18 to 30: Product ID. Up to 8192 products are supported. For example, “Air conditioner on” and “Fan on” are distinguished by the ID of air conditioner (ID: 0xAF) and fan (ID: 0x9D). Product ID is defined in product_ The location of the semantic. h file is shown in the following figure:

产品ID位置

Figure 3-2 Product ID Location

Note

The product ID contains general (ID: 0x65) instructions, such as volume adjustment and broadcast control.

  • Bit 6 to 17: Function ID. Up to 4096 functions are supported.

For example, “loud voice” and “low voice” belong to different functions, and their function IDs are different. “Loud voice” and “Increase volume” belong to the same function, and their function IDs are the same, facilitating the processing of command words with the same function. The function ID is defined in the product_ The location of semantic. h file is shown in the following figure:

功能ID位置

Figure 3-3 Function ID Location
  • Bits 0 to 5: express ID. Up to 64 different expressions are supported.

For example, the function of words such as “louder”, “louder” and “louder” is to increase the volume. Their product ID and function ID are identical, but the only difference is the expression ID. ID is expressed to support semantic ID uniqueness. If the developer does not consider uniqueness, it can be ignored.


4. Specific Description of Semantic ID

4.1. Semantic ID Function

//Get Product ID

get_ product_ id_ from_ semantic_ id(semantic_id);

//Get function ID

get_ function_ id_ from_ semantic_ id(semantic_id);

4.2. Semantic ID File

The command semantic ID is provided by our company, which is unique. The developer packages.. Farmware_ser_ file\cmd_ When info [60000] xxx.xls command word list file, [60000] xxx.xls semantic ID will be automatically generated. As shown in the figure below:

命令词语义ID自动生成

Figure 4-1 Automatic generation of command semantic ID

The command semantic ID is gradually improved by our company. The path of the semantic ID header file is SDK components cmd_ info\product_ semantic.h.


5. Example code of semantic ID

5.1. Common Semantic ID Example Code

#define  PRODUCT_ GENERAL (0x65)//General (semantic ID header file has been defined)
uint32_ t semantic_ id = 0x19419C4;   // Maximum volume semantic ID (command word Excel table)
//Get Product ID
if(PRODUCT_GENERAL==get_product_id_from_semantic_id(semantic_id))
{
//Get function ID
switch(get_function_id_from_semantic_id(semantic_id))
{

case VOLUME_ UP://Increase the volume
break;
case VOLUME_ DOWN://Decrease the volume
break;
case MAXIMUM_ VOLUME://Maximum volume
vol_ set(VOLUME_MAX);
break;
case MEDIUM_ VOLUME://Medium volume
vol_ set(VOLUME_MID);
break;
case MINIMUM_ VOLUME://Minimum volume
vol_ set(VOLUME_MIN);
break;
default:
break;
}
}

The above example code is the general control of products. Multiple products can use the same code to speed up code development.

5.2. Example code of lamp control semantic ID

#define PRODUCT_ LAMP_ CONTROL (0x8D)//Light control (semantic ID header file has been defined)
uint32_ t semantic_ id = 0x234DF84;  //Maximum brightness semantic ID (command word Excel table)
//Get Product ID
if(PRODUCT_LAMP_CONTROL==get_product_id_from_semantic_id(semantic_id))
{
//Get function ID
switch(get_function_id_from_semantic_id(semantic_id))
{
case MAXIMUM_ BRIGHTNESS_ OF_ LIGHT://Highest light brightness
break;
case MODERATE_ BRIGHTNESS://Medium brightness
break;
case MINIMUM_ BRIGHTNESS_ OF_ LIGHT://Minimum light brightness
break;
case TURN_ UP_ THE_ LIGHT://Turn on the light
break;
case DIM_ THE_ LIGHT://Turn down the light
break;
case RED_ MODE://Red mode
break;
case GREEN_ MODE://green mode
break;
case BLUE_ MODE://Blue mode
break;
case COLORFUL_ MODE://Color mode
break;
default:
break;
}
}

6. Example of user-defined semantic ID

6.1. Fill in the user-defined semantic ID

  • Developers package SDK projects sample_ xxx\firmware\user_ file\cmd_ Info [60000] xxx.xls command word list file, [60000] xxx.xls semantic ID will be automatically generated. If the generated default semantic ID is shown in the following figure.

命令词语义ID

  • The semantic ID in the user-defined modification [60000] xxx.xls table is shown in the following figure.

命令词语义ID

6.2. Make Custom Semantic ID Valid

  • Open the cmd in the [60000] xxx.xls peer directory_ The original contents of the info.bat file are as follows.
if exist *. bin (del *.bin)

..\..\..\..\..\..\tools\cmd_ info. exe --no-cmd-id-duplicate-check -c

if exist *. bin goto label_ ok
echo cmd_ info failed
..\..\..\..\..\..\tools\cmd_ info_ err.exe
goto end

:label_ ok
echo cmd_ info ok

:end
  • Modify cmd_ In the second line of the info.bat file, remove the last character “- c”, save and close the file.

Notes

  1. Remove cmd_ The “- c” character in the second line of the info.bat file can prevent the generation of the default semantic ID when calling (composite partition bin file. bat), making the custom semantic ID valid.
  2. The user can test the effect of not removing the “- c” character, that is, after calling (synthetic partition bin file. bat), the custom semantic ID will disappear and become the default semantic ID.
  • Back to SDK projects sample_ Xxx firmware directory. Double click the (synthetic partition bin file. bat) file. After the program runs, look back at [60000] xxx. xls. The custom semantic ID is generated successfully.

命令词语义ID

6.3. Validation results

  • You can click SDK projects sample_ xxx\src\system_ msg_ Find the following code in the deal.c file to obtain the semantic ID verification results.
void sys_ deal_ asr_ msg(sys_msg_asr_data_t *asr_msg)
{
cmd_ handle_ t cmd_ handle;

if(MSG_ASR_STATUS_GOOD_RESULT == asr_msg->asr_status && (ignore_asr_msg == 0))
{
/*Omit some codes*/

cmd_ handle = asr_ msg->asr_ cmd_ handle;

/*Omit some codes*/

/*Get the semantic ID, and verify the result according to the print*/
uint32_ t semantic_ id = cmd_ info_ get_ semantic_ id(cmd_handle);
ci_ loginfo(LOG_USER,"semantic_id:%08x\n",semantic_id);

/*Omit some codes*/
}

/*Omit some codes*/
}