Skip to content

Commit 481364f

Browse files
committed
feat: update nertc sdk 1.1.5.1
- add emotion event callback by on_ai_data - Introduce new event type `emotion` - emotion data:{"message":"happy","type":"emotion"}
1 parent abb4147 commit 481364f

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed
15.6 KB
Binary file not shown.
16.9 KB
Binary file not shown.

main/protocols/nertc_protocol.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,25 @@ void NeRtcProtocol::OnAiData(const nertc_sdk_callback_context_t* ctx, nertc_sdk_
705705
}
706706
}
707707

708+
cJSON_Delete(data_json);
709+
} else if (strncmp(type_str, "emotion", type_len) == 0) {
710+
cJSON* data_json = cJSON_Parse(data_str);
711+
if (!data_json) {
712+
ESP_LOGE(TAG, "Failed to parse JSON data");
713+
return;
714+
}
715+
cJSON* message = cJSON_GetObjectItem(data_json, "message");
716+
if (!message || !cJSON_IsString(message)) {
717+
ESP_LOGE(TAG, "message is null");
718+
cJSON_Delete(data_json);
719+
return;
720+
}
721+
std::string emotion = message->valuestring;
722+
cJSON* emot_json = cJSON_CreateObject();
723+
cJSON_AddStringToObject(emot_json, "type", "llm");
724+
cJSON_AddStringToObject(emot_json, "emotion", emotion.c_str());
725+
if (instance->on_incoming_json_) instance->on_incoming_json_(emot_json);
726+
cJSON_Delete(emot_json);
708727
cJSON_Delete(data_json);
709728
}
710729
}

0 commit comments

Comments
 (0)