Giter Site home page Giter Site logo

Comments (2)

ahendrix avatar ahendrix commented on July 16, 2024

[kstrabala] The data field in each ROS audio_common_msgs/AudioData message contains mp3 frames for the audio data. Simple concatenation will give you a valid mp3 audio file. From this knowledge, you can use other tools such as lame to convert the mp3 frames into other formats.

Below, I've included a simple Python script to convert a rosbag of audio data into an .mp3 file.

{{{
from ros import rosbag

def extract_audio(bag_path, topic_name, mp3_path):
print 'Opening bag'
bag = rosbag.Bag(bag_path)
mp3_file = open(mp3_path, 'w')
print 'Reading audio messages and saving to mp3 file'
msg_count = 0
for topic, msg, stamp in bag.read_messages(topics=[topic_name]):
if msg._type == 'audio_common_msgs/AudioData':
msg_count += 1
mp3_file.write(''.join(msg.data))
bag.close()
mp3_file.close()
print 'Done. %d audio messages written to %s'%(msg_count, mp3_path)
}}}

from audio_common.

himanshuwalia avatar himanshuwalia commented on July 16, 2024

Hi,
I am trying to capture audio via a microphone, i have successful in capturing the audio as mp3 as also extracting the ros messages back to mp3 format, but i would like to extract them and save them as .wav format, while capturing i have given the argument for format as wave, it is successfully saving the rosbag file.
Could you please help me with the extraction part from rosbag to .wav file.

from audio_common.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.