Roban2 Docs
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 KuavoRobotLLM in kuavo_humanoid_sdk; speech capture/synthesis runs on the host computer (the microphone micphone_bridge is bridged to the lower-level controller).
  • Example code: examples/demo/llm_demo/llm_demo.py
  • Main files and brief descriptions:
    1. kuavo_humanoid_sdk/kuavo/robot_llm.py — main LLM conversation class (KuavoRobotLLM: ASR, LLM conversation, TTS, function/action registration)
    2. examples/demo/llm_demo/llm_demo.py — reference example (register functions/cases, import actions, trigger conversation)
    3. ~/.config/lejuconfig/llm_apis.json — API key configuration file (must be filled in manually)

Steps

  1. 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.
  2. 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):

Desktop software

  • If keys are missing, KuavoRobotLLM initialization reports LLM配置缺失; fill them in and retry.

  • You can register a conversation application and large model service at the following link:

Volcengine

Desktop software

  1. Run the voice conversation demo

Click the Large Model Conversation switch to start a real-time conversation Desktop software

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 / TTS

Main Methods

MethodDescription
trigger_asr() -> strTriggers speech recognition and returns the recognized text
chat_with_llm(user_input='') -> dictSends 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)

FieldTypeDescription
successint0 indicates success
intentstrfunction_call / action / action_custom / normal reply
slotstrParameter 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

  1. The robot has a built-in microphone receiver, and the service starts automatically at boot.
  2. Before use, make sure the robot is standing and there are no obstructions around it.
  3. The API used in this demo must be purchased separately by the user; this demo does not provide keys.
  4. The key file path is fixed at ~/.config/lejuconfig/llm_apis.json; initialization fails if any field is missing.
  5. 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.