7.3 Audio Playback Section

7.3 Audio Playback Section

7.3.1 Overview

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.

7.3.2 Audio File Playback RPC Interface

Interface Namepb:/aimdk.protocol.TTSService/PlayMediaFile
Function SummaryAudio file playback
Interface TypeHTTP JSON RPC
URLhttp://127.0.0.1:59201/rpc/aimdk.protocol.TTSService/PlayMediaFile
Input Parameters
text
{
  "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
{
  "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 Scriptexamples/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

Interface Namepb:/aimdk.protocol.TTSService/GetAudioStatus
Function SummaryAudio file playback status query
Interface TypeHTTP JSON RPC
URLhttp://127.0.0.1:59201/rpc/aimdk.protocol.TTSService/GetAudioStatus
Input Parameters
text
{
  "trace_id": "hafhjkqwjwefk"
}
  • trace_id: Playback ID, fill in the custom ID passed when calling the PlayMediaFile interface
Output Parameters
text
{
  "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 Scriptexamples/audio/get_audio_status.sh
NotesA successful playback queried through this RPC interface generally returns InQue, Playing, and NOTInQue states

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 Namepb:/aimdk.protocol.TTSService/StopTTSTraceId
Function SummaryInterrupt a single file playback
Interface TypeHTTP JSON RPC
URLhttp://127.0.0.1:59201/rpc/aimdk.protocol.TTSService/StopTTSTraceId
Input Parameters
text
{
  "trace_id": "hafhjkqwjwefk"
}
  • trace_id: Playback ID, fill in the custom ID passed when calling the PlayMediaFile interface
Output Parameters
text
{
  "state":"CommonState_UNKNOWN"
}
  • state: Request status, no need to pay attention to the specific value, HTTP request returning 200 indicates success
Example Scriptexamples/audio/stop_trace_id.sh
Notes
Interface Namepb:/aimdk.protocol.TTSService/StopTTS
Function SummaryTerminate all audio file playback, including the current playback task and all tasks in the queue
Interface TypeHTTP JSON RPC
URLhttp://127.0.0.1:59201/rpc/aimdk.protocol.TTSService/StopTTS
Input Parameters
text
{}
  • trace_id: Playback ID, fill in the custom ID passed when calling the PlayMediaFile interface
Output Parameters
text
{
  "state":"CommonState_UNKNOWN"
}
  • state: Request status, no need to pay attention to the specific value, HTTP request returning 200 indicates success
Example Scriptexamples/audio/stop_all.sh
Notes

7.3.5 Volume Get and Set RPC Interfaces

Interface Namepb:/aimdk.protocol.HalAudioService/GetAudioVolume
Function SummaryGet the current volume level
Interface TypeHTTP JSON RPC
URLhttp://127.0.0.1:59201/rpc/aimdk.protocol.HalAudioService/GetAudioVolume
Input Parameters
text
{}
Output Parameters
text
{
  "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 Scriptexamples/audio/get_audio_volume.sh
Notes
Interface Namepb:/aimdk.protocol.HalAudioService/SetAudioVolume
Function SummaryAdjust the volume
Interface TypeHTTP JSON RPC
URLhttp://127.0.0.1:59201/rpc/aimdk.protocol.HalAudioService/SetAudioVolume
Input Parameters
text
{
  "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
text
{
  "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 Scriptexamples/audio/set_audio_volume.sh
Notes