This ROS Catkin package is a wrapper around the sounddevice python package located here: https://python-sounddevice.readthedocs.io/en/0.3.13/
- Install sounddevice and soundfile:
pip install sounddevice pysoundfile
- Install PortAudio and ASound:
sudo apt-get install libportaudio2 libasound-dev
- Clone this repository into your catkin_ws/src folder:
cd ~/catkin_ws/src git clone https://github.com/firephinx/sounddevice_ros.git
- Run catkin_make in your catkin_ws folder:
cd .. catkin_make
- Source the devel/setup.bash and start the sound device publisher:
source devel/setup.bash rosrun sounddevice_ros sounddevice_ros_publisher_node.py
- Open a new terminal, source the devel/setup.bash, and start the sound device subscriber:
source ~/catkin_ws/devel/setup.bash rosrun sounddevice_ros sounddevice_ros_subscriber_node.py
- You can list available devices by first running:
rosrun sounddevice_ros sounddevice_ros_publisher_node.py -l
- You can select your desired input device by using the -d flag:
rosrun sounddevice_ros sounddevice_ros_publisher_node.py -d <device id or substring>
- You can set the sample rate by using the -r flag:
rosrun sounddevice_ros sounddevice_ros_publisher_node.py -r <sample_rate>
- You can set the number of channels by using the -c flag (default is 1):
rosrun sounddevice_ros sounddevice_ros_publisher_node.py -c <num_channels>
- You can set whether to save the audio to a wav file using the -s flag (default is False):
rosrun sounddevice_ros sounddevice_ros_publisher_node.py -s True
- If you want to save the audio to a wave file, you can set the filename (default is a random temp filename):
rosrun sounddevice_ros sounddevice_ros_publisher_node.py -s True [Filename]
- If you want to set the subtype for soundfile saving, you can use the -t flag:
rosrun sounddevice_ros sounddevice_ros_publisher_node.py -t PCM_24
- You can set the filename that the audio will be saved to (default is a random temp filename):
rosrun sounddevice_ros sounddevice_ros_subscriber_node.py [Filename]
- If you did not already set the subtype for soundfile saving when starting the publisher node, you can use the -t flag:
rosrun sounddevice_ros sounddevice_ros_publisher_node.py -t PCM_24