Skip to content

7.3 Audio Playback Section

The A2 Lite robot does not have a microphone and thus cannot perform voice interaction functions. However, it is equipped with a speaker that can play basic audio files and adjust volume. It also supports queue playback, playback status queries, and interruption control logic.

Interface Name pb:/aimdk.protocol.TTSService/PlayMediaFile
Function Summary Audio file playback
Interface Type HTTP JSON RPC
URL http://127.0.0.1:59201/rpc/aimdk.protocol.TTSService/PlayMediaFile
Input Parameters
{
  "file_name": "wake.pcm",
  "priority_level": "INTERACTION_L6",
  "domain": "example",
  "trace_id": "hafhjkqwjwefk",
  "is_interrupted": true
}
  • file_name: File name (stored in /agibot/data/var/interaction/audio/, for example, wake.pcm. The file should be a 24kHz, 16-bit, mono PCM file. A separate folder needs to be created, and the input should be in the format of folder name/file name, such as file/wake.pcm)
  • priority_level: Priority level, keep INTERACTION_L6
  • domain: Caller source identifier, you can pass in a custom client string for easier troubleshooting, etc.
  • trace_id: Playback ID, if you need to get the playback status, you need to pass this field and use its value as the parameter to query the playback status
  • is_interrupted: Whether to interrupt playback of the same priority, please default to true. For queue playback requirements, you can use false
Output Parameters
{
  "text": "wake.pcm",
  "priority_level": "INTERACTION_L6",
  "priority_weight": 0,
  "domain": "example",
  "trace_id": "hafhjkqwjwefk",
  "is_sucess": true,
  "error_message": "",
  "estimated_duration": 0
}
  • text: File name
  • priority_level: Priority level, no need to pay attention
  • pritority_weight: Priority weight, no need to pay attention
  • domain: Caller source identifier, returns the custom string passed in the request for easier troubleshooting
  • trace_id: Playback ID, returns the custom string passed in the request for easier troubleshooting
  • is_success: Whether the priority check was successful, generally true, but it does not mean it will play. For example, passing an incorrect or non-existent file name will still return true. Only when there is a higher-priority content being played, such as a fault alarm, will it return true
  • estimated_duration: Invalid field, no need to pay attention, unable to estimate playback duration
Example Script examples/audio/play_media_file.sh
Notes
  • Supports standard 44-byte header Linear PCM wav files. Other header formats and compressed formats are not supported. It is recommended to use 24kHz, 16-bit, mono PCM files
  • If an incorrect or non-existent file name is passed, it will silently fail without playing, and is_success will return true

7.3.3 Audio File Playback Status Query RPC Interface

Section titled “7.3.3 Audio File Playback Status Query RPC Interface”
Interface Name pb:/aimdk.protocol.TTSService/GetAudioStatus
Function Summary Audio file playback status query
Interface Type HTTP JSON RPC
URL http://127.0.0.1:59201/rpc/aimdk.protocol.TTSService/GetAudioStatus
Input Parameters
{
  "trace_id": "hafhjkqwjwefk"
}
  • trace_id: Playback ID, fill in the custom ID passed when calling the PlayMediaFile interface
Output Parameters
{
  "tts_status": {
    "text": "",
    "priority": 0,
    "trace_id": "",
    "tts_status": "TTSStatusType_Playing",
    "domain": "",
    "error_message": ""
  }
}
  • tts_status: Playback status, enumeration values

    • TTSConfigStatusType_Unknown: Unknown status
    • TTSStatusType_Begin: Start playback, brief, usually not queried
    • TTSStatusType_Playing: Playing
    • TTSStatusType_End: End of playback, brief, usually not queried
    • TTSStatusType_Stop: Pause playback/cancel playback/interrupt playback
    • TTSStatusType_Error: Playback failed
    • TTSStatusType_InQue: In the playback queue, not yet started
    • TTSStatusType_NOTInQue: No such text in the playback queue, not playing, enters this state after playback ends
  • The rest of the fields are invalid and do not need to be paid attention to

Example Script examples/audio/get_audio_status.sh
Notes A successful playback queried through this RPC interface generally returns InQue, Playing, and NOTInQue states

7.3.4 Audio File Playback Interruption RPC Interface

Section titled “7.3.4 Audio File Playback Interruption RPC Interface”

We provide interfaces for interrupting a single file playback and clearing the entire playback queue.

Interface Name pb:/aimdk.protocol.TTSService/StopTTSTraceId
Function Summary Interrupt a single file playback
Interface Type HTTP JSON RPC
URL http://127.0.0.1:59201/rpc/aimdk.protocol.TTSService/StopTTSTraceId
Input Parameters
{
  "trace_id": "hafhjkqwjwefk"
}
  • trace_id: Playback ID, fill in the custom ID passed when calling the PlayMediaFile interface
Output Parameters
{
  "state":"CommonState_UNKNOWN"
}
  • state: Request status, no need to pay attention to the specific value, HTTP request returning 200 indicates success
Example Script examples/audio/stop_trace_id.sh
Notes
Interface Name pb:/aimdk.protocol.TTSService/StopTTS
Function Summary Terminate all audio file playback, including the current playback task and all tasks in the queue
Interface Type HTTP JSON RPC
URL http://127.0.0.1:59201/rpc/aimdk.protocol.TTSService/StopTTS
Input Parameters
{}
  • trace_id: Playback ID, fill in the custom ID passed when calling the PlayMediaFile interface
Output Parameters
{
  "state":"CommonState_UNKNOWN"
}
  • state: Request status, no need to pay attention to the specific value, HTTP request returning 200 indicates success
Example Script examples/audio/stop_all.sh
Notes
Interface Name pb:/aimdk.protocol.HalAudioService/GetAudioVolume
Function Summary Get the current volume level
Interface Type HTTP JSON RPC
URL http://127.0.0.1:59201/rpc/aimdk.protocol.HalAudioService/GetAudioVolume
Input Parameters
{}
Output Parameters
{
  "header": {
    "code": "0",
    "msg": "GetAudioVolume successfully",
    "trace_id": "",
    "domin": ""
  },
  "audio_volume": 80,
  "is_mute": false
}
  • audio_volume: Volume level, a value between 0-100
  • is_mute: Whether muted
Example Script examples/audio/get_audio_volume.sh
Notes
Interface Name pb:/aimdk.protocol.HalAudioService/SetAudioVolume
Function Summary Adjust the volume
Interface Type HTTP JSON RPC
URL http://127.0.0.1:59201/rpc/aimdk.protocol.HalAudioService/SetAudioVolume
Input Parameters
{
  "audio_volume": 70,
  "is_mute": false
}
  • audio_volume: Volume level, a value between 0-100. Note: Do not set the volume above 70, as exceeding this range will cause the speaker to exceed its rated operating capacity, leading to damage
  • is_mute: Whether muted
Output Parameters
{
  "header": {
    "code": "0",
    "msg": "SetAudioVolume successfully",
    "trace_id": "",
    "domin": ""
  },
  "pkg_name": "",
  "is_success": false
}
  • pkg_name: Invalid field, no need to pay attention
  • is_success: Invalid field, no need to pay attention
Example Script examples/audio/set_audio_volume.sh
Notes