Feature Examples
Large Speech Model Conversation
Description
- This demo enables voice conversation with the robot using a microphone: the robot captures speech (ASR recognition) → calls a large model to understand and generate a reply → speech synthesis (TTS) playback, and can execute robot actions/functions as part of the reply.
- Note: This demo is implemented on the host computer via
KuavoRobotLLMinkuavo_humanoid_sdk; speech capture/synthesis runs on the host computer (the microphonemicphone_bridgeis bridged to the lower-level controller). - Example code:
examples/demo/llm_demo/llm_demo.py - Main files and brief descriptions:
kuavo_humanoid_sdk/kuavo/robot_llm.py— main LLM conversation class (KuavoRobotLLM: ASR, LLM conversation, TTS, function/action registration)examples/demo/llm_demo/llm_demo.py— reference example (register functions/cases, import actions, trigger conversation)~/.config/lejuconfig/llm_apis.json— API key configuration file (must be filled in manually)
Steps
-
Make sure the robot control link is up
- The robot must already be standing (the lower-level controller is started with the gamepad), and the microphone and audio playback nodes must be online (they start automatically at boot).
- Make sure there are no obstructions around the robot so that speech can be captured properly.
-
Fill in the API keys Fill in the app id and access token here!!! Some versions of the desktop software display this incorrectly
- Fill in the following keys in the desktop software configuration (host configuration path
~/.config/lejuconfig/llm_apis.json):
- Fill in the following keys in the desktop software configuration (host configuration path

-
If keys are missing,
KuavoRobotLLMinitialization reportsLLM配置缺失; fill them in and retry. -
You can register a conversation application and large model service at the following link:

- Run the voice conversation demo
Click the Large Model Conversation switch to start a real-time conversation

Interface Definition
Initialization
from kuavo_humanoid_sdk import KuavoSDK, KuavoRobotLLM
if not KuavoSDK.Init(log_level='INFO'): # 初始化 SDK / ROS 环境
exit(1)
kuavo_llm = KuavoRobotLLM() # 加载密钥并初始化 LLM / ASR / TTSMain Methods
| Method | Description |
|---|---|
trigger_asr() -> str | Triggers speech recognition and returns the recognized text |
chat_with_llm(user_input='') -> dict | Sends a question to the large model; returns {"success", "intent", "slot", ...} |
response_with_voice(llm_output) | Performs text-to-speech (TTS) playback of the LLM reply |
import_action_from_files(project_name) | Imports the action files of the specified project into the prompt |
register_function(function_comment, function) | Registers a custom function (the LLM can call it as needed) |
register_case(user_input, robot_response, action) | Registers an example conversation case (helps the LLM understand the intent) |
add_file_to_prompt(file_name, project_name) | Adds the contents of a knowledge file to the prompt |
stop() | Stops and cleans up the LLM/audio services |
Action Execution
When the LLM returns intent=="action", the example plays a .tact action via RobotControlBlockly.execute_action_file():
from kuavo_humanoid_sdk import RobotControlBlockly
robot_control = RobotControlBlockly()
robot_control.execute_action_file(llm_output["slot"]) # 播放动作文件
robot_control.execute_action_file(llm_output["slot"], "demo_project") # 带项目名Return Structure (chat_with_llm)
| Field | Type | Description |
|---|---|---|
success | int | 0 indicates success |
intent | str | function_call / action / action_custom / normal reply |
slot | str | Parameter corresponding to the intent (function call expression / action file name) |
Subscription Address
If you want to subscribe to the LLM service yourself, you can configure the service address through the base_url / asr_base_url fields in ~/.config/lejuconfig/llm_apis.json.
Notes
- The robot has a built-in microphone receiver, and the service starts automatically at boot.
- Before use, make sure the robot is standing and there are no obstructions around it.
- The API used in this demo must be purchased separately by the user; this demo does not provide keys.
- The key file path is fixed at
~/.config/lejuconfig/llm_apis.json; initialization fails if any field is missing. - The host computer (NX) defaults to a 15W power mode with only 4 cores, so speech recognition latency will exceed 1s. It is recommended to switch to MAXN mode first (
sudo nvpmodel -m 0) before the demo.