ReferenceREST API

Audio

REST API: Speaker and microphone. Generated from the OpenAPI document.

Audio format

GET /v1/audio

The robot speaks and hears mono 16-bit PCM at 16 kHz.

Token: required · Lease: not needed

StatusMeaningBody
200Audio format on the wireAudioInfo
401Missing or wrong tokenErrorBody
curl -H "Authorization: Bearer $TOKEN" http://$ROBOT:7702/v1/audio

Stream the microphones

GET /v1/audio/microphone

An endless WAV (or raw s16le) stream, mono 16 kHz. The robot only mixes microphone audio while someone listens.

Token: required · Lease: not needed

ParameterInTypeRequiredMeaning
formatqueryStreamFormatno
StatusMeaningBody
200Endless mono 16 kHz 16-bit stream of the microphonesaudio/wav, application/octet-stream
401Missing or wrong tokenErrorBody
503Too many streams openErrorBody
curl -N -H "Authorization: Bearer $TOKEN" http://$ROBOT:7702/v1/audio/microphone > mic.wav

Play audio on the speakers

POST /v1/audio/speaker

16-bit PCM WAV at any rate and channel count (converted to 16 kHz mono) or raw s16le 16 kHz mono, at most 4 MiB. Queued after what is playing.

Token: required · Lease: required (Nao-Lease header)

Request body (application/octet-stream or audio/wav): 16-bit PCM WAV (any rate and channel count, converted to 16 kHz mono) or raw s16le 16 kHz mono; at most 4 MiB

StatusMeaningBody
202Queued for the speakersQueued
409Not the active leaseErrorBody
413Larger than 4 MiBErrorBody
415Unsupported content typeErrorBody
422Not usable audioErrorBody
428No Nao-Lease headerErrorBody
curl -X POST -H "Authorization: Bearer $TOKEN" -H "Nao-Lease: $LEASE" -H 'Content-Type: audio/wav' \
  --data-binary @hello.wav http://$ROBOT:7702/v1/audio/speaker

Stop the speakers

DELETE /v1/audio/speaker

Drops queued speaker audio.

Token: required · Lease: required (Nao-Lease header)

StatusMeaningBody
204Queued speaker audio dropped
409Not the active leaseErrorBody
428No Nao-Lease headerErrorBody
curl -X DELETE -H "Authorization: Bearer $TOKEN" -H "Nao-Lease: $LEASE" http://$ROBOT:7702/v1/audio/speaker

Speaker volume

GET /v1/audio/volume

What the mixer holds now. Every boot starts at 65 %; changes are not kept across reboots.

Token: required · Lease: not needed

StatusMeaningBody
200The speaker volumeVolumeStatus
401Missing or wrong tokenErrorBody
503No mixer (simulator), or not read yetErrorBody
curl -H "Authorization: Bearer $TOKEN" http://$ROBOT:7702/v1/audio/volume

Set the speaker volume

PUT /v1/audio/volume

Changes the mixer only, never the audio stream, so it does not pop. Applied within about 0.1 s; GET /v1/audio/volume reads it back. Not persistent: the next boot is at 65 % again.

Token: required · Lease: required (Nao-Lease header)

Request body (application/json)

VolumeRequest. A volume change. Give percent, muted or both; a percent above 0 also unmutes unless muted is given too.

FieldTypeRequiredMeaning
mutedboolean or nullno
percentinteger or nullno0 to 100. (0 to 100)
{"percent":50}
StatusMeaningBody
202RequestedVolumeRequest
409Not the active leaseErrorBody
422Invalid input (percent outside 0..100, nothing given)ErrorBody
428No Nao-Lease headerErrorBody
curl -X PUT -H "Authorization: Bearer $TOKEN" -H "Nao-Lease: $LEASE" -H 'Content-Type: application/json' \
  -d '{"percent": 50}' http://$ROBOT:7702/v1/audio/volume

On this page