Comments (2)
[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.
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)
- memory leak in audio_play HOT 4
- Parameter name error HOT 3
- Convert rclcpp nodes into components HOT 2
- Make all nodes to nodelet
- AudioData 8 bit integer
- Release AudioDataStamped in noetic HOT 2
- Can we play sound in systemd service + no login?
- Backporting plugin feature to ROS2 branch
- Can't get ROS 2 branch to work in ROS2 humble HOT 25
- Importing the sound_play module is slow HOT 1
- sound_play command not being executed in a docker environment HOT 1
- ros2 branch is not compiling for ROS 2 Humble HOT 4
- ROS2 foxy: Problem when writing to wav file. HOT 2
- ros2 branch has ros1 headers HOT 6
- Question/Tutorial : how to effectively use audio_capture_node in ROS2 HOT 3
- ROS2 Branch: SoundClient blocking mode does not work HOT 4
- Add audio common ros2 branch to `iron` distribution HOT 2
- Replacing `GObject` with `GLib` due to deprecation of `threads_init()` and `GObject.MainLoop`
- Can't cancel loop sounds via action
- How can i play an incoming AudioMessage HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from audio_common.