Audio recording with microphone using Ros audio capture

asked 2019-04-29 13:42:46 -0500

wskway gravatar image

updated 2019-05-01 20:08:35 -0500

I am pretty new to ROS - I am trying to implement a audio recorder functionality in an existing system. Essentially I want to record an audio file for 15 seconds right after an event and include that data in a rosbag and a have a way to playback the data. Any tips and suggestions are welcome !


Edit: Okay here where I got so far. I installed the audio_common package and was able to successfully catkin_make. I launched the audio_capture.launch file I got a message saying unsupported media type. Which makes sense since I am running it on my local system without a microphone device connected. But just to test it out I wonder if i can use my dell laptops internal microphone. this is how the launch file looks like -

<launch>
  <!-- arecord -l will show available input devices, use the car number as
      the first number and the subdevice number as the second in a string
      like hw:1,0 -->
  <arg name="device" default=""/>
  <arg name="channels" default="1"/>
  <arg name="sample_rate" default="16000"/>
  <arg name="format" default="mp3"/>
  <arg name="ns" default="audio"/>

  <group ns="$(arg ns)">
    <node name="audio_capture" pkg="audio_capture" type="audio_capture" output="screen">
      <param name="bitrate" value="128"/>
      <param name="device" value="$(arg device)"/>
      <param name="channels" value="$(arg channels)"/>
      <param name="sample_rate" value="$(arg sample_rate)"/>
      <param name="format" value="$(arg format)"/>
    </node>
  </group>

</launch>

I learned that to access the internal microphone I need to access the ALSA sound architecture of linux.

https://superuser.com/questions/53957...

I tried the launch file with hw:1,0 as device name also hw:0,0. Both of them yield the following error.

SUMMARY
========

PARAMETERS
 * /audio/audio_capture/bitrate: 128
 * /audio/audio_capture/channels: 1
 * /audio/audio_capture/device: hw:1,0
 * /audio/audio_capture/format: mp3
 * /audio/audio_capture/sample_rate: 16000
 * /rosdistro: kinetic
 * /rosversion: 1.12.13

NODES
  /audio/
    audio_capture (audio_capture/audio_capture)

auto-starting new master
process[master]: started with pid [13042]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to 8de21388-6c29-11e9-8596-8cec4bfad6f9
process[rosout-1]: started with pid [13055]
started core service [/rosout]
process[audio/audio_capture-2]: started with pid [13060]

(audio_capture:13060): GLib-GObject-CRITICAL **: g_object_set: assertion 'G_IS_OBJECT (object)' failed

(audio_capture:13060): GStreamer-CRITICAL **: gst_bin_add_many: assertion 'GST_IS_ELEMENT (element_1)' failed

(audio_capture:13060): GStreamer-CRITICAL **: gst_element_link_many: assertion 'GST_IS_ELEMENT (element_1)' failed
[ERROR] [1556726135.431327179]: Unsupported media type.
[audio/audio_capture-2] process has died [pid 13060, exit code 1, cmd /root/catkin_ws/devel/lib/audio_capture/audio_capture __name:=audio_capture __log:=/root/.ros/log/8de21388-6c29-11e9-8596-8cec4bfad6f9/audio-audio_capture-2.log].
log file: /root/.ros/log/8de21388-6c29-11e9-8596-8cec4bfad6f9/audio-audio_capture-2*.log

I am running my build environment in docker. I think I am not able to access the ALSA device from the docker container. I included the following in my docker script for the ALSA device --device /dev/snd successfully catkin_make but I get the same error.

edit retag flag offensive close merge delete

Comments

1

We're all here to help, but just to avoid suggesting things you've already seen/tried/implemented: what have you found yourself? What worked, what didn't, and why did it, or didn't it?

gvdhoorn gravatar image gvdhoorn  ( 2019-04-29 13:44:42 -0500 )edit

I have found an existing ros feature - http://wiki.ros.org/audio_common/Tuto... . I will get my microphone in a couple days and will try using the tutorial to see where I get.

wskway gravatar image wskway  ( 2019-04-29 17:17:10 -0500 )edit

I am stuck on how to specify my internal microphone as a source. Does anybody know how I can use my headset microphone as a device for this launch.

wskway gravatar image wskway  ( 2019-04-30 13:12:08 -0500 )edit

@wskway Comments aren't really an appropriate place to additional information about your question (due to length limitations for one reason). So, can you please update your question with that information instead of leaving it as a comment?

jayess gravatar image jayess  ( 2019-04-30 19:51:42 -0500 )edit

Thanks for the feedback. I will update my question with my recent comments.

wskway gravatar image wskway  ( 2019-05-01 10:54:05 -0500 )edit