# Enable core audio with `qrb_ros_audio_service` The `qrb_ros_audio_service` sample application is a ROS package that delivers core audio functionalities, serving as the primary interface for audio capabilities (currently supporting playback and recording) within the ROS ecosystem. Note For more information, see the [qrb_ros_audio_service](https://github.com/qualcomm-qrb-ros/qrb_ros_audio_service) GitHub repo. ## Pipeline for `qrb_ros_audio_service` The following figure shows the pipeline.
node: audio_service
APP
Client
service: audio_server
topic: qrb_audiodata
ROS node
External App
Topic
**Figure : `qrb_ros_audio_service` pipeline** ## ROS nodes/services used in the `qrb_ros_audio_service` pipeline | ROS node | Description | | --- | --- | | `/audio_service` | This node functions as the primary entry point for the `qrb_ros_audio_service`, offering audio playback and recording capabilities through ROS service requests. | | ROS service | Type | Description | | --- | --- | --- | | `/audio_server` | `qrb_ros_audio_service_msgs::srv::AudioRequest` | Allows ROS applications to send service requests for audio playback and recording. | ## ROS topics used in the `qrb_ros_audio_service` pipeline | ROS topic | Type | Description | | --- | --- | --- | | `/qrb_audiodata` | `qrb_ros_audio_common_msgs::msg::AudioData` | Used for streaming audio playback and recording. Publishes the recorded real-time raw audio data, or allows subscription to this node's raw data for playback. You can modify the topic name using the `--topic_name` parameter. Supports using separate topics for playback and recording operations. | ## Prerequisites You have **Set up the device** according to [Set up the environment for running sample applications](https://docs.qualcomm.com/doc/80-70022-265/topic/quick_start.html#setup-demo-qs). ## Run out-of-the-box `qrb_ros_audio_service` 1. Start three commandline terminals on your device and run the following commands to set up the environment. ssh root@[ip-addr] (ssh) export HOME=/home (ssh) source /usr/bin/ros_setup.sh && source /usr/share/qirp-setup.sh Copy to clipboard 2. In the first SSH terminal, run the audio service package using the `ros2 launch` command. ros2 launch qrb_ros_audio_service audio_service.launch.py Copy to clipboard 3. In the second SSH terminal, run `qrb_ros_audio_common`. ros2 launch qrb_ros_audio_common component.launch.py Copy to clipboard 4. Check the default devices for the pipewire. 1. Verify the status of default speaker and handset mic. wpctl status Copy to clipboard Audio ├─ Devices: │ ├─ Sinks: │ \* 42. pal sink speaker ll [vol: 1.00] │ 44. pal sink speaker\_db [vol: 1.00] │ 46. pal sink headset\_ll [vol: 1.00] │ 47. pal sink headset\_db [vol: 1.00] │ ├─ Sources: │ \* 48. pal source handset mic [vol: 1.00] │ 50. pal source headset mic [vol: 1.00] 2. If the default speaker or handset mic isn't set, use `wpctl set-default ` to set the default device(s). # Set the default speaker wpctl set-default 42 # Set the default handset mic wpctl set-default 48 Copy to clipboard 5. In the third SSH terminal, run the test cases using either ROS commands or Python scripts according to the following table. Note For all step-by-step test cases, `stream_handle` indicates the stream created by the audio service when the command is `create`. After the audio service creates a stream, the command prints the value of `stream_handle` in the third SSH terminal. > > > - For the ROS command, you see the following output: > > > > > > > > > `stream_handle=<***>` > - For the Python script, you see the following output: > > > > > > > > > `command create success 1 stream_handle <***>.` > > > > Download the Python script using > > > > > > > > > wget https://raw.githubusercontent.com/qualcomm-qrb-ros/qrb_ros_audio_service/main/tests/audio_service_test.py > > Copy to clipboard > > > Table : Audio service commands > > > | Case name | Description | ROS command/Python script | > | --- | --- | --- | > | One-touch playback | Start playback with a one-touch command. The speaker outputs the audio. Supports the WAV file format. Place the music file on a device path, for example, `/tmp/music.wav`. | Tab ROS command
Tab Python script

ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "play",
source: "/tmp/music.wav",
volume: 100,
}"
Copy to clipboard

python3 audio_service_test.py --mode='one-touch' --source='/tmp/music.wav' --volume=100``
Copy to clipboard | > | Step-by-step playback | Start playback with step-by-step commands. The speaker outputs the audio. Supports the WAV file format. | Tab ROS command
Tab Python script

ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
type: "playback",
command: "create",
source: "/tmp/music.wav",
volume: 100,
}"

ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "start",
stream_handle: ,
}"

ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "mute",
mute: true,
stream_handle: ,
}"

ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "mute",
mute: false,
stream_handle: ,
}"

ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "stop",
stream_handle: ,
}"

ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "release",
stream_handle: ,
}"
Copy to clipboard

python3 audio_service_test.py --type='playback' --source='/tmp/music.wav' --volume=100
python3 audio_service_test.py --set-mute --mute=True --stream_handle=
python3 audio_service_test.py --set-mute --mute=False --stream_handle=
Copy to clipboard | > | Streaming playback | Create and start a streaming playback. It subscribes to the audio PCM data from the `loopback` topic. Audio data should be filled with `qrb_ros_audio_common_msgs::msg::AudioData`. | Tab ROS command
Tab Python script

Start a step-by-step streaming playback:


ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
audio_info: {
channels: 1,
sample_rate: 16000,
sample_format: 16,
},
type: "playback",
command: "create",
volume: 100,
topic_name: "loopback",
}"

ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "start",
stream_handle: ,
}"
Copy to clipboard


Start a one-touch streaming playback:


ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
audio_info: {
channels: 1,
sample_rate: 16000,
sample_format: 16,
},
command: "play",
volume: 100,
topic_name: "loopback",
}"
Copy to clipboard

Start a step-by-step streaming playback:


python3 audio_service_test.py --type='playback' --channels=1 --sample_rate=16000 --sample_format=16 --pub_pcm=True --volume=100 --topic_name='loopback'
Copy to clipboard


Start a one-touch streaming playback:


python3 audio_service_test.py --mode='one-touch' --channels=1 --sample_rate=16000 --sample_format=16 --pub_pcm=True --volume=100 --topic_name='loopback'
Copy to clipboard | > | Step-by-step record | Use the default input device to record with step-by-step commands and write the audio data to the `/tmp/rec.wav` file. | Tab ROS command
Tab Python script

ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
audio_info: {
channels: 1,
sample_rate: 16000,
sample_format: 16,
},
type: "record",
command: "create",
source: "/tmp/rec.wav",
}"

ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "start",
stream_handle: ,
}"

ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "stop",
stream_handle: ,
}"

ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "release",
stream_handle: ,
}"
Copy to clipboard

python3 audio_service_test.py --type='record' --source='/tmp/rec.wav' --channels=1 --sample_rate=16000 --sample_format=16
Copy to clipboard | > | Publish recording data |

  • Publish the recording data to a topic (default topic name: qrb_audiodata. You can specify another name using topic_name).


  • The audio data will be filled with qrb_ros_audio_common_msgs::msg::AudioData.


| Tab ROS command
Tab Python script

Publish the recording data to a topic (default topic name is "`qrb_audiodata`", but it can be specified using `topic_name`):


ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
audio_info: {
channels: 1,
sample_rate: 16000,
sample_format: 16,
},
type: "record",
command: "create",
pub_pcm: true,
topic_name: "loopback",
}"
Copy to clipboard


Or, publish the recording data to `/qrb_audiodata`. Meanwhile, save it to a file:


ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
audio_info: {
channels: 1,
sample_rate: 16000,
sample_format: 16,
},
type: "record",
command: "create",
pub_pcm: true,
source: "/tmp/rec.wav",
}"

ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{command: "start",
stream_handle: ,
}"

ros2 topic echo /qrb_audiodata

ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "stop",
stream_handle: ,
}"

ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "release",
stream_handle: ,
}"
Copy to clipboard

Publish the recording data to a topic (default topic name is "`qrb_audiodata`", but it can be specified using `topic_name`):


python3 audio_service_test.py --type='record' --channels=1 --sample_rate=16000 --sample_format=16 --pub_pcm=True
Copy to clipboard


Or, publish the recording data to `/qrb_audiodata`. Meanwhile, save it to a file:


python3 audio_service_test.py --type='record' --source='/tmp/rec.wav' --channels=1 --sample_rate=16000 --sample_format=16 --pub_pcm=True
Copy to clipboard | Last Published: Nov 05, 2025 [Previous Topic Bridge ROS and GST with](https://docs.qualcomm.com/bundle/publicresource/80-70022-265/topics/ros-gst-bridge.md) [Next Topic Develop applications using the QIR SDK](https://docs.qualcomm.com/bundle/publicresource/80-70022-265/topics/develop_application_with_qirp_sdk.md)