|
Package Summary
Tags | No category tags. |
Version | 1.2.17 |
License | BSD |
Build type | CATKIN |
Use | RECOMMENDED |
Repository Summary
Checkout URI | https://github.com/jsk-ros-pkg/jsk_recognition.git |
VCS Type | git |
VCS Version | master |
Last Updated | 2024-10-29 |
Dev Status | DEVELOPED |
CI status | No Continuous Integration |
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Package Description
Additional Links
Maintainers
- Naoya Yamaguchi
Authors
audio_to_spectrogram
This package converts audio data (or other time-series data) to spectrum and spectrogram data.
Usage
By following command, you can publish audio, spectrum and spectrogram topics. Please set correct args for your microphone configuration, such as mic_sampling_rate or bitdepth.
roslaunch audio_to_spectrogram audio_to_spectrogram.launch
Its data conversion pipeline is as follows:
audio_to_spectrum.py -> spectrum
-> normalized_half_spectrum
-> log_spectrum -> preprocess node(s) -> preprocessed spectrum -> spectrum_to_spectrogram.py -> spectrogram
Here is an example using rosbag with 300Hz audio.
roslaunch audio_to_spectrogram sample_audio_to_spectrogram.launch
Audio Amplitude | Spectrum | Spectrogram |
---|---|---|
You can also convert data other than audio to spectrum and spectrogram data using this package.
Here is an example using rosbag of a force torque sensor sensing drill vibration.
roslaunch audio_to_spectrogram sample_wrench_to_spectrogram.launch
Z-axis Force Amplitude | Normalized Half Spectrum | Spectrogram Source Spectrum | Spectrogram |
---|---|---|---|
Scripts
audio_to_spectrum.py
A script to convert audio to spectrum.
-
Publishing topics
-
~spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data calculated from audio by FFT.
It is usual “amplitude spectrum”.
See https://ryo-iijima.com/fftresult/ for details. -
~normalized_half_spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data which is “half” (having non-negative frequencies (0Hz-Nyquist frequency)) and is “normalized” (consistent with the amplitude of the original signal).
See the following for details.- https://ryo-iijima.com/fftresult/
- https://stackoverflow.com/questions/63211851/why-divide-the-output-of-numpy-fft-by-n
- https://github.com/jsk-ros-pkg/jsk_recognition/issues/2761#issue-1550715400
-
~log_spectrum
(jsk_recognition_msgs/Spectrum
)Log-scaled spectrum data.
It is calculated by applying log to the absolute value of the FFT result.
Usually, log is applied to “power spectrum”, but we don’t use it for simplicity.
See the following for details.- https://github.com/jsk-ros-pkg/jsk_recognition/issues/2761#issuecomment-1445810380
- http://makotomurakami.com/blog/2020/05/23/5266/
-
-
Subscribing topics
-
~audio
(audio_common_msgs/AudioData
)Audio stream data from microphone. The audio format must be
wave
.
-
-
Parameters
-
~mic_sampling_rate
(Int
, default:16000
)Sampling rate [Hz] of microphone. Namely, sampling rate of audio topic.
-
~fft_sampling_period
(Double
, default:0.3
)Period [s] to sample audio data for one FFT.
-
~n_channel
(Int
, default:1
)Number of channel of microphone.
-
~target_channel
(Int
, default:0
)Target channel.
-
~bitdepth
(Int
, default:16
)Number of bits per audio data.
-
~fft_exec_rate
(Double
, default:50
)Rate [Hz] to execute FFT and publish its results.
-
data_to_spectrum.py
Generalized version of audio_to_spectrum.py
.
This script can convert multiple message types to spectrum.
-
Publishing topics
Same as
audio_to_spectrum.py
. -
Subscribing topics
-
~input
(AnyMsg
)Topic to which message including data you want to convert to spectrum is published.
-
-
Parameters
-
~expression_to_get_data
(String
, default:m.data
)Python expression to get data from the input message
m
. For example, if your input isstd_msgs/Float64
, it ism.data
.
Just accessing a field ofm
is recommended.
If you want to do a complex calculation (e.g., usingnumpy
), usetransform
oftopic_tools
before this node. -
~data_sampling_rate
(Int
, default:500
)Sampling rate [Hz] of input data.
-
~fft_sampling_period
(Double
, default:0.3
)Period [s] to sample input data for one FFT.
-
~fft_exec_rate
(Double
, default:50
)Rate [Hz] to execute FFT and publish its results.
-
~is_integer
(Bool
, default:false
)Whether input data is integer or not. For example, if your input is
std_msgs/Float64
, it isfalse
. -
~is_signed
(Bool
, default:true
)Whether input data is signed or not. For example, if your input is
std_msgs/Float64
, it istrue
. -
~bitdepth
(Int
, default:64
)Number of bits per input data. For example, if your input is
std_msgs/Float64
, it is64
. -
~n_channel
(Int
, default:1
)If your input is scalar, it is
1
.
If your input is flattened 2D matrix, it is number of channel of original matrix. -
~target_channel
(Int
, default:0
)If your input is scalar, it is
0
.
If your input is flattened 2D matrix, it is target channel.
-
spectrum_filter.py
A script to filter spectrum.
-
Publishing topics
-
~output
(jsk_recognition_msgs/Spectrum
)Filtered spectrum data (
low_cut_freq
-high_cut_freq
).
-
-
Subscribing topics
-
~input
(jsk_recognition_msgs/Spectrum
)Original spectrum data.
-
-
Parameters
-
~data_sampling_rate
(Int
, default:500
)Sampling rate [Hz] of data used in generation of original spectrum data.
-
~high_cut_freq
(Int
, default:250
)Threshold to limit the maximum frequency of the output spectrum.
-
~low_cut_freq
(Int
, default:0
)Threshold to limit the minimum frequency of the output spectrum.
-
spectrum_to_spectrogram.py
A script to convert spectrum to spectrogram.
-
Publishing topics
-
~spectrogram
(sensor_msgs/Image
)Spectrogram data, which is concatenation of spectrum in time series. Image format is 32FC1.
-
-
Subscribing topics
-
~spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data calculated from audio by FFT.
-
-
Parameters
-
~image_height
(Int
, default:300
)Number of vertical (frequency axis) pixels in output spectrogram.
-
~image_width
(Int
, default:300
)Number of horizontal (time axis) pixels in output spectrogram.
-
~spectrogram_period
(Double
, default:5
)Period [s] to store spectrum data to create one spectrogram topic.
-
~publish_rate
(Double
, default:image_width / spectrogram_period
)Publish rate [Hz] of spectrogram topic.
-
audio_amplitude_plot.py
A script to publish audio amplitude plot image.
-
Publishing topics
-
~output/viz
(sensor_msgs/Image
)Audio amplitude plot image.
-
-
Subscribing topics
-
~audio
(audio_common_msgs/AudioData
)Audio stream data from microphone. The audio format must be
wave
.
-
-
Parameters
-
~mic_sampling_rate
(Int
, default:16000
)Sampling rate [Hz] of microphone. Namely, sampling rate of audio topic.
-
~n_channel
(Int
, default:1
)Number of channel of microphone.
-
~target_channel
(Int
, default:0
)Target channel.
-
~bitdepth
(Int
, default:16
)Number of bits per audio data.
-
~maximum_amplitude
(Double
, default:10000.0
)Maximum range of amplitude to plot.
-
~window_size
(Double
, default:10.0
)Window size of sound input to plot.
-
~rate
(Double
, default:10.0
)Publish rate [Hz] of audio amplitude image topic.
-
data_amplitude_plot.py
Generalized version of audio_amplitude_plot.py
.
-
Publishing topics
-
~output/viz
(sensor_msgs/Image
)Data amplitude plot image.
-
-
Subscribing topics
-
~input
(AnyMsg
)Topic to which message including data whose amplitude you want to plot is published.
-
-
Parameters
-
~expression_to_get_data
(String
, default:m.data
)Python expression to get data from the input message
m
. For example, if your input isstd_msgs/Float64
, it ism.data
.
Just accessing a field ofm
is recommended.
If you want to do a complex calculation (e.g., usingnumpy
), usetransform
oftopic_tools
before this node. -
~data_sampling_rate
(Int
, default:500
)Sampling rate [Hz] of input data.
-
~is_integer
(Bool
, default:false
)Whether input data is integer or not. For example, if your input is
std_msgs/Float64
, it isfalse
. -
~is_signed
(Bool
, default:true
)Whether input data is signed or not. For example, if your input is
std_msgs/Float64
, it istrue
. -
~bitdepth
(Int
, default:64
)Number of bits per input data. For example, if your input is
std_msgs/Float64
, it is64
. -
~n_channel
(Int
, default:1
)If your input is scalar, it is
1
.
If your input is flattened 2D matrix, it is number of channel of original matrix. -
~target_channel
(Int
, default:0
)If your input is scalar, it is
0
.
If your input is flattened 2D matrix, it is target channel. -
~maximum_amplitude
(Double
, default:10.0
)Maximum range of amplitude to plot.
-
~window_size
(Double
, default:10.0
)Window size of input data to plot.
-
~rate
(Double
, default:10.0
)Publish rate [Hz] of data amplitude image topic.
-
spectrum_plot.py
A script to publish frequency vs amplitude plot image.
-
Publishing topics
-
~output/viz
(sensor_msgs/Image
)Frequency vs amplitude plot image.
-
-
Subscribing topics
-
~spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data calculated from audio by FFT.
-
-
Parameters
-
~min_amp
(Double
, default:0.0
)Minimum value of amplitude in plot.
-
~max_amp
(Double
, default:20.0
)Maximum value of amplitude in plot.
-
~queue_size
(Int
, default:1
)Queue size of spectrum subscriber.
-
~max_rate
(Double
, default:-1
)Maximum publish rate [Hz] of frequency vs amplitude plot image. Setting this value low reduces CPU load.
-1
means no maximum limit.
-
Changelog for package audio_to_spectrogram
1.2.17 (2023-11-14)
1.2.16 (2023-11-10)
- [audio_to_spectrogram, sound_classification] Add data_to_spectrogram (#2767)
- [audio_to_spectrogram] Enable to change spectrum plot from rosparam (#2760)
- Fix audio to spectrogram plot and add test (#2764)
- [audio_to_spectrogram] Add AudioAmplitudePlot node to visualize audio amplitude #2657 (#2755)
- [audio_to_spectrogram] Enable publishing frequency vs amplitude plot (#2654)
- use catkin_install_python to install python scripts under node_scripts/ scripts/ (#2743)
- Contributors: Kei Okada, Naoto Tsukamoto, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Iory Yanokura
1.2.15 (2020-10-10)
1.2.14 (2020-10-09)
1.2.13 (2020-10-08)
1.2.12 (2020-10-03)
1.2.11 (2020-10-01)
- Fix for noetic / 20.04
(#2507)
- upgrade package.xml to format=3, migrate to noetic with ROS_PYTHON_VERSION=2/3, use multiple ROS distro strategy http://wiki.ros.org/noetic/Migration
- [audio_to_spectrogram] Enable multi channel input by retrieving single channel data (#2514)
- [audio_to_spectrogram] Add README for usage and scripts
interface
(#2498)
- [audio_to_spectrogram] Add README for usage and scripts interface
- [audio_to_spectrogram] add args to audio_to_spectrogram.launch
- [audio_to_spectrogram] Add arg to run audio_capture
- Convert audio data to spectrogram
(#2478)
- Make audio_to_spectrogram as ROS package
- Contributors: Kei Okada, Naoya Yamaguchi, Shingo Kitagawa
1.2.10 (2019-03-27)
1.2.9 (2019-02-23)
1.2.8 (2019-02-22)
1.2.7 (2019-02-14)
1.2.6 (2018-11-02)
1.2.5 (2018-04-09)
1.2.4 (2018-01-12)
1.2.3 (2017-11-23)
1.2.2 (2017-07-23)
1.2.1 (2017-07-15 20:44)
1.2.0 (2017-07-15 09:14)
1.1.3 (2017-07-07)
1.1.2 (2017-06-16)
1.1.1 (2017-03-04)
1.1.0 (2017-02-09 22:50)
1.0.4 (2017-02-09 22:48)
1.0.3 (2017-02-08)
1.0.2 (2017-01-12)
1.0.1 (2016-12-13)
1.0.0 (2016-12-12)
0.3.29 (2016-10-30)
0.3.28 (2016-10-29 16:34)
0.3.27 (2016-10-29 00:14)
0.3.26 (2016-10-27)
0.3.25 (2016-09-16)
0.3.24 (2016-09-15)
0.3.23 (2016-09-14)
0.3.22 (2016-09-13)
0.3.21 (2016-04-15)
0.3.20 (2016-04-14)
0.3.19 (2016-03-22)
0.3.18 (2016-03-21)
0.3.17 (2016-03-20)
0.3.16 (2016-02-11)
0.3.15 (2016-02-09)
0.3.14 (2016-02-04)
0.3.13 (2015-12-19 17:35)
0.3.12 (2015-12-19 14:44)
0.3.11 (2015-12-18)
0.3.10 (2015-12-17)
0.3.9 (2015-12-14)
0.3.8 (2015-12-08)
0.3.7 (2015-11-19)
0.3.6 (2015-09-11)
0.3.5 (2015-09-09)
0.3.4 (2015-09-07)
0.3.3 (2015-09-06)
0.3.2 (2015-09-05)
0.3.1 (2015-09-04 17:12)
0.3.0 (2015-09-04 12:37)
0.2.18 (2015-09-04 01:07)
0.2.17 (2015-08-21)
0.2.16 (2015-08-19)
0.2.15 (2015-08-18)
0.2.14 (2015-08-13)
0.2.13 (2015-06-11)
0.2.12 (2015-05-04)
0.2.11 (2015-04-13)
0.2.10 (2015-04-09)
0.2.9 (2015-03-29)
0.2.7 (2015-03-26)
0.2.6 (2015-03-25)
0.2.5 (2015-03-17)
0.2.4 (2015-03-08)
0.2.3 (2015-02-02)
0.2.2 (2015-01-30)
0.2.0 (2015-01-29 12:20)
0.1.34 (2015-01-29 11:53)
0.1.33 (2015-01-24)
0.1.32 (2015-01-12)
0.1.31 (2015-01-08)
0.1.30 (2014-12-24 16:45)
0.1.29 (2014-12-24 12:43)
0.1.28 (2014-12-17)
0.1.27 (2014-12-09)
0.1.26 (2014-11-23)
0.1.25 (2014-11-21)
0.1.24 (2014-11-15)
0.1.23 (2014-10-09)
0.1.22 (2014-09-24)
0.1.21 (2014-09-20)
0.1.20 (2014-09-17)
0.1.19 (2014-09-15)
0.1.18 (2014-09-13)
0.1.17 (2014-09-07)
0.1.16 (2014-09-04)
0.1.15 (2014-08-26)
0.1.14 (2014-08-01)
0.1.13 (2014-07-29)
0.1.12 (2014-07-24)
0.1.11 (2014-07-08)
0.1.10 (2014-07-07)
0.1.9 (2014-07-01)
0.1.8 (2014-06-29)
0.1.7 (2014-05-31)
0.1.6 (2014-05-30)
0.1.5 (2014-05-29)
0.1.4 (2014-04-25)
0.1.3 (2014-04-12)
0.1.2 (2014-04-11)
0.1.1 (2014-04-10)
Wiki Tutorials
Package Dependencies
System Dependencies
Dependant Packages
Name | Deps |
---|---|
sound_classification |
Launch files
- sample/sample_wrench_to_spectrogram.launch
-
- gui [default: true]
- filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]
- sample/sample_audio_to_spectrogram.launch
- data flow
-
- gui [default: true]
- filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
- launch/audio_to_spectrogram.launch
- data flow
-
- launch_audio_capture [default: true]
- audio_capture_ns [default: /]
- bitdepth [default: 16]
- mic_sampling_rate [default: 16000]
- n_channel [default: 1]
- target_channel [default: 0]
- device [default: hw:0,0]
- audio_topic [default: /audio]
- fft_sampling_period [default: 0.3]
- fft_exec_rate [default: 50]
- audio_amp_plot_max_amp [default: 10000.0]
- audio_amp_plot_window_size [default: 10.0]
- audio_amp_plot_rate [default: 10.0]
- spectrogram_source [default: audio_to_spectrum/log_spectrum]
- high_cut_freq [default: 800]
- low_cut_freq [default: 1]
- spectrogram_period [default: 5]
- preprocessed_spectrogram_source_plot_min_amp [default: 0.0]
- preprocessed_spectrogram_source_plot_max_amp [default: 20.0]
- preprocessed_spectrogram_source_plot_queue_size [default: 1]
- preprocessed_spectrogram_source_plot_max_rate [default: -1]
- gui [default: true]
- launch/spectrum_plot.launch
-
- spectrum
- plotter_name [default: spectrum_plot]
- min_amp [default: 0.0]
- max_amp [default: 20.0]
- queue_size [default: 1]
- max_rate [default: -1]
- gui [default: true]
- launch/wrench_to_spectrogram.launch
- data flow
-
- how_to_get_scalar [default: element_extraction]
- target_element [default: force.z]
- data_sampling_rate [default: 500]
- wrench_topic [default: /ft_sensor]
- fft_sampling_period [default: 0.3]
- fft_exec_rate [default: 50]
- data_amp_plot_max_amp [default: 10.0]
- data_amp_plot_window_size [default: 10.0]
- data_amp_plot_rate [default: 10.0]
- spectrogram_source [default: data_to_spectrum/log_spectrum]
- high_cut_freq [default: 250]
- low_cut_freq [default: 5]
- spectrogram_period [default: 5]
- preprocessed_spectrogram_source_plot_min_amp [default: -10.0]
- preprocessed_spectrogram_source_plot_max_amp [default: 10.0]
- preprocessed_spectrogram_source_plot_queue_size [default: 1]
- preprocessed_spectrogram_source_plot_max_rate [default: -1]
- normalized_half_spectrum_plot_min_amp [default: 0.0]
- normalized_half_spectrum_plot_max_amp [default: 0.2]
- normalized_half_spectrum_plot_queue_size [default: 1]
- normalized_half_spectrum_plot_max_rate [default: -1]
- gui [default: true]
- launch/spectrum_to_spectrogram.launch
-
- spectrum
- data_sampling_rate [default: 500]
- high_cut_freq [default: 250]
- low_cut_freq [default: 5]
- spectrogram_height [default: 300]
- spectrogram_width [default: 300]
- spectrogram_period [default: 5]
- preprocessed_spectrum_plot_min_amp [default: -10.0]
- preprocessed_spectrum_plot_max_amp [default: 10.0]
- preprocessed_spectrum_plot_queue_size [default: 1]
- preprocessed_spectrum_plot_max_rate [default: -1]
- gui [default: true]
- do_dynamic_scaling [default: true]
- colormap [default: 2]
- launch/data_to_spectrum.launch
-
- data_topic
- expression_to_get_data [default: m.data]
- data_sampling_rate [default: 500]
- fft_sampling_period [default: 0.3]
- is_integer [default: false]
- is_signed [default: true]
- bitdepth [default: 64]
- n_channel [default: 1]
- target_channel [default: 0]
- fft_exec_rate [default: 50]
- data_amp_plot_max_amp [default: 10.0]
- data_amp_plot_window_size [default: 10.0]
- data_amp_plot_rate [default: 10.0]
- gui [default: true]
- launch/audio_to_spectrum.launch
-
- audio_topic [default: /audio]
- n_channel [default: 1]
- target_channel [default: 0]
- mic_sampling_rate [default: 16000]
- fft_sampling_period [default: 0.3]
- bitdepth [default: 16]
- fft_exec_rate [default: 50]
- audio_amp_plot_max_amp [default: 10000.0]
- audio_amp_plot_window_size [default: 10.0]
- audio_amp_plot_rate [default: 10.0]
- gui [default: true]
Messages
Services
Plugins
Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange
|
Package Summary
Tags | No category tags. |
Version | 1.2.17 |
License | BSD |
Build type | CATKIN |
Use | RECOMMENDED |
Repository Summary
Checkout URI | https://github.com/jsk-ros-pkg/jsk_recognition.git |
VCS Type | git |
VCS Version | master |
Last Updated | 2024-10-29 |
Dev Status | DEVELOPED |
CI status | No Continuous Integration |
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Package Description
Additional Links
Maintainers
- Naoya Yamaguchi
Authors
audio_to_spectrogram
This package converts audio data (or other time-series data) to spectrum and spectrogram data.
Usage
By following command, you can publish audio, spectrum and spectrogram topics. Please set correct args for your microphone configuration, such as mic_sampling_rate or bitdepth.
roslaunch audio_to_spectrogram audio_to_spectrogram.launch
Its data conversion pipeline is as follows:
audio_to_spectrum.py -> spectrum
-> normalized_half_spectrum
-> log_spectrum -> preprocess node(s) -> preprocessed spectrum -> spectrum_to_spectrogram.py -> spectrogram
Here is an example using rosbag with 300Hz audio.
roslaunch audio_to_spectrogram sample_audio_to_spectrogram.launch
Audio Amplitude | Spectrum | Spectrogram |
---|---|---|
You can also convert data other than audio to spectrum and spectrogram data using this package.
Here is an example using rosbag of a force torque sensor sensing drill vibration.
roslaunch audio_to_spectrogram sample_wrench_to_spectrogram.launch
Z-axis Force Amplitude | Normalized Half Spectrum | Spectrogram Source Spectrum | Spectrogram |
---|---|---|---|
Scripts
audio_to_spectrum.py
A script to convert audio to spectrum.
-
Publishing topics
-
~spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data calculated from audio by FFT.
It is usual “amplitude spectrum”.
See https://ryo-iijima.com/fftresult/ for details. -
~normalized_half_spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data which is “half” (having non-negative frequencies (0Hz-Nyquist frequency)) and is “normalized” (consistent with the amplitude of the original signal).
See the following for details.- https://ryo-iijima.com/fftresult/
- https://stackoverflow.com/questions/63211851/why-divide-the-output-of-numpy-fft-by-n
- https://github.com/jsk-ros-pkg/jsk_recognition/issues/2761#issue-1550715400
-
~log_spectrum
(jsk_recognition_msgs/Spectrum
)Log-scaled spectrum data.
It is calculated by applying log to the absolute value of the FFT result.
Usually, log is applied to “power spectrum”, but we don’t use it for simplicity.
See the following for details.- https://github.com/jsk-ros-pkg/jsk_recognition/issues/2761#issuecomment-1445810380
- http://makotomurakami.com/blog/2020/05/23/5266/
-
-
Subscribing topics
-
~audio
(audio_common_msgs/AudioData
)Audio stream data from microphone. The audio format must be
wave
.
-
-
Parameters
-
~mic_sampling_rate
(Int
, default:16000
)Sampling rate [Hz] of microphone. Namely, sampling rate of audio topic.
-
~fft_sampling_period
(Double
, default:0.3
)Period [s] to sample audio data for one FFT.
-
~n_channel
(Int
, default:1
)Number of channel of microphone.
-
~target_channel
(Int
, default:0
)Target channel.
-
~bitdepth
(Int
, default:16
)Number of bits per audio data.
-
~fft_exec_rate
(Double
, default:50
)Rate [Hz] to execute FFT and publish its results.
-
data_to_spectrum.py
Generalized version of audio_to_spectrum.py
.
This script can convert multiple message types to spectrum.
-
Publishing topics
Same as
audio_to_spectrum.py
. -
Subscribing topics
-
~input
(AnyMsg
)Topic to which message including data you want to convert to spectrum is published.
-
-
Parameters
-
~expression_to_get_data
(String
, default:m.data
)Python expression to get data from the input message
m
. For example, if your input isstd_msgs/Float64
, it ism.data
.
Just accessing a field ofm
is recommended.
If you want to do a complex calculation (e.g., usingnumpy
), usetransform
oftopic_tools
before this node. -
~data_sampling_rate
(Int
, default:500
)Sampling rate [Hz] of input data.
-
~fft_sampling_period
(Double
, default:0.3
)Period [s] to sample input data for one FFT.
-
~fft_exec_rate
(Double
, default:50
)Rate [Hz] to execute FFT and publish its results.
-
~is_integer
(Bool
, default:false
)Whether input data is integer or not. For example, if your input is
std_msgs/Float64
, it isfalse
. -
~is_signed
(Bool
, default:true
)Whether input data is signed or not. For example, if your input is
std_msgs/Float64
, it istrue
. -
~bitdepth
(Int
, default:64
)Number of bits per input data. For example, if your input is
std_msgs/Float64
, it is64
. -
~n_channel
(Int
, default:1
)If your input is scalar, it is
1
.
If your input is flattened 2D matrix, it is number of channel of original matrix. -
~target_channel
(Int
, default:0
)If your input is scalar, it is
0
.
If your input is flattened 2D matrix, it is target channel.
-
spectrum_filter.py
A script to filter spectrum.
-
Publishing topics
-
~output
(jsk_recognition_msgs/Spectrum
)Filtered spectrum data (
low_cut_freq
-high_cut_freq
).
-
-
Subscribing topics
-
~input
(jsk_recognition_msgs/Spectrum
)Original spectrum data.
-
-
Parameters
-
~data_sampling_rate
(Int
, default:500
)Sampling rate [Hz] of data used in generation of original spectrum data.
-
~high_cut_freq
(Int
, default:250
)Threshold to limit the maximum frequency of the output spectrum.
-
~low_cut_freq
(Int
, default:0
)Threshold to limit the minimum frequency of the output spectrum.
-
spectrum_to_spectrogram.py
A script to convert spectrum to spectrogram.
-
Publishing topics
-
~spectrogram
(sensor_msgs/Image
)Spectrogram data, which is concatenation of spectrum in time series. Image format is 32FC1.
-
-
Subscribing topics
-
~spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data calculated from audio by FFT.
-
-
Parameters
-
~image_height
(Int
, default:300
)Number of vertical (frequency axis) pixels in output spectrogram.
-
~image_width
(Int
, default:300
)Number of horizontal (time axis) pixels in output spectrogram.
-
~spectrogram_period
(Double
, default:5
)Period [s] to store spectrum data to create one spectrogram topic.
-
~publish_rate
(Double
, default:image_width / spectrogram_period
)Publish rate [Hz] of spectrogram topic.
-
audio_amplitude_plot.py
A script to publish audio amplitude plot image.
-
Publishing topics
-
~output/viz
(sensor_msgs/Image
)Audio amplitude plot image.
-
-
Subscribing topics
-
~audio
(audio_common_msgs/AudioData
)Audio stream data from microphone. The audio format must be
wave
.
-
-
Parameters
-
~mic_sampling_rate
(Int
, default:16000
)Sampling rate [Hz] of microphone. Namely, sampling rate of audio topic.
-
~n_channel
(Int
, default:1
)Number of channel of microphone.
-
~target_channel
(Int
, default:0
)Target channel.
-
~bitdepth
(Int
, default:16
)Number of bits per audio data.
-
~maximum_amplitude
(Double
, default:10000.0
)Maximum range of amplitude to plot.
-
~window_size
(Double
, default:10.0
)Window size of sound input to plot.
-
~rate
(Double
, default:10.0
)Publish rate [Hz] of audio amplitude image topic.
-
data_amplitude_plot.py
Generalized version of audio_amplitude_plot.py
.
-
Publishing topics
-
~output/viz
(sensor_msgs/Image
)Data amplitude plot image.
-
-
Subscribing topics
-
~input
(AnyMsg
)Topic to which message including data whose amplitude you want to plot is published.
-
-
Parameters
-
~expression_to_get_data
(String
, default:m.data
)Python expression to get data from the input message
m
. For example, if your input isstd_msgs/Float64
, it ism.data
.
Just accessing a field ofm
is recommended.
If you want to do a complex calculation (e.g., usingnumpy
), usetransform
oftopic_tools
before this node. -
~data_sampling_rate
(Int
, default:500
)Sampling rate [Hz] of input data.
-
~is_integer
(Bool
, default:false
)Whether input data is integer or not. For example, if your input is
std_msgs/Float64
, it isfalse
. -
~is_signed
(Bool
, default:true
)Whether input data is signed or not. For example, if your input is
std_msgs/Float64
, it istrue
. -
~bitdepth
(Int
, default:64
)Number of bits per input data. For example, if your input is
std_msgs/Float64
, it is64
. -
~n_channel
(Int
, default:1
)If your input is scalar, it is
1
.
If your input is flattened 2D matrix, it is number of channel of original matrix. -
~target_channel
(Int
, default:0
)If your input is scalar, it is
0
.
If your input is flattened 2D matrix, it is target channel. -
~maximum_amplitude
(Double
, default:10.0
)Maximum range of amplitude to plot.
-
~window_size
(Double
, default:10.0
)Window size of input data to plot.
-
~rate
(Double
, default:10.0
)Publish rate [Hz] of data amplitude image topic.
-
spectrum_plot.py
A script to publish frequency vs amplitude plot image.
-
Publishing topics
-
~output/viz
(sensor_msgs/Image
)Frequency vs amplitude plot image.
-
-
Subscribing topics
-
~spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data calculated from audio by FFT.
-
-
Parameters
-
~min_amp
(Double
, default:0.0
)Minimum value of amplitude in plot.
-
~max_amp
(Double
, default:20.0
)Maximum value of amplitude in plot.
-
~queue_size
(Int
, default:1
)Queue size of spectrum subscriber.
-
~max_rate
(Double
, default:-1
)Maximum publish rate [Hz] of frequency vs amplitude plot image. Setting this value low reduces CPU load.
-1
means no maximum limit.
-
Changelog for package audio_to_spectrogram
1.2.17 (2023-11-14)
1.2.16 (2023-11-10)
- [audio_to_spectrogram, sound_classification] Add data_to_spectrogram (#2767)
- [audio_to_spectrogram] Enable to change spectrum plot from rosparam (#2760)
- Fix audio to spectrogram plot and add test (#2764)
- [audio_to_spectrogram] Add AudioAmplitudePlot node to visualize audio amplitude #2657 (#2755)
- [audio_to_spectrogram] Enable publishing frequency vs amplitude plot (#2654)
- use catkin_install_python to install python scripts under node_scripts/ scripts/ (#2743)
- Contributors: Kei Okada, Naoto Tsukamoto, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Iory Yanokura
1.2.15 (2020-10-10)
1.2.14 (2020-10-09)
1.2.13 (2020-10-08)
1.2.12 (2020-10-03)
1.2.11 (2020-10-01)
- Fix for noetic / 20.04
(#2507)
- upgrade package.xml to format=3, migrate to noetic with ROS_PYTHON_VERSION=2/3, use multiple ROS distro strategy http://wiki.ros.org/noetic/Migration
- [audio_to_spectrogram] Enable multi channel input by retrieving single channel data (#2514)
- [audio_to_spectrogram] Add README for usage and scripts
interface
(#2498)
- [audio_to_spectrogram] Add README for usage and scripts interface
- [audio_to_spectrogram] add args to audio_to_spectrogram.launch
- [audio_to_spectrogram] Add arg to run audio_capture
- Convert audio data to spectrogram
(#2478)
- Make audio_to_spectrogram as ROS package
- Contributors: Kei Okada, Naoya Yamaguchi, Shingo Kitagawa
1.2.10 (2019-03-27)
1.2.9 (2019-02-23)
1.2.8 (2019-02-22)
1.2.7 (2019-02-14)
1.2.6 (2018-11-02)
1.2.5 (2018-04-09)
1.2.4 (2018-01-12)
1.2.3 (2017-11-23)
1.2.2 (2017-07-23)
1.2.1 (2017-07-15 20:44)
1.2.0 (2017-07-15 09:14)
1.1.3 (2017-07-07)
1.1.2 (2017-06-16)
1.1.1 (2017-03-04)
1.1.0 (2017-02-09 22:50)
1.0.4 (2017-02-09 22:48)
1.0.3 (2017-02-08)
1.0.2 (2017-01-12)
1.0.1 (2016-12-13)
1.0.0 (2016-12-12)
0.3.29 (2016-10-30)
0.3.28 (2016-10-29 16:34)
0.3.27 (2016-10-29 00:14)
0.3.26 (2016-10-27)
0.3.25 (2016-09-16)
0.3.24 (2016-09-15)
0.3.23 (2016-09-14)
0.3.22 (2016-09-13)
0.3.21 (2016-04-15)
0.3.20 (2016-04-14)
0.3.19 (2016-03-22)
0.3.18 (2016-03-21)
0.3.17 (2016-03-20)
0.3.16 (2016-02-11)
0.3.15 (2016-02-09)
0.3.14 (2016-02-04)
0.3.13 (2015-12-19 17:35)
0.3.12 (2015-12-19 14:44)
0.3.11 (2015-12-18)
0.3.10 (2015-12-17)
0.3.9 (2015-12-14)
0.3.8 (2015-12-08)
0.3.7 (2015-11-19)
0.3.6 (2015-09-11)
0.3.5 (2015-09-09)
0.3.4 (2015-09-07)
0.3.3 (2015-09-06)
0.3.2 (2015-09-05)
0.3.1 (2015-09-04 17:12)
0.3.0 (2015-09-04 12:37)
0.2.18 (2015-09-04 01:07)
0.2.17 (2015-08-21)
0.2.16 (2015-08-19)
0.2.15 (2015-08-18)
0.2.14 (2015-08-13)
0.2.13 (2015-06-11)
0.2.12 (2015-05-04)
0.2.11 (2015-04-13)
0.2.10 (2015-04-09)
0.2.9 (2015-03-29)
0.2.7 (2015-03-26)
0.2.6 (2015-03-25)
0.2.5 (2015-03-17)
0.2.4 (2015-03-08)
0.2.3 (2015-02-02)
0.2.2 (2015-01-30)
0.2.0 (2015-01-29 12:20)
0.1.34 (2015-01-29 11:53)
0.1.33 (2015-01-24)
0.1.32 (2015-01-12)
0.1.31 (2015-01-08)
0.1.30 (2014-12-24 16:45)
0.1.29 (2014-12-24 12:43)
0.1.28 (2014-12-17)
0.1.27 (2014-12-09)
0.1.26 (2014-11-23)
0.1.25 (2014-11-21)
0.1.24 (2014-11-15)
0.1.23 (2014-10-09)
0.1.22 (2014-09-24)
0.1.21 (2014-09-20)
0.1.20 (2014-09-17)
0.1.19 (2014-09-15)
0.1.18 (2014-09-13)
0.1.17 (2014-09-07)
0.1.16 (2014-09-04)
0.1.15 (2014-08-26)
0.1.14 (2014-08-01)
0.1.13 (2014-07-29)
0.1.12 (2014-07-24)
0.1.11 (2014-07-08)
0.1.10 (2014-07-07)
0.1.9 (2014-07-01)
0.1.8 (2014-06-29)
0.1.7 (2014-05-31)
0.1.6 (2014-05-30)
0.1.5 (2014-05-29)
0.1.4 (2014-04-25)
0.1.3 (2014-04-12)
0.1.2 (2014-04-11)
0.1.1 (2014-04-10)
Wiki Tutorials
Package Dependencies
System Dependencies
Dependant Packages
Name | Deps |
---|---|
sound_classification |
Launch files
- sample/sample_wrench_to_spectrogram.launch
-
- gui [default: true]
- filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]
- sample/sample_audio_to_spectrogram.launch
- data flow
-
- gui [default: true]
- filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
- launch/audio_to_spectrogram.launch
- data flow
-
- launch_audio_capture [default: true]
- audio_capture_ns [default: /]
- bitdepth [default: 16]
- mic_sampling_rate [default: 16000]
- n_channel [default: 1]
- target_channel [default: 0]
- device [default: hw:0,0]
- audio_topic [default: /audio]
- fft_sampling_period [default: 0.3]
- fft_exec_rate [default: 50]
- audio_amp_plot_max_amp [default: 10000.0]
- audio_amp_plot_window_size [default: 10.0]
- audio_amp_plot_rate [default: 10.0]
- spectrogram_source [default: audio_to_spectrum/log_spectrum]
- high_cut_freq [default: 800]
- low_cut_freq [default: 1]
- spectrogram_period [default: 5]
- preprocessed_spectrogram_source_plot_min_amp [default: 0.0]
- preprocessed_spectrogram_source_plot_max_amp [default: 20.0]
- preprocessed_spectrogram_source_plot_queue_size [default: 1]
- preprocessed_spectrogram_source_plot_max_rate [default: -1]
- gui [default: true]
- launch/spectrum_plot.launch
-
- spectrum
- plotter_name [default: spectrum_plot]
- min_amp [default: 0.0]
- max_amp [default: 20.0]
- queue_size [default: 1]
- max_rate [default: -1]
- gui [default: true]
- launch/wrench_to_spectrogram.launch
- data flow
-
- how_to_get_scalar [default: element_extraction]
- target_element [default: force.z]
- data_sampling_rate [default: 500]
- wrench_topic [default: /ft_sensor]
- fft_sampling_period [default: 0.3]
- fft_exec_rate [default: 50]
- data_amp_plot_max_amp [default: 10.0]
- data_amp_plot_window_size [default: 10.0]
- data_amp_plot_rate [default: 10.0]
- spectrogram_source [default: data_to_spectrum/log_spectrum]
- high_cut_freq [default: 250]
- low_cut_freq [default: 5]
- spectrogram_period [default: 5]
- preprocessed_spectrogram_source_plot_min_amp [default: -10.0]
- preprocessed_spectrogram_source_plot_max_amp [default: 10.0]
- preprocessed_spectrogram_source_plot_queue_size [default: 1]
- preprocessed_spectrogram_source_plot_max_rate [default: -1]
- normalized_half_spectrum_plot_min_amp [default: 0.0]
- normalized_half_spectrum_plot_max_amp [default: 0.2]
- normalized_half_spectrum_plot_queue_size [default: 1]
- normalized_half_spectrum_plot_max_rate [default: -1]
- gui [default: true]
- launch/spectrum_to_spectrogram.launch
-
- spectrum
- data_sampling_rate [default: 500]
- high_cut_freq [default: 250]
- low_cut_freq [default: 5]
- spectrogram_height [default: 300]
- spectrogram_width [default: 300]
- spectrogram_period [default: 5]
- preprocessed_spectrum_plot_min_amp [default: -10.0]
- preprocessed_spectrum_plot_max_amp [default: 10.0]
- preprocessed_spectrum_plot_queue_size [default: 1]
- preprocessed_spectrum_plot_max_rate [default: -1]
- gui [default: true]
- do_dynamic_scaling [default: true]
- colormap [default: 2]
- launch/data_to_spectrum.launch
-
- data_topic
- expression_to_get_data [default: m.data]
- data_sampling_rate [default: 500]
- fft_sampling_period [default: 0.3]
- is_integer [default: false]
- is_signed [default: true]
- bitdepth [default: 64]
- n_channel [default: 1]
- target_channel [default: 0]
- fft_exec_rate [default: 50]
- data_amp_plot_max_amp [default: 10.0]
- data_amp_plot_window_size [default: 10.0]
- data_amp_plot_rate [default: 10.0]
- gui [default: true]
- launch/audio_to_spectrum.launch
-
- audio_topic [default: /audio]
- n_channel [default: 1]
- target_channel [default: 0]
- mic_sampling_rate [default: 16000]
- fft_sampling_period [default: 0.3]
- bitdepth [default: 16]
- fft_exec_rate [default: 50]
- audio_amp_plot_max_amp [default: 10000.0]
- audio_amp_plot_window_size [default: 10.0]
- audio_amp_plot_rate [default: 10.0]
- gui [default: true]
Messages
Services
Plugins
Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange
|
Package Summary
Tags | No category tags. |
Version | 1.2.17 |
License | BSD |
Build type | CATKIN |
Use | RECOMMENDED |
Repository Summary
Checkout URI | https://github.com/jsk-ros-pkg/jsk_recognition.git |
VCS Type | git |
VCS Version | master |
Last Updated | 2024-10-29 |
Dev Status | DEVELOPED |
CI status | No Continuous Integration |
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Package Description
Additional Links
Maintainers
- Naoya Yamaguchi
Authors
audio_to_spectrogram
This package converts audio data (or other time-series data) to spectrum and spectrogram data.
Usage
By following command, you can publish audio, spectrum and spectrogram topics. Please set correct args for your microphone configuration, such as mic_sampling_rate or bitdepth.
roslaunch audio_to_spectrogram audio_to_spectrogram.launch
Its data conversion pipeline is as follows:
audio_to_spectrum.py -> spectrum
-> normalized_half_spectrum
-> log_spectrum -> preprocess node(s) -> preprocessed spectrum -> spectrum_to_spectrogram.py -> spectrogram
Here is an example using rosbag with 300Hz audio.
roslaunch audio_to_spectrogram sample_audio_to_spectrogram.launch
Audio Amplitude | Spectrum | Spectrogram |
---|---|---|
You can also convert data other than audio to spectrum and spectrogram data using this package.
Here is an example using rosbag of a force torque sensor sensing drill vibration.
roslaunch audio_to_spectrogram sample_wrench_to_spectrogram.launch
Z-axis Force Amplitude | Normalized Half Spectrum | Spectrogram Source Spectrum | Spectrogram |
---|---|---|---|
Scripts
audio_to_spectrum.py
A script to convert audio to spectrum.
-
Publishing topics
-
~spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data calculated from audio by FFT.
It is usual “amplitude spectrum”.
See https://ryo-iijima.com/fftresult/ for details. -
~normalized_half_spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data which is “half” (having non-negative frequencies (0Hz-Nyquist frequency)) and is “normalized” (consistent with the amplitude of the original signal).
See the following for details.- https://ryo-iijima.com/fftresult/
- https://stackoverflow.com/questions/63211851/why-divide-the-output-of-numpy-fft-by-n
- https://github.com/jsk-ros-pkg/jsk_recognition/issues/2761#issue-1550715400
-
~log_spectrum
(jsk_recognition_msgs/Spectrum
)Log-scaled spectrum data.
It is calculated by applying log to the absolute value of the FFT result.
Usually, log is applied to “power spectrum”, but we don’t use it for simplicity.
See the following for details.- https://github.com/jsk-ros-pkg/jsk_recognition/issues/2761#issuecomment-1445810380
- http://makotomurakami.com/blog/2020/05/23/5266/
-
-
Subscribing topics
-
~audio
(audio_common_msgs/AudioData
)Audio stream data from microphone. The audio format must be
wave
.
-
-
Parameters
-
~mic_sampling_rate
(Int
, default:16000
)Sampling rate [Hz] of microphone. Namely, sampling rate of audio topic.
-
~fft_sampling_period
(Double
, default:0.3
)Period [s] to sample audio data for one FFT.
-
~n_channel
(Int
, default:1
)Number of channel of microphone.
-
~target_channel
(Int
, default:0
)Target channel.
-
~bitdepth
(Int
, default:16
)Number of bits per audio data.
-
~fft_exec_rate
(Double
, default:50
)Rate [Hz] to execute FFT and publish its results.
-
data_to_spectrum.py
Generalized version of audio_to_spectrum.py
.
This script can convert multiple message types to spectrum.
-
Publishing topics
Same as
audio_to_spectrum.py
. -
Subscribing topics
-
~input
(AnyMsg
)Topic to which message including data you want to convert to spectrum is published.
-
-
Parameters
-
~expression_to_get_data
(String
, default:m.data
)Python expression to get data from the input message
m
. For example, if your input isstd_msgs/Float64
, it ism.data
.
Just accessing a field ofm
is recommended.
If you want to do a complex calculation (e.g., usingnumpy
), usetransform
oftopic_tools
before this node. -
~data_sampling_rate
(Int
, default:500
)Sampling rate [Hz] of input data.
-
~fft_sampling_period
(Double
, default:0.3
)Period [s] to sample input data for one FFT.
-
~fft_exec_rate
(Double
, default:50
)Rate [Hz] to execute FFT and publish its results.
-
~is_integer
(Bool
, default:false
)Whether input data is integer or not. For example, if your input is
std_msgs/Float64
, it isfalse
. -
~is_signed
(Bool
, default:true
)Whether input data is signed or not. For example, if your input is
std_msgs/Float64
, it istrue
. -
~bitdepth
(Int
, default:64
)Number of bits per input data. For example, if your input is
std_msgs/Float64
, it is64
. -
~n_channel
(Int
, default:1
)If your input is scalar, it is
1
.
If your input is flattened 2D matrix, it is number of channel of original matrix. -
~target_channel
(Int
, default:0
)If your input is scalar, it is
0
.
If your input is flattened 2D matrix, it is target channel.
-
spectrum_filter.py
A script to filter spectrum.
-
Publishing topics
-
~output
(jsk_recognition_msgs/Spectrum
)Filtered spectrum data (
low_cut_freq
-high_cut_freq
).
-
-
Subscribing topics
-
~input
(jsk_recognition_msgs/Spectrum
)Original spectrum data.
-
-
Parameters
-
~data_sampling_rate
(Int
, default:500
)Sampling rate [Hz] of data used in generation of original spectrum data.
-
~high_cut_freq
(Int
, default:250
)Threshold to limit the maximum frequency of the output spectrum.
-
~low_cut_freq
(Int
, default:0
)Threshold to limit the minimum frequency of the output spectrum.
-
spectrum_to_spectrogram.py
A script to convert spectrum to spectrogram.
-
Publishing topics
-
~spectrogram
(sensor_msgs/Image
)Spectrogram data, which is concatenation of spectrum in time series. Image format is 32FC1.
-
-
Subscribing topics
-
~spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data calculated from audio by FFT.
-
-
Parameters
-
~image_height
(Int
, default:300
)Number of vertical (frequency axis) pixels in output spectrogram.
-
~image_width
(Int
, default:300
)Number of horizontal (time axis) pixels in output spectrogram.
-
~spectrogram_period
(Double
, default:5
)Period [s] to store spectrum data to create one spectrogram topic.
-
~publish_rate
(Double
, default:image_width / spectrogram_period
)Publish rate [Hz] of spectrogram topic.
-
audio_amplitude_plot.py
A script to publish audio amplitude plot image.
-
Publishing topics
-
~output/viz
(sensor_msgs/Image
)Audio amplitude plot image.
-
-
Subscribing topics
-
~audio
(audio_common_msgs/AudioData
)Audio stream data from microphone. The audio format must be
wave
.
-
-
Parameters
-
~mic_sampling_rate
(Int
, default:16000
)Sampling rate [Hz] of microphone. Namely, sampling rate of audio topic.
-
~n_channel
(Int
, default:1
)Number of channel of microphone.
-
~target_channel
(Int
, default:0
)Target channel.
-
~bitdepth
(Int
, default:16
)Number of bits per audio data.
-
~maximum_amplitude
(Double
, default:10000.0
)Maximum range of amplitude to plot.
-
~window_size
(Double
, default:10.0
)Window size of sound input to plot.
-
~rate
(Double
, default:10.0
)Publish rate [Hz] of audio amplitude image topic.
-
data_amplitude_plot.py
Generalized version of audio_amplitude_plot.py
.
-
Publishing topics
-
~output/viz
(sensor_msgs/Image
)Data amplitude plot image.
-
-
Subscribing topics
-
~input
(AnyMsg
)Topic to which message including data whose amplitude you want to plot is published.
-
-
Parameters
-
~expression_to_get_data
(String
, default:m.data
)Python expression to get data from the input message
m
. For example, if your input isstd_msgs/Float64
, it ism.data
.
Just accessing a field ofm
is recommended.
If you want to do a complex calculation (e.g., usingnumpy
), usetransform
oftopic_tools
before this node. -
~data_sampling_rate
(Int
, default:500
)Sampling rate [Hz] of input data.
-
~is_integer
(Bool
, default:false
)Whether input data is integer or not. For example, if your input is
std_msgs/Float64
, it isfalse
. -
~is_signed
(Bool
, default:true
)Whether input data is signed or not. For example, if your input is
std_msgs/Float64
, it istrue
. -
~bitdepth
(Int
, default:64
)Number of bits per input data. For example, if your input is
std_msgs/Float64
, it is64
. -
~n_channel
(Int
, default:1
)If your input is scalar, it is
1
.
If your input is flattened 2D matrix, it is number of channel of original matrix. -
~target_channel
(Int
, default:0
)If your input is scalar, it is
0
.
If your input is flattened 2D matrix, it is target channel. -
~maximum_amplitude
(Double
, default:10.0
)Maximum range of amplitude to plot.
-
~window_size
(Double
, default:10.0
)Window size of input data to plot.
-
~rate
(Double
, default:10.0
)Publish rate [Hz] of data amplitude image topic.
-
spectrum_plot.py
A script to publish frequency vs amplitude plot image.
-
Publishing topics
-
~output/viz
(sensor_msgs/Image
)Frequency vs amplitude plot image.
-
-
Subscribing topics
-
~spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data calculated from audio by FFT.
-
-
Parameters
-
~min_amp
(Double
, default:0.0
)Minimum value of amplitude in plot.
-
~max_amp
(Double
, default:20.0
)Maximum value of amplitude in plot.
-
~queue_size
(Int
, default:1
)Queue size of spectrum subscriber.
-
~max_rate
(Double
, default:-1
)Maximum publish rate [Hz] of frequency vs amplitude plot image. Setting this value low reduces CPU load.
-1
means no maximum limit.
-
Changelog for package audio_to_spectrogram
1.2.17 (2023-11-14)
1.2.16 (2023-11-10)
- [audio_to_spectrogram, sound_classification] Add data_to_spectrogram (#2767)
- [audio_to_spectrogram] Enable to change spectrum plot from rosparam (#2760)
- Fix audio to spectrogram plot and add test (#2764)
- [audio_to_spectrogram] Add AudioAmplitudePlot node to visualize audio amplitude #2657 (#2755)
- [audio_to_spectrogram] Enable publishing frequency vs amplitude plot (#2654)
- use catkin_install_python to install python scripts under node_scripts/ scripts/ (#2743)
- Contributors: Kei Okada, Naoto Tsukamoto, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Iory Yanokura
1.2.15 (2020-10-10)
1.2.14 (2020-10-09)
1.2.13 (2020-10-08)
1.2.12 (2020-10-03)
1.2.11 (2020-10-01)
- Fix for noetic / 20.04
(#2507)
- upgrade package.xml to format=3, migrate to noetic with ROS_PYTHON_VERSION=2/3, use multiple ROS distro strategy http://wiki.ros.org/noetic/Migration
- [audio_to_spectrogram] Enable multi channel input by retrieving single channel data (#2514)
- [audio_to_spectrogram] Add README for usage and scripts
interface
(#2498)
- [audio_to_spectrogram] Add README for usage and scripts interface
- [audio_to_spectrogram] add args to audio_to_spectrogram.launch
- [audio_to_spectrogram] Add arg to run audio_capture
- Convert audio data to spectrogram
(#2478)
- Make audio_to_spectrogram as ROS package
- Contributors: Kei Okada, Naoya Yamaguchi, Shingo Kitagawa
1.2.10 (2019-03-27)
1.2.9 (2019-02-23)
1.2.8 (2019-02-22)
1.2.7 (2019-02-14)
1.2.6 (2018-11-02)
1.2.5 (2018-04-09)
1.2.4 (2018-01-12)
1.2.3 (2017-11-23)
1.2.2 (2017-07-23)
1.2.1 (2017-07-15 20:44)
1.2.0 (2017-07-15 09:14)
1.1.3 (2017-07-07)
1.1.2 (2017-06-16)
1.1.1 (2017-03-04)
1.1.0 (2017-02-09 22:50)
1.0.4 (2017-02-09 22:48)
1.0.3 (2017-02-08)
1.0.2 (2017-01-12)
1.0.1 (2016-12-13)
1.0.0 (2016-12-12)
0.3.29 (2016-10-30)
0.3.28 (2016-10-29 16:34)
0.3.27 (2016-10-29 00:14)
0.3.26 (2016-10-27)
0.3.25 (2016-09-16)
0.3.24 (2016-09-15)
0.3.23 (2016-09-14)
0.3.22 (2016-09-13)
0.3.21 (2016-04-15)
0.3.20 (2016-04-14)
0.3.19 (2016-03-22)
0.3.18 (2016-03-21)
0.3.17 (2016-03-20)
0.3.16 (2016-02-11)
0.3.15 (2016-02-09)
0.3.14 (2016-02-04)
0.3.13 (2015-12-19 17:35)
0.3.12 (2015-12-19 14:44)
0.3.11 (2015-12-18)
0.3.10 (2015-12-17)
0.3.9 (2015-12-14)
0.3.8 (2015-12-08)
0.3.7 (2015-11-19)
0.3.6 (2015-09-11)
0.3.5 (2015-09-09)
0.3.4 (2015-09-07)
0.3.3 (2015-09-06)
0.3.2 (2015-09-05)
0.3.1 (2015-09-04 17:12)
0.3.0 (2015-09-04 12:37)
0.2.18 (2015-09-04 01:07)
0.2.17 (2015-08-21)
0.2.16 (2015-08-19)
0.2.15 (2015-08-18)
0.2.14 (2015-08-13)
0.2.13 (2015-06-11)
0.2.12 (2015-05-04)
0.2.11 (2015-04-13)
0.2.10 (2015-04-09)
0.2.9 (2015-03-29)
0.2.7 (2015-03-26)
0.2.6 (2015-03-25)
0.2.5 (2015-03-17)
0.2.4 (2015-03-08)
0.2.3 (2015-02-02)
0.2.2 (2015-01-30)
0.2.0 (2015-01-29 12:20)
0.1.34 (2015-01-29 11:53)
0.1.33 (2015-01-24)
0.1.32 (2015-01-12)
0.1.31 (2015-01-08)
0.1.30 (2014-12-24 16:45)
0.1.29 (2014-12-24 12:43)
0.1.28 (2014-12-17)
0.1.27 (2014-12-09)
0.1.26 (2014-11-23)
0.1.25 (2014-11-21)
0.1.24 (2014-11-15)
0.1.23 (2014-10-09)
0.1.22 (2014-09-24)
0.1.21 (2014-09-20)
0.1.20 (2014-09-17)
0.1.19 (2014-09-15)
0.1.18 (2014-09-13)
0.1.17 (2014-09-07)
0.1.16 (2014-09-04)
0.1.15 (2014-08-26)
0.1.14 (2014-08-01)
0.1.13 (2014-07-29)
0.1.12 (2014-07-24)
0.1.11 (2014-07-08)
0.1.10 (2014-07-07)
0.1.9 (2014-07-01)
0.1.8 (2014-06-29)
0.1.7 (2014-05-31)
0.1.6 (2014-05-30)
0.1.5 (2014-05-29)
0.1.4 (2014-04-25)
0.1.3 (2014-04-12)
0.1.2 (2014-04-11)
0.1.1 (2014-04-10)
Wiki Tutorials
Package Dependencies
System Dependencies
Dependant Packages
Name | Deps |
---|---|
sound_classification |
Launch files
- sample/sample_wrench_to_spectrogram.launch
-
- gui [default: true]
- filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]
- sample/sample_audio_to_spectrogram.launch
- data flow
-
- gui [default: true]
- filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
- launch/audio_to_spectrogram.launch
- data flow
-
- launch_audio_capture [default: true]
- audio_capture_ns [default: /]
- bitdepth [default: 16]
- mic_sampling_rate [default: 16000]
- n_channel [default: 1]
- target_channel [default: 0]
- device [default: hw:0,0]
- audio_topic [default: /audio]
- fft_sampling_period [default: 0.3]
- fft_exec_rate [default: 50]
- audio_amp_plot_max_amp [default: 10000.0]
- audio_amp_plot_window_size [default: 10.0]
- audio_amp_plot_rate [default: 10.0]
- spectrogram_source [default: audio_to_spectrum/log_spectrum]
- high_cut_freq [default: 800]
- low_cut_freq [default: 1]
- spectrogram_period [default: 5]
- preprocessed_spectrogram_source_plot_min_amp [default: 0.0]
- preprocessed_spectrogram_source_plot_max_amp [default: 20.0]
- preprocessed_spectrogram_source_plot_queue_size [default: 1]
- preprocessed_spectrogram_source_plot_max_rate [default: -1]
- gui [default: true]
- launch/spectrum_plot.launch
-
- spectrum
- plotter_name [default: spectrum_plot]
- min_amp [default: 0.0]
- max_amp [default: 20.0]
- queue_size [default: 1]
- max_rate [default: -1]
- gui [default: true]
- launch/wrench_to_spectrogram.launch
- data flow
-
- how_to_get_scalar [default: element_extraction]
- target_element [default: force.z]
- data_sampling_rate [default: 500]
- wrench_topic [default: /ft_sensor]
- fft_sampling_period [default: 0.3]
- fft_exec_rate [default: 50]
- data_amp_plot_max_amp [default: 10.0]
- data_amp_plot_window_size [default: 10.0]
- data_amp_plot_rate [default: 10.0]
- spectrogram_source [default: data_to_spectrum/log_spectrum]
- high_cut_freq [default: 250]
- low_cut_freq [default: 5]
- spectrogram_period [default: 5]
- preprocessed_spectrogram_source_plot_min_amp [default: -10.0]
- preprocessed_spectrogram_source_plot_max_amp [default: 10.0]
- preprocessed_spectrogram_source_plot_queue_size [default: 1]
- preprocessed_spectrogram_source_plot_max_rate [default: -1]
- normalized_half_spectrum_plot_min_amp [default: 0.0]
- normalized_half_spectrum_plot_max_amp [default: 0.2]
- normalized_half_spectrum_plot_queue_size [default: 1]
- normalized_half_spectrum_plot_max_rate [default: -1]
- gui [default: true]
- launch/spectrum_to_spectrogram.launch
-
- spectrum
- data_sampling_rate [default: 500]
- high_cut_freq [default: 250]
- low_cut_freq [default: 5]
- spectrogram_height [default: 300]
- spectrogram_width [default: 300]
- spectrogram_period [default: 5]
- preprocessed_spectrum_plot_min_amp [default: -10.0]
- preprocessed_spectrum_plot_max_amp [default: 10.0]
- preprocessed_spectrum_plot_queue_size [default: 1]
- preprocessed_spectrum_plot_max_rate [default: -1]
- gui [default: true]
- do_dynamic_scaling [default: true]
- colormap [default: 2]
- launch/data_to_spectrum.launch
-
- data_topic
- expression_to_get_data [default: m.data]
- data_sampling_rate [default: 500]
- fft_sampling_period [default: 0.3]
- is_integer [default: false]
- is_signed [default: true]
- bitdepth [default: 64]
- n_channel [default: 1]
- target_channel [default: 0]
- fft_exec_rate [default: 50]
- data_amp_plot_max_amp [default: 10.0]
- data_amp_plot_window_size [default: 10.0]
- data_amp_plot_rate [default: 10.0]
- gui [default: true]
- launch/audio_to_spectrum.launch
-
- audio_topic [default: /audio]
- n_channel [default: 1]
- target_channel [default: 0]
- mic_sampling_rate [default: 16000]
- fft_sampling_period [default: 0.3]
- bitdepth [default: 16]
- fft_exec_rate [default: 50]
- audio_amp_plot_max_amp [default: 10000.0]
- audio_amp_plot_window_size [default: 10.0]
- audio_amp_plot_rate [default: 10.0]
- gui [default: true]
Messages
Services
Plugins
Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange
|
Package Summary
Tags | No category tags. |
Version | 1.2.17 |
License | BSD |
Build type | CATKIN |
Use | RECOMMENDED |
Repository Summary
Checkout URI | https://github.com/jsk-ros-pkg/jsk_recognition.git |
VCS Type | git |
VCS Version | master |
Last Updated | 2024-10-29 |
Dev Status | DEVELOPED |
CI status | No Continuous Integration |
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Package Description
Additional Links
Maintainers
- Naoya Yamaguchi
Authors
audio_to_spectrogram
This package converts audio data (or other time-series data) to spectrum and spectrogram data.
Usage
By following command, you can publish audio, spectrum and spectrogram topics. Please set correct args for your microphone configuration, such as mic_sampling_rate or bitdepth.
roslaunch audio_to_spectrogram audio_to_spectrogram.launch
Its data conversion pipeline is as follows:
audio_to_spectrum.py -> spectrum
-> normalized_half_spectrum
-> log_spectrum -> preprocess node(s) -> preprocessed spectrum -> spectrum_to_spectrogram.py -> spectrogram
Here is an example using rosbag with 300Hz audio.
roslaunch audio_to_spectrogram sample_audio_to_spectrogram.launch
Audio Amplitude | Spectrum | Spectrogram |
---|---|---|
You can also convert data other than audio to spectrum and spectrogram data using this package.
Here is an example using rosbag of a force torque sensor sensing drill vibration.
roslaunch audio_to_spectrogram sample_wrench_to_spectrogram.launch
Z-axis Force Amplitude | Normalized Half Spectrum | Spectrogram Source Spectrum | Spectrogram |
---|---|---|---|
Scripts
audio_to_spectrum.py
A script to convert audio to spectrum.
-
Publishing topics
-
~spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data calculated from audio by FFT.
It is usual “amplitude spectrum”.
See https://ryo-iijima.com/fftresult/ for details. -
~normalized_half_spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data which is “half” (having non-negative frequencies (0Hz-Nyquist frequency)) and is “normalized” (consistent with the amplitude of the original signal).
See the following for details.- https://ryo-iijima.com/fftresult/
- https://stackoverflow.com/questions/63211851/why-divide-the-output-of-numpy-fft-by-n
- https://github.com/jsk-ros-pkg/jsk_recognition/issues/2761#issue-1550715400
-
~log_spectrum
(jsk_recognition_msgs/Spectrum
)Log-scaled spectrum data.
It is calculated by applying log to the absolute value of the FFT result.
Usually, log is applied to “power spectrum”, but we don’t use it for simplicity.
See the following for details.- https://github.com/jsk-ros-pkg/jsk_recognition/issues/2761#issuecomment-1445810380
- http://makotomurakami.com/blog/2020/05/23/5266/
-
-
Subscribing topics
-
~audio
(audio_common_msgs/AudioData
)Audio stream data from microphone. The audio format must be
wave
.
-
-
Parameters
-
~mic_sampling_rate
(Int
, default:16000
)Sampling rate [Hz] of microphone. Namely, sampling rate of audio topic.
-
~fft_sampling_period
(Double
, default:0.3
)Period [s] to sample audio data for one FFT.
-
~n_channel
(Int
, default:1
)Number of channel of microphone.
-
~target_channel
(Int
, default:0
)Target channel.
-
~bitdepth
(Int
, default:16
)Number of bits per audio data.
-
~fft_exec_rate
(Double
, default:50
)Rate [Hz] to execute FFT and publish its results.
-
data_to_spectrum.py
Generalized version of audio_to_spectrum.py
.
This script can convert multiple message types to spectrum.
-
Publishing topics
Same as
audio_to_spectrum.py
. -
Subscribing topics
-
~input
(AnyMsg
)Topic to which message including data you want to convert to spectrum is published.
-
-
Parameters
-
~expression_to_get_data
(String
, default:m.data
)Python expression to get data from the input message
m
. For example, if your input isstd_msgs/Float64
, it ism.data
.
Just accessing a field ofm
is recommended.
If you want to do a complex calculation (e.g., usingnumpy
), usetransform
oftopic_tools
before this node. -
~data_sampling_rate
(Int
, default:500
)Sampling rate [Hz] of input data.
-
~fft_sampling_period
(Double
, default:0.3
)Period [s] to sample input data for one FFT.
-
~fft_exec_rate
(Double
, default:50
)Rate [Hz] to execute FFT and publish its results.
-
~is_integer
(Bool
, default:false
)Whether input data is integer or not. For example, if your input is
std_msgs/Float64
, it isfalse
. -
~is_signed
(Bool
, default:true
)Whether input data is signed or not. For example, if your input is
std_msgs/Float64
, it istrue
. -
~bitdepth
(Int
, default:64
)Number of bits per input data. For example, if your input is
std_msgs/Float64
, it is64
. -
~n_channel
(Int
, default:1
)If your input is scalar, it is
1
.
If your input is flattened 2D matrix, it is number of channel of original matrix. -
~target_channel
(Int
, default:0
)If your input is scalar, it is
0
.
If your input is flattened 2D matrix, it is target channel.
-
spectrum_filter.py
A script to filter spectrum.
-
Publishing topics
-
~output
(jsk_recognition_msgs/Spectrum
)Filtered spectrum data (
low_cut_freq
-high_cut_freq
).
-
-
Subscribing topics
-
~input
(jsk_recognition_msgs/Spectrum
)Original spectrum data.
-
-
Parameters
-
~data_sampling_rate
(Int
, default:500
)Sampling rate [Hz] of data used in generation of original spectrum data.
-
~high_cut_freq
(Int
, default:250
)Threshold to limit the maximum frequency of the output spectrum.
-
~low_cut_freq
(Int
, default:0
)Threshold to limit the minimum frequency of the output spectrum.
-
spectrum_to_spectrogram.py
A script to convert spectrum to spectrogram.
-
Publishing topics
-
~spectrogram
(sensor_msgs/Image
)Spectrogram data, which is concatenation of spectrum in time series. Image format is 32FC1.
-
-
Subscribing topics
-
~spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data calculated from audio by FFT.
-
-
Parameters
-
~image_height
(Int
, default:300
)Number of vertical (frequency axis) pixels in output spectrogram.
-
~image_width
(Int
, default:300
)Number of horizontal (time axis) pixels in output spectrogram.
-
~spectrogram_period
(Double
, default:5
)Period [s] to store spectrum data to create one spectrogram topic.
-
~publish_rate
(Double
, default:image_width / spectrogram_period
)Publish rate [Hz] of spectrogram topic.
-
audio_amplitude_plot.py
A script to publish audio amplitude plot image.
-
Publishing topics
-
~output/viz
(sensor_msgs/Image
)Audio amplitude plot image.
-
-
Subscribing topics
-
~audio
(audio_common_msgs/AudioData
)Audio stream data from microphone. The audio format must be
wave
.
-
-
Parameters
-
~mic_sampling_rate
(Int
, default:16000
)Sampling rate [Hz] of microphone. Namely, sampling rate of audio topic.
-
~n_channel
(Int
, default:1
)Number of channel of microphone.
-
~target_channel
(Int
, default:0
)Target channel.
-
~bitdepth
(Int
, default:16
)Number of bits per audio data.
-
~maximum_amplitude
(Double
, default:10000.0
)Maximum range of amplitude to plot.
-
~window_size
(Double
, default:10.0
)Window size of sound input to plot.
-
~rate
(Double
, default:10.0
)Publish rate [Hz] of audio amplitude image topic.
-
data_amplitude_plot.py
Generalized version of audio_amplitude_plot.py
.
-
Publishing topics
-
~output/viz
(sensor_msgs/Image
)Data amplitude plot image.
-
-
Subscribing topics
-
~input
(AnyMsg
)Topic to which message including data whose amplitude you want to plot is published.
-
-
Parameters
-
~expression_to_get_data
(String
, default:m.data
)Python expression to get data from the input message
m
. For example, if your input isstd_msgs/Float64
, it ism.data
.
Just accessing a field ofm
is recommended.
If you want to do a complex calculation (e.g., usingnumpy
), usetransform
oftopic_tools
before this node. -
~data_sampling_rate
(Int
, default:500
)Sampling rate [Hz] of input data.
-
~is_integer
(Bool
, default:false
)Whether input data is integer or not. For example, if your input is
std_msgs/Float64
, it isfalse
. -
~is_signed
(Bool
, default:true
)Whether input data is signed or not. For example, if your input is
std_msgs/Float64
, it istrue
. -
~bitdepth
(Int
, default:64
)Number of bits per input data. For example, if your input is
std_msgs/Float64
, it is64
. -
~n_channel
(Int
, default:1
)If your input is scalar, it is
1
.
If your input is flattened 2D matrix, it is number of channel of original matrix. -
~target_channel
(Int
, default:0
)If your input is scalar, it is
0
.
If your input is flattened 2D matrix, it is target channel. -
~maximum_amplitude
(Double
, default:10.0
)Maximum range of amplitude to plot.
-
~window_size
(Double
, default:10.0
)Window size of input data to plot.
-
~rate
(Double
, default:10.0
)Publish rate [Hz] of data amplitude image topic.
-
spectrum_plot.py
A script to publish frequency vs amplitude plot image.
-
Publishing topics
-
~output/viz
(sensor_msgs/Image
)Frequency vs amplitude plot image.
-
-
Subscribing topics
-
~spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data calculated from audio by FFT.
-
-
Parameters
-
~min_amp
(Double
, default:0.0
)Minimum value of amplitude in plot.
-
~max_amp
(Double
, default:20.0
)Maximum value of amplitude in plot.
-
~queue_size
(Int
, default:1
)Queue size of spectrum subscriber.
-
~max_rate
(Double
, default:-1
)Maximum publish rate [Hz] of frequency vs amplitude plot image. Setting this value low reduces CPU load.
-1
means no maximum limit.
-
Changelog for package audio_to_spectrogram
1.2.17 (2023-11-14)
1.2.16 (2023-11-10)
- [audio_to_spectrogram, sound_classification] Add data_to_spectrogram (#2767)
- [audio_to_spectrogram] Enable to change spectrum plot from rosparam (#2760)
- Fix audio to spectrogram plot and add test (#2764)
- [audio_to_spectrogram] Add AudioAmplitudePlot node to visualize audio amplitude #2657 (#2755)
- [audio_to_spectrogram] Enable publishing frequency vs amplitude plot (#2654)
- use catkin_install_python to install python scripts under node_scripts/ scripts/ (#2743)
- Contributors: Kei Okada, Naoto Tsukamoto, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Iory Yanokura
1.2.15 (2020-10-10)
1.2.14 (2020-10-09)
1.2.13 (2020-10-08)
1.2.12 (2020-10-03)
1.2.11 (2020-10-01)
- Fix for noetic / 20.04
(#2507)
- upgrade package.xml to format=3, migrate to noetic with ROS_PYTHON_VERSION=2/3, use multiple ROS distro strategy http://wiki.ros.org/noetic/Migration
- [audio_to_spectrogram] Enable multi channel input by retrieving single channel data (#2514)
- [audio_to_spectrogram] Add README for usage and scripts
interface
(#2498)
- [audio_to_spectrogram] Add README for usage and scripts interface
- [audio_to_spectrogram] add args to audio_to_spectrogram.launch
- [audio_to_spectrogram] Add arg to run audio_capture
- Convert audio data to spectrogram
(#2478)
- Make audio_to_spectrogram as ROS package
- Contributors: Kei Okada, Naoya Yamaguchi, Shingo Kitagawa
1.2.10 (2019-03-27)
1.2.9 (2019-02-23)
1.2.8 (2019-02-22)
1.2.7 (2019-02-14)
1.2.6 (2018-11-02)
1.2.5 (2018-04-09)
1.2.4 (2018-01-12)
1.2.3 (2017-11-23)
1.2.2 (2017-07-23)
1.2.1 (2017-07-15 20:44)
1.2.0 (2017-07-15 09:14)
1.1.3 (2017-07-07)
1.1.2 (2017-06-16)
1.1.1 (2017-03-04)
1.1.0 (2017-02-09 22:50)
1.0.4 (2017-02-09 22:48)
1.0.3 (2017-02-08)
1.0.2 (2017-01-12)
1.0.1 (2016-12-13)
1.0.0 (2016-12-12)
0.3.29 (2016-10-30)
0.3.28 (2016-10-29 16:34)
0.3.27 (2016-10-29 00:14)
0.3.26 (2016-10-27)
0.3.25 (2016-09-16)
0.3.24 (2016-09-15)
0.3.23 (2016-09-14)
0.3.22 (2016-09-13)
0.3.21 (2016-04-15)
0.3.20 (2016-04-14)
0.3.19 (2016-03-22)
0.3.18 (2016-03-21)
0.3.17 (2016-03-20)
0.3.16 (2016-02-11)
0.3.15 (2016-02-09)
0.3.14 (2016-02-04)
0.3.13 (2015-12-19 17:35)
0.3.12 (2015-12-19 14:44)
0.3.11 (2015-12-18)
0.3.10 (2015-12-17)
0.3.9 (2015-12-14)
0.3.8 (2015-12-08)
0.3.7 (2015-11-19)
0.3.6 (2015-09-11)
0.3.5 (2015-09-09)
0.3.4 (2015-09-07)
0.3.3 (2015-09-06)
0.3.2 (2015-09-05)
0.3.1 (2015-09-04 17:12)
0.3.0 (2015-09-04 12:37)
0.2.18 (2015-09-04 01:07)
0.2.17 (2015-08-21)
0.2.16 (2015-08-19)
0.2.15 (2015-08-18)
0.2.14 (2015-08-13)
0.2.13 (2015-06-11)
0.2.12 (2015-05-04)
0.2.11 (2015-04-13)
0.2.10 (2015-04-09)
0.2.9 (2015-03-29)
0.2.7 (2015-03-26)
0.2.6 (2015-03-25)
0.2.5 (2015-03-17)
0.2.4 (2015-03-08)
0.2.3 (2015-02-02)
0.2.2 (2015-01-30)
0.2.0 (2015-01-29 12:20)
0.1.34 (2015-01-29 11:53)
0.1.33 (2015-01-24)
0.1.32 (2015-01-12)
0.1.31 (2015-01-08)
0.1.30 (2014-12-24 16:45)
0.1.29 (2014-12-24 12:43)
0.1.28 (2014-12-17)
0.1.27 (2014-12-09)
0.1.26 (2014-11-23)
0.1.25 (2014-11-21)
0.1.24 (2014-11-15)
0.1.23 (2014-10-09)
0.1.22 (2014-09-24)
0.1.21 (2014-09-20)
0.1.20 (2014-09-17)
0.1.19 (2014-09-15)
0.1.18 (2014-09-13)
0.1.17 (2014-09-07)
0.1.16 (2014-09-04)
0.1.15 (2014-08-26)
0.1.14 (2014-08-01)
0.1.13 (2014-07-29)
0.1.12 (2014-07-24)
0.1.11 (2014-07-08)
0.1.10 (2014-07-07)
0.1.9 (2014-07-01)
0.1.8 (2014-06-29)
0.1.7 (2014-05-31)
0.1.6 (2014-05-30)
0.1.5 (2014-05-29)
0.1.4 (2014-04-25)
0.1.3 (2014-04-12)
0.1.2 (2014-04-11)
0.1.1 (2014-04-10)
Wiki Tutorials
Package Dependencies
System Dependencies
Dependant Packages
Name | Deps |
---|---|
sound_classification |
Launch files
- sample/sample_wrench_to_spectrogram.launch
-
- gui [default: true]
- filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]
- sample/sample_audio_to_spectrogram.launch
- data flow
-
- gui [default: true]
- filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
- launch/audio_to_spectrogram.launch
- data flow
-
- launch_audio_capture [default: true]
- audio_capture_ns [default: /]
- bitdepth [default: 16]
- mic_sampling_rate [default: 16000]
- n_channel [default: 1]
- target_channel [default: 0]
- device [default: hw:0,0]
- audio_topic [default: /audio]
- fft_sampling_period [default: 0.3]
- fft_exec_rate [default: 50]
- audio_amp_plot_max_amp [default: 10000.0]
- audio_amp_plot_window_size [default: 10.0]
- audio_amp_plot_rate [default: 10.0]
- spectrogram_source [default: audio_to_spectrum/log_spectrum]
- high_cut_freq [default: 800]
- low_cut_freq [default: 1]
- spectrogram_period [default: 5]
- preprocessed_spectrogram_source_plot_min_amp [default: 0.0]
- preprocessed_spectrogram_source_plot_max_amp [default: 20.0]
- preprocessed_spectrogram_source_plot_queue_size [default: 1]
- preprocessed_spectrogram_source_plot_max_rate [default: -1]
- gui [default: true]
- launch/spectrum_plot.launch
-
- spectrum
- plotter_name [default: spectrum_plot]
- min_amp [default: 0.0]
- max_amp [default: 20.0]
- queue_size [default: 1]
- max_rate [default: -1]
- gui [default: true]
- launch/wrench_to_spectrogram.launch
- data flow
-
- how_to_get_scalar [default: element_extraction]
- target_element [default: force.z]
- data_sampling_rate [default: 500]
- wrench_topic [default: /ft_sensor]
- fft_sampling_period [default: 0.3]
- fft_exec_rate [default: 50]
- data_amp_plot_max_amp [default: 10.0]
- data_amp_plot_window_size [default: 10.0]
- data_amp_plot_rate [default: 10.0]
- spectrogram_source [default: data_to_spectrum/log_spectrum]
- high_cut_freq [default: 250]
- low_cut_freq [default: 5]
- spectrogram_period [default: 5]
- preprocessed_spectrogram_source_plot_min_amp [default: -10.0]
- preprocessed_spectrogram_source_plot_max_amp [default: 10.0]
- preprocessed_spectrogram_source_plot_queue_size [default: 1]
- preprocessed_spectrogram_source_plot_max_rate [default: -1]
- normalized_half_spectrum_plot_min_amp [default: 0.0]
- normalized_half_spectrum_plot_max_amp [default: 0.2]
- normalized_half_spectrum_plot_queue_size [default: 1]
- normalized_half_spectrum_plot_max_rate [default: -1]
- gui [default: true]
- launch/spectrum_to_spectrogram.launch
-
- spectrum
- data_sampling_rate [default: 500]
- high_cut_freq [default: 250]
- low_cut_freq [default: 5]
- spectrogram_height [default: 300]
- spectrogram_width [default: 300]
- spectrogram_period [default: 5]
- preprocessed_spectrum_plot_min_amp [default: -10.0]
- preprocessed_spectrum_plot_max_amp [default: 10.0]
- preprocessed_spectrum_plot_queue_size [default: 1]
- preprocessed_spectrum_plot_max_rate [default: -1]
- gui [default: true]
- do_dynamic_scaling [default: true]
- colormap [default: 2]
- launch/data_to_spectrum.launch
-
- data_topic
- expression_to_get_data [default: m.data]
- data_sampling_rate [default: 500]
- fft_sampling_period [default: 0.3]
- is_integer [default: false]
- is_signed [default: true]
- bitdepth [default: 64]
- n_channel [default: 1]
- target_channel [default: 0]
- fft_exec_rate [default: 50]
- data_amp_plot_max_amp [default: 10.0]
- data_amp_plot_window_size [default: 10.0]
- data_amp_plot_rate [default: 10.0]
- gui [default: true]
- launch/audio_to_spectrum.launch
-
- audio_topic [default: /audio]
- n_channel [default: 1]
- target_channel [default: 0]
- mic_sampling_rate [default: 16000]
- fft_sampling_period [default: 0.3]
- bitdepth [default: 16]
- fft_exec_rate [default: 50]
- audio_amp_plot_max_amp [default: 10000.0]
- audio_amp_plot_window_size [default: 10.0]
- audio_amp_plot_rate [default: 10.0]
- gui [default: true]
Messages
Services
Plugins
Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange
|
Package Summary
Tags | No category tags. |
Version | 1.2.17 |
License | BSD |
Build type | CATKIN |
Use | RECOMMENDED |
Repository Summary
Checkout URI | https://github.com/jsk-ros-pkg/jsk_recognition.git |
VCS Type | git |
VCS Version | master |
Last Updated | 2024-10-29 |
Dev Status | DEVELOPED |
CI status | Continuous Integration |
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Package Description
Additional Links
Maintainers
- Naoya Yamaguchi
Authors
audio_to_spectrogram
This package converts audio data (or other time-series data) to spectrum and spectrogram data.
Usage
By following command, you can publish audio, spectrum and spectrogram topics. Please set correct args for your microphone configuration, such as mic_sampling_rate or bitdepth.
roslaunch audio_to_spectrogram audio_to_spectrogram.launch
Its data conversion pipeline is as follows:
audio_to_spectrum.py -> spectrum
-> normalized_half_spectrum
-> log_spectrum -> preprocess node(s) -> preprocessed spectrum -> spectrum_to_spectrogram.py -> spectrogram
Here is an example using rosbag with 300Hz audio.
roslaunch audio_to_spectrogram sample_audio_to_spectrogram.launch
Audio Amplitude | Spectrum | Spectrogram |
---|---|---|
You can also convert data other than audio to spectrum and spectrogram data using this package.
Here is an example using rosbag of a force torque sensor sensing drill vibration.
roslaunch audio_to_spectrogram sample_wrench_to_spectrogram.launch
Z-axis Force Amplitude | Normalized Half Spectrum | Spectrogram Source Spectrum | Spectrogram |
---|---|---|---|
Scripts
audio_to_spectrum.py
A script to convert audio to spectrum.
-
Publishing topics
-
~spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data calculated from audio by FFT.
It is usual “amplitude spectrum”.
See https://ryo-iijima.com/fftresult/ for details. -
~normalized_half_spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data which is “half” (having non-negative frequencies (0Hz-Nyquist frequency)) and is “normalized” (consistent with the amplitude of the original signal).
See the following for details.- https://ryo-iijima.com/fftresult/
- https://stackoverflow.com/questions/63211851/why-divide-the-output-of-numpy-fft-by-n
- https://github.com/jsk-ros-pkg/jsk_recognition/issues/2761#issue-1550715400
-
~log_spectrum
(jsk_recognition_msgs/Spectrum
)Log-scaled spectrum data.
It is calculated by applying log to the absolute value of the FFT result.
Usually, log is applied to “power spectrum”, but we don’t use it for simplicity.
See the following for details.- https://github.com/jsk-ros-pkg/jsk_recognition/issues/2761#issuecomment-1445810380
- http://makotomurakami.com/blog/2020/05/23/5266/
-
-
Subscribing topics
-
~audio
(audio_common_msgs/AudioData
)Audio stream data from microphone. The audio format must be
wave
.
-
-
Parameters
-
~mic_sampling_rate
(Int
, default:16000
)Sampling rate [Hz] of microphone. Namely, sampling rate of audio topic.
-
~fft_sampling_period
(Double
, default:0.3
)Period [s] to sample audio data for one FFT.
-
~n_channel
(Int
, default:1
)Number of channel of microphone.
-
~target_channel
(Int
, default:0
)Target channel.
-
~bitdepth
(Int
, default:16
)Number of bits per audio data.
-
~fft_exec_rate
(Double
, default:50
)Rate [Hz] to execute FFT and publish its results.
-
data_to_spectrum.py
Generalized version of audio_to_spectrum.py
.
This script can convert multiple message types to spectrum.
-
Publishing topics
Same as
audio_to_spectrum.py
. -
Subscribing topics
-
~input
(AnyMsg
)Topic to which message including data you want to convert to spectrum is published.
-
-
Parameters
-
~expression_to_get_data
(String
, default:m.data
)Python expression to get data from the input message
m
. For example, if your input isstd_msgs/Float64
, it ism.data
.
Just accessing a field ofm
is recommended.
If you want to do a complex calculation (e.g., usingnumpy
), usetransform
oftopic_tools
before this node. -
~data_sampling_rate
(Int
, default:500
)Sampling rate [Hz] of input data.
-
~fft_sampling_period
(Double
, default:0.3
)Period [s] to sample input data for one FFT.
-
~fft_exec_rate
(Double
, default:50
)Rate [Hz] to execute FFT and publish its results.
-
~is_integer
(Bool
, default:false
)Whether input data is integer or not. For example, if your input is
std_msgs/Float64
, it isfalse
. -
~is_signed
(Bool
, default:true
)Whether input data is signed or not. For example, if your input is
std_msgs/Float64
, it istrue
. -
~bitdepth
(Int
, default:64
)Number of bits per input data. For example, if your input is
std_msgs/Float64
, it is64
. -
~n_channel
(Int
, default:1
)If your input is scalar, it is
1
.
If your input is flattened 2D matrix, it is number of channel of original matrix. -
~target_channel
(Int
, default:0
)If your input is scalar, it is
0
.
If your input is flattened 2D matrix, it is target channel.
-
spectrum_filter.py
A script to filter spectrum.
-
Publishing topics
-
~output
(jsk_recognition_msgs/Spectrum
)Filtered spectrum data (
low_cut_freq
-high_cut_freq
).
-
-
Subscribing topics
-
~input
(jsk_recognition_msgs/Spectrum
)Original spectrum data.
-
-
Parameters
-
~data_sampling_rate
(Int
, default:500
)Sampling rate [Hz] of data used in generation of original spectrum data.
-
~high_cut_freq
(Int
, default:250
)Threshold to limit the maximum frequency of the output spectrum.
-
~low_cut_freq
(Int
, default:0
)Threshold to limit the minimum frequency of the output spectrum.
-
spectrum_to_spectrogram.py
A script to convert spectrum to spectrogram.
-
Publishing topics
-
~spectrogram
(sensor_msgs/Image
)Spectrogram data, which is concatenation of spectrum in time series. Image format is 32FC1.
-
-
Subscribing topics
-
~spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data calculated from audio by FFT.
-
-
Parameters
-
~image_height
(Int
, default:300
)Number of vertical (frequency axis) pixels in output spectrogram.
-
~image_width
(Int
, default:300
)Number of horizontal (time axis) pixels in output spectrogram.
-
~spectrogram_period
(Double
, default:5
)Period [s] to store spectrum data to create one spectrogram topic.
-
~publish_rate
(Double
, default:image_width / spectrogram_period
)Publish rate [Hz] of spectrogram topic.
-
audio_amplitude_plot.py
A script to publish audio amplitude plot image.
-
Publishing topics
-
~output/viz
(sensor_msgs/Image
)Audio amplitude plot image.
-
-
Subscribing topics
-
~audio
(audio_common_msgs/AudioData
)Audio stream data from microphone. The audio format must be
wave
.
-
-
Parameters
-
~mic_sampling_rate
(Int
, default:16000
)Sampling rate [Hz] of microphone. Namely, sampling rate of audio topic.
-
~n_channel
(Int
, default:1
)Number of channel of microphone.
-
~target_channel
(Int
, default:0
)Target channel.
-
~bitdepth
(Int
, default:16
)Number of bits per audio data.
-
~maximum_amplitude
(Double
, default:10000.0
)Maximum range of amplitude to plot.
-
~window_size
(Double
, default:10.0
)Window size of sound input to plot.
-
~rate
(Double
, default:10.0
)Publish rate [Hz] of audio amplitude image topic.
-
data_amplitude_plot.py
Generalized version of audio_amplitude_plot.py
.
-
Publishing topics
-
~output/viz
(sensor_msgs/Image
)Data amplitude plot image.
-
-
Subscribing topics
-
~input
(AnyMsg
)Topic to which message including data whose amplitude you want to plot is published.
-
-
Parameters
-
~expression_to_get_data
(String
, default:m.data
)Python expression to get data from the input message
m
. For example, if your input isstd_msgs/Float64
, it ism.data
.
Just accessing a field ofm
is recommended.
If you want to do a complex calculation (e.g., usingnumpy
), usetransform
oftopic_tools
before this node. -
~data_sampling_rate
(Int
, default:500
)Sampling rate [Hz] of input data.
-
~is_integer
(Bool
, default:false
)Whether input data is integer or not. For example, if your input is
std_msgs/Float64
, it isfalse
. -
~is_signed
(Bool
, default:true
)Whether input data is signed or not. For example, if your input is
std_msgs/Float64
, it istrue
. -
~bitdepth
(Int
, default:64
)Number of bits per input data. For example, if your input is
std_msgs/Float64
, it is64
. -
~n_channel
(Int
, default:1
)If your input is scalar, it is
1
.
If your input is flattened 2D matrix, it is number of channel of original matrix. -
~target_channel
(Int
, default:0
)If your input is scalar, it is
0
.
If your input is flattened 2D matrix, it is target channel. -
~maximum_amplitude
(Double
, default:10.0
)Maximum range of amplitude to plot.
-
~window_size
(Double
, default:10.0
)Window size of input data to plot.
-
~rate
(Double
, default:10.0
)Publish rate [Hz] of data amplitude image topic.
-
spectrum_plot.py
A script to publish frequency vs amplitude plot image.
-
Publishing topics
-
~output/viz
(sensor_msgs/Image
)Frequency vs amplitude plot image.
-
-
Subscribing topics
-
~spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data calculated from audio by FFT.
-
-
Parameters
-
~min_amp
(Double
, default:0.0
)Minimum value of amplitude in plot.
-
~max_amp
(Double
, default:20.0
)Maximum value of amplitude in plot.
-
~queue_size
(Int
, default:1
)Queue size of spectrum subscriber.
-
~max_rate
(Double
, default:-1
)Maximum publish rate [Hz] of frequency vs amplitude plot image. Setting this value low reduces CPU load.
-1
means no maximum limit.
-
Changelog for package audio_to_spectrogram
1.2.17 (2023-11-14)
1.2.16 (2023-11-10)
- [audio_to_spectrogram, sound_classification] Add data_to_spectrogram (#2767)
- [audio_to_spectrogram] Enable to change spectrum plot from rosparam (#2760)
- Fix audio to spectrogram plot and add test (#2764)
- [audio_to_spectrogram] Add AudioAmplitudePlot node to visualize audio amplitude #2657 (#2755)
- [audio_to_spectrogram] Enable publishing frequency vs amplitude plot (#2654)
- use catkin_install_python to install python scripts under node_scripts/ scripts/ (#2743)
- Contributors: Kei Okada, Naoto Tsukamoto, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Iory Yanokura
1.2.15 (2020-10-10)
1.2.14 (2020-10-09)
1.2.13 (2020-10-08)
1.2.12 (2020-10-03)
1.2.11 (2020-10-01)
- Fix for noetic / 20.04
(#2507)
- upgrade package.xml to format=3, migrate to noetic with ROS_PYTHON_VERSION=2/3, use multiple ROS distro strategy http://wiki.ros.org/noetic/Migration
- [audio_to_spectrogram] Enable multi channel input by retrieving single channel data (#2514)
- [audio_to_spectrogram] Add README for usage and scripts
interface
(#2498)
- [audio_to_spectrogram] Add README for usage and scripts interface
- [audio_to_spectrogram] add args to audio_to_spectrogram.launch
- [audio_to_spectrogram] Add arg to run audio_capture
- Convert audio data to spectrogram
(#2478)
- Make audio_to_spectrogram as ROS package
- Contributors: Kei Okada, Naoya Yamaguchi, Shingo Kitagawa
1.2.10 (2019-03-27)
1.2.9 (2019-02-23)
1.2.8 (2019-02-22)
1.2.7 (2019-02-14)
1.2.6 (2018-11-02)
1.2.5 (2018-04-09)
1.2.4 (2018-01-12)
1.2.3 (2017-11-23)
1.2.2 (2017-07-23)
1.2.1 (2017-07-15 20:44)
1.2.0 (2017-07-15 09:14)
1.1.3 (2017-07-07)
1.1.2 (2017-06-16)
1.1.1 (2017-03-04)
1.1.0 (2017-02-09 22:50)
1.0.4 (2017-02-09 22:48)
1.0.3 (2017-02-08)
1.0.2 (2017-01-12)
1.0.1 (2016-12-13)
1.0.0 (2016-12-12)
0.3.29 (2016-10-30)
0.3.28 (2016-10-29 16:34)
0.3.27 (2016-10-29 00:14)
0.3.26 (2016-10-27)
0.3.25 (2016-09-16)
0.3.24 (2016-09-15)
0.3.23 (2016-09-14)
0.3.22 (2016-09-13)
0.3.21 (2016-04-15)
0.3.20 (2016-04-14)
0.3.19 (2016-03-22)
0.3.18 (2016-03-21)
0.3.17 (2016-03-20)
0.3.16 (2016-02-11)
0.3.15 (2016-02-09)
0.3.14 (2016-02-04)
0.3.13 (2015-12-19 17:35)
0.3.12 (2015-12-19 14:44)
0.3.11 (2015-12-18)
0.3.10 (2015-12-17)
0.3.9 (2015-12-14)
0.3.8 (2015-12-08)
0.3.7 (2015-11-19)
0.3.6 (2015-09-11)
0.3.5 (2015-09-09)
0.3.4 (2015-09-07)
0.3.3 (2015-09-06)
0.3.2 (2015-09-05)
0.3.1 (2015-09-04 17:12)
0.3.0 (2015-09-04 12:37)
0.2.18 (2015-09-04 01:07)
0.2.17 (2015-08-21)
0.2.16 (2015-08-19)
0.2.15 (2015-08-18)
0.2.14 (2015-08-13)
0.2.13 (2015-06-11)
0.2.12 (2015-05-04)
0.2.11 (2015-04-13)
0.2.10 (2015-04-09)
0.2.9 (2015-03-29)
0.2.7 (2015-03-26)
0.2.6 (2015-03-25)
0.2.5 (2015-03-17)
0.2.4 (2015-03-08)
0.2.3 (2015-02-02)
0.2.2 (2015-01-30)
0.2.0 (2015-01-29 12:20)
0.1.34 (2015-01-29 11:53)
0.1.33 (2015-01-24)
0.1.32 (2015-01-12)
0.1.31 (2015-01-08)
0.1.30 (2014-12-24 16:45)
0.1.29 (2014-12-24 12:43)
0.1.28 (2014-12-17)
0.1.27 (2014-12-09)
0.1.26 (2014-11-23)
0.1.25 (2014-11-21)
0.1.24 (2014-11-15)
0.1.23 (2014-10-09)
0.1.22 (2014-09-24)
0.1.21 (2014-09-20)
0.1.20 (2014-09-17)
0.1.19 (2014-09-15)
0.1.18 (2014-09-13)
0.1.17 (2014-09-07)
0.1.16 (2014-09-04)
0.1.15 (2014-08-26)
0.1.14 (2014-08-01)
0.1.13 (2014-07-29)
0.1.12 (2014-07-24)
0.1.11 (2014-07-08)
0.1.10 (2014-07-07)
0.1.9 (2014-07-01)
0.1.8 (2014-06-29)
0.1.7 (2014-05-31)
0.1.6 (2014-05-30)
0.1.5 (2014-05-29)
0.1.4 (2014-04-25)
0.1.3 (2014-04-12)
0.1.2 (2014-04-11)
0.1.1 (2014-04-10)
Wiki Tutorials
Package Dependencies
System Dependencies
Dependant Packages
Name | Deps |
---|---|
sound_classification |
Launch files
- sample/sample_wrench_to_spectrogram.launch
-
- gui [default: true]
- filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]
- sample/sample_audio_to_spectrogram.launch
- data flow
-
- gui [default: true]
- filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
- launch/audio_to_spectrogram.launch
- data flow
-
- launch_audio_capture [default: true]
- audio_capture_ns [default: /]
- bitdepth [default: 16]
- mic_sampling_rate [default: 16000]
- n_channel [default: 1]
- target_channel [default: 0]
- device [default: hw:0,0]
- audio_topic [default: /audio]
- fft_sampling_period [default: 0.3]
- fft_exec_rate [default: 50]
- audio_amp_plot_max_amp [default: 10000.0]
- audio_amp_plot_window_size [default: 10.0]
- audio_amp_plot_rate [default: 10.0]
- spectrogram_source [default: audio_to_spectrum/log_spectrum]
- high_cut_freq [default: 800]
- low_cut_freq [default: 1]
- spectrogram_period [default: 5]
- preprocessed_spectrogram_source_plot_min_amp [default: 0.0]
- preprocessed_spectrogram_source_plot_max_amp [default: 20.0]
- preprocessed_spectrogram_source_plot_queue_size [default: 1]
- preprocessed_spectrogram_source_plot_max_rate [default: -1]
- gui [default: true]
- launch/spectrum_plot.launch
-
- spectrum
- plotter_name [default: spectrum_plot]
- min_amp [default: 0.0]
- max_amp [default: 20.0]
- queue_size [default: 1]
- max_rate [default: -1]
- gui [default: true]
- launch/wrench_to_spectrogram.launch
- data flow
-
- how_to_get_scalar [default: element_extraction]
- target_element [default: force.z]
- data_sampling_rate [default: 500]
- wrench_topic [default: /ft_sensor]
- fft_sampling_period [default: 0.3]
- fft_exec_rate [default: 50]
- data_amp_plot_max_amp [default: 10.0]
- data_amp_plot_window_size [default: 10.0]
- data_amp_plot_rate [default: 10.0]
- spectrogram_source [default: data_to_spectrum/log_spectrum]
- high_cut_freq [default: 250]
- low_cut_freq [default: 5]
- spectrogram_period [default: 5]
- preprocessed_spectrogram_source_plot_min_amp [default: -10.0]
- preprocessed_spectrogram_source_plot_max_amp [default: 10.0]
- preprocessed_spectrogram_source_plot_queue_size [default: 1]
- preprocessed_spectrogram_source_plot_max_rate [default: -1]
- normalized_half_spectrum_plot_min_amp [default: 0.0]
- normalized_half_spectrum_plot_max_amp [default: 0.2]
- normalized_half_spectrum_plot_queue_size [default: 1]
- normalized_half_spectrum_plot_max_rate [default: -1]
- gui [default: true]
- launch/spectrum_to_spectrogram.launch
-
- spectrum
- data_sampling_rate [default: 500]
- high_cut_freq [default: 250]
- low_cut_freq [default: 5]
- spectrogram_height [default: 300]
- spectrogram_width [default: 300]
- spectrogram_period [default: 5]
- preprocessed_spectrum_plot_min_amp [default: -10.0]
- preprocessed_spectrum_plot_max_amp [default: 10.0]
- preprocessed_spectrum_plot_queue_size [default: 1]
- preprocessed_spectrum_plot_max_rate [default: -1]
- gui [default: true]
- do_dynamic_scaling [default: true]
- colormap [default: 2]
- launch/data_to_spectrum.launch
-
- data_topic
- expression_to_get_data [default: m.data]
- data_sampling_rate [default: 500]
- fft_sampling_period [default: 0.3]
- is_integer [default: false]
- is_signed [default: true]
- bitdepth [default: 64]
- n_channel [default: 1]
- target_channel [default: 0]
- fft_exec_rate [default: 50]
- data_amp_plot_max_amp [default: 10.0]
- data_amp_plot_window_size [default: 10.0]
- data_amp_plot_rate [default: 10.0]
- gui [default: true]
- launch/audio_to_spectrum.launch
-
- audio_topic [default: /audio]
- n_channel [default: 1]
- target_channel [default: 0]
- mic_sampling_rate [default: 16000]
- fft_sampling_period [default: 0.3]
- bitdepth [default: 16]
- fft_exec_rate [default: 50]
- audio_amp_plot_max_amp [default: 10000.0]
- audio_amp_plot_window_size [default: 10.0]
- audio_amp_plot_rate [default: 10.0]
- gui [default: true]
Messages
Services
Plugins
Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange
|
Package Summary
Tags | No category tags. |
Version | 1.2.17 |
License | BSD |
Build type | CATKIN |
Use | RECOMMENDED |
Repository Summary
Checkout URI | https://github.com/jsk-ros-pkg/jsk_recognition.git |
VCS Type | git |
VCS Version | master |
Last Updated | 2024-10-29 |
Dev Status | DEVELOPED |
CI status | No Continuous Integration |
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Package Description
Additional Links
Maintainers
- Naoya Yamaguchi
Authors
audio_to_spectrogram
This package converts audio data (or other time-series data) to spectrum and spectrogram data.
Usage
By following command, you can publish audio, spectrum and spectrogram topics. Please set correct args for your microphone configuration, such as mic_sampling_rate or bitdepth.
roslaunch audio_to_spectrogram audio_to_spectrogram.launch
Its data conversion pipeline is as follows:
audio_to_spectrum.py -> spectrum
-> normalized_half_spectrum
-> log_spectrum -> preprocess node(s) -> preprocessed spectrum -> spectrum_to_spectrogram.py -> spectrogram
Here is an example using rosbag with 300Hz audio.
roslaunch audio_to_spectrogram sample_audio_to_spectrogram.launch
Audio Amplitude | Spectrum | Spectrogram |
---|---|---|
You can also convert data other than audio to spectrum and spectrogram data using this package.
Here is an example using rosbag of a force torque sensor sensing drill vibration.
roslaunch audio_to_spectrogram sample_wrench_to_spectrogram.launch
Z-axis Force Amplitude | Normalized Half Spectrum | Spectrogram Source Spectrum | Spectrogram |
---|---|---|---|
Scripts
audio_to_spectrum.py
A script to convert audio to spectrum.
-
Publishing topics
-
~spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data calculated from audio by FFT.
It is usual “amplitude spectrum”.
See https://ryo-iijima.com/fftresult/ for details. -
~normalized_half_spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data which is “half” (having non-negative frequencies (0Hz-Nyquist frequency)) and is “normalized” (consistent with the amplitude of the original signal).
See the following for details.- https://ryo-iijima.com/fftresult/
- https://stackoverflow.com/questions/63211851/why-divide-the-output-of-numpy-fft-by-n
- https://github.com/jsk-ros-pkg/jsk_recognition/issues/2761#issue-1550715400
-
~log_spectrum
(jsk_recognition_msgs/Spectrum
)Log-scaled spectrum data.
It is calculated by applying log to the absolute value of the FFT result.
Usually, log is applied to “power spectrum”, but we don’t use it for simplicity.
See the following for details.- https://github.com/jsk-ros-pkg/jsk_recognition/issues/2761#issuecomment-1445810380
- http://makotomurakami.com/blog/2020/05/23/5266/
-
-
Subscribing topics
-
~audio
(audio_common_msgs/AudioData
)Audio stream data from microphone. The audio format must be
wave
.
-
-
Parameters
-
~mic_sampling_rate
(Int
, default:16000
)Sampling rate [Hz] of microphone. Namely, sampling rate of audio topic.
-
~fft_sampling_period
(Double
, default:0.3
)Period [s] to sample audio data for one FFT.
-
~n_channel
(Int
, default:1
)Number of channel of microphone.
-
~target_channel
(Int
, default:0
)Target channel.
-
~bitdepth
(Int
, default:16
)Number of bits per audio data.
-
~fft_exec_rate
(Double
, default:50
)Rate [Hz] to execute FFT and publish its results.
-
data_to_spectrum.py
Generalized version of audio_to_spectrum.py
.
This script can convert multiple message types to spectrum.
-
Publishing topics
Same as
audio_to_spectrum.py
. -
Subscribing topics
-
~input
(AnyMsg
)Topic to which message including data you want to convert to spectrum is published.
-
-
Parameters
-
~expression_to_get_data
(String
, default:m.data
)Python expression to get data from the input message
m
. For example, if your input isstd_msgs/Float64
, it ism.data
.
Just accessing a field ofm
is recommended.
If you want to do a complex calculation (e.g., usingnumpy
), usetransform
oftopic_tools
before this node. -
~data_sampling_rate
(Int
, default:500
)Sampling rate [Hz] of input data.
-
~fft_sampling_period
(Double
, default:0.3
)Period [s] to sample input data for one FFT.
-
~fft_exec_rate
(Double
, default:50
)Rate [Hz] to execute FFT and publish its results.
-
~is_integer
(Bool
, default:false
)Whether input data is integer or not. For example, if your input is
std_msgs/Float64
, it isfalse
. -
~is_signed
(Bool
, default:true
)Whether input data is signed or not. For example, if your input is
std_msgs/Float64
, it istrue
. -
~bitdepth
(Int
, default:64
)Number of bits per input data. For example, if your input is
std_msgs/Float64
, it is64
. -
~n_channel
(Int
, default:1
)If your input is scalar, it is
1
.
If your input is flattened 2D matrix, it is number of channel of original matrix. -
~target_channel
(Int
, default:0
)If your input is scalar, it is
0
.
If your input is flattened 2D matrix, it is target channel.
-
spectrum_filter.py
A script to filter spectrum.
-
Publishing topics
-
~output
(jsk_recognition_msgs/Spectrum
)Filtered spectrum data (
low_cut_freq
-high_cut_freq
).
-
-
Subscribing topics
-
~input
(jsk_recognition_msgs/Spectrum
)Original spectrum data.
-
-
Parameters
-
~data_sampling_rate
(Int
, default:500
)Sampling rate [Hz] of data used in generation of original spectrum data.
-
~high_cut_freq
(Int
, default:250
)Threshold to limit the maximum frequency of the output spectrum.
-
~low_cut_freq
(Int
, default:0
)Threshold to limit the minimum frequency of the output spectrum.
-
spectrum_to_spectrogram.py
A script to convert spectrum to spectrogram.
-
Publishing topics
-
~spectrogram
(sensor_msgs/Image
)Spectrogram data, which is concatenation of spectrum in time series. Image format is 32FC1.
-
-
Subscribing topics
-
~spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data calculated from audio by FFT.
-
-
Parameters
-
~image_height
(Int
, default:300
)Number of vertical (frequency axis) pixels in output spectrogram.
-
~image_width
(Int
, default:300
)Number of horizontal (time axis) pixels in output spectrogram.
-
~spectrogram_period
(Double
, default:5
)Period [s] to store spectrum data to create one spectrogram topic.
-
~publish_rate
(Double
, default:image_width / spectrogram_period
)Publish rate [Hz] of spectrogram topic.
-
audio_amplitude_plot.py
A script to publish audio amplitude plot image.
-
Publishing topics
-
~output/viz
(sensor_msgs/Image
)Audio amplitude plot image.
-
-
Subscribing topics
-
~audio
(audio_common_msgs/AudioData
)Audio stream data from microphone. The audio format must be
wave
.
-
-
Parameters
-
~mic_sampling_rate
(Int
, default:16000
)Sampling rate [Hz] of microphone. Namely, sampling rate of audio topic.
-
~n_channel
(Int
, default:1
)Number of channel of microphone.
-
~target_channel
(Int
, default:0
)Target channel.
-
~bitdepth
(Int
, default:16
)Number of bits per audio data.
-
~maximum_amplitude
(Double
, default:10000.0
)Maximum range of amplitude to plot.
-
~window_size
(Double
, default:10.0
)Window size of sound input to plot.
-
~rate
(Double
, default:10.0
)Publish rate [Hz] of audio amplitude image topic.
-
data_amplitude_plot.py
Generalized version of audio_amplitude_plot.py
.
-
Publishing topics
-
~output/viz
(sensor_msgs/Image
)Data amplitude plot image.
-
-
Subscribing topics
-
~input
(AnyMsg
)Topic to which message including data whose amplitude you want to plot is published.
-
-
Parameters
-
~expression_to_get_data
(String
, default:m.data
)Python expression to get data from the input message
m
. For example, if your input isstd_msgs/Float64
, it ism.data
.
Just accessing a field ofm
is recommended.
If you want to do a complex calculation (e.g., usingnumpy
), usetransform
oftopic_tools
before this node. -
~data_sampling_rate
(Int
, default:500
)Sampling rate [Hz] of input data.
-
~is_integer
(Bool
, default:false
)Whether input data is integer or not. For example, if your input is
std_msgs/Float64
, it isfalse
. -
~is_signed
(Bool
, default:true
)Whether input data is signed or not. For example, if your input is
std_msgs/Float64
, it istrue
. -
~bitdepth
(Int
, default:64
)Number of bits per input data. For example, if your input is
std_msgs/Float64
, it is64
. -
~n_channel
(Int
, default:1
)If your input is scalar, it is
1
.
If your input is flattened 2D matrix, it is number of channel of original matrix. -
~target_channel
(Int
, default:0
)If your input is scalar, it is
0
.
If your input is flattened 2D matrix, it is target channel. -
~maximum_amplitude
(Double
, default:10.0
)Maximum range of amplitude to plot.
-
~window_size
(Double
, default:10.0
)Window size of input data to plot.
-
~rate
(Double
, default:10.0
)Publish rate [Hz] of data amplitude image topic.
-
spectrum_plot.py
A script to publish frequency vs amplitude plot image.
-
Publishing topics
-
~output/viz
(sensor_msgs/Image
)Frequency vs amplitude plot image.
-
-
Subscribing topics
-
~spectrum
(jsk_recognition_msgs/Spectrum
)Spectrum data calculated from audio by FFT.
-
-
Parameters
-
~min_amp
(Double
, default:0.0
)Minimum value of amplitude in plot.
-
~max_amp
(Double
, default:20.0
)Maximum value of amplitude in plot.
-
~queue_size
(Int
, default:1
)Queue size of spectrum subscriber.
-
~max_rate
(Double
, default:-1
)Maximum publish rate [Hz] of frequency vs amplitude plot image. Setting this value low reduces CPU load.
-1
means no maximum limit.
-
Changelog for package audio_to_spectrogram
1.2.17 (2023-11-14)
1.2.16 (2023-11-10)
- [audio_to_spectrogram, sound_classification] Add data_to_spectrogram (#2767)
- [audio_to_spectrogram] Enable to change spectrum plot from rosparam (#2760)
- Fix audio to spectrogram plot and add test (#2764)
- [audio_to_spectrogram] Add AudioAmplitudePlot node to visualize audio amplitude #2657 (#2755)
- [audio_to_spectrogram] Enable publishing frequency vs amplitude plot (#2654)
- use catkin_install_python to install python scripts under node_scripts/ scripts/ (#2743)
- Contributors: Kei Okada, Naoto Tsukamoto, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Iory Yanokura
1.2.15 (2020-10-10)
1.2.14 (2020-10-09)
1.2.13 (2020-10-08)
1.2.12 (2020-10-03)
1.2.11 (2020-10-01)
- Fix for noetic / 20.04
(#2507)
- upgrade package.xml to format=3, migrate to noetic with ROS_PYTHON_VERSION=2/3, use multiple ROS distro strategy http://wiki.ros.org/noetic/Migration
- [audio_to_spectrogram] Enable multi channel input by retrieving single channel data (#2514)
- [audio_to_spectrogram] Add README for usage and scripts
interface
(#2498)
- [audio_to_spectrogram] Add README for usage and scripts interface
- [audio_to_spectrogram] add args to audio_to_spectrogram.launch
- [audio_to_spectrogram] Add arg to run audio_capture
- Convert audio data to spectrogram
(#2478)
- Make audio_to_spectrogram as ROS package
- Contributors: Kei Okada, Naoya Yamaguchi, Shingo Kitagawa
1.2.10 (2019-03-27)
1.2.9 (2019-02-23)
1.2.8 (2019-02-22)
1.2.7 (2019-02-14)
1.2.6 (2018-11-02)
1.2.5 (2018-04-09)
1.2.4 (2018-01-12)
1.2.3 (2017-11-23)
1.2.2 (2017-07-23)
1.2.1 (2017-07-15 20:44)
1.2.0 (2017-07-15 09:14)
1.1.3 (2017-07-07)
1.1.2 (2017-06-16)
1.1.1 (2017-03-04)
1.1.0 (2017-02-09 22:50)
1.0.4 (2017-02-09 22:48)
1.0.3 (2017-02-08)
1.0.2 (2017-01-12)
1.0.1 (2016-12-13)
1.0.0 (2016-12-12)
0.3.29 (2016-10-30)
0.3.28 (2016-10-29 16:34)
0.3.27 (2016-10-29 00:14)
0.3.26 (2016-10-27)
0.3.25 (2016-09-16)
0.3.24 (2016-09-15)
0.3.23 (2016-09-14)
0.3.22 (2016-09-13)
0.3.21 (2016-04-15)
0.3.20 (2016-04-14)
0.3.19 (2016-03-22)
0.3.18 (2016-03-21)
0.3.17 (2016-03-20)
0.3.16 (2016-02-11)
0.3.15 (2016-02-09)
0.3.14 (2016-02-04)
0.3.13 (2015-12-19 17:35)
0.3.12 (2015-12-19 14:44)
0.3.11 (2015-12-18)
0.3.10 (2015-12-17)
0.3.9 (2015-12-14)
0.3.8 (2015-12-08)
0.3.7 (2015-11-19)
0.3.6 (2015-09-11)
0.3.5 (2015-09-09)
0.3.4 (2015-09-07)
0.3.3 (2015-09-06)
0.3.2 (2015-09-05)
0.3.1 (2015-09-04 17:12)
0.3.0 (2015-09-04 12:37)
0.2.18 (2015-09-04 01:07)
0.2.17 (2015-08-21)
0.2.16 (2015-08-19)
0.2.15 (2015-08-18)
0.2.14 (2015-08-13)
0.2.13 (2015-06-11)
0.2.12 (2015-05-04)
0.2.11 (2015-04-13)
0.2.10 (2015-04-09)
0.2.9 (2015-03-29)
0.2.7 (2015-03-26)
0.2.6 (2015-03-25)
0.2.5 (2015-03-17)
0.2.4 (2015-03-08)
0.2.3 (2015-02-02)
0.2.2 (2015-01-30)
0.2.0 (2015-01-29 12:20)
0.1.34 (2015-01-29 11:53)
0.1.33 (2015-01-24)
0.1.32 (2015-01-12)
0.1.31 (2015-01-08)
0.1.30 (2014-12-24 16:45)
0.1.29 (2014-12-24 12:43)
0.1.28 (2014-12-17)
0.1.27 (2014-12-09)
0.1.26 (2014-11-23)
0.1.25 (2014-11-21)
0.1.24 (2014-11-15)
0.1.23 (2014-10-09)
0.1.22 (2014-09-24)
0.1.21 (2014-09-20)
0.1.20 (2014-09-17)
0.1.19 (2014-09-15)
0.1.18 (2014-09-13)
0.1.17 (2014-09-07)
0.1.16 (2014-09-04)
0.1.15 (2014-08-26)
0.1.14 (2014-08-01)
0.1.13 (2014-07-29)
0.1.12 (2014-07-24)
0.1.11 (2014-07-08)
0.1.10 (2014-07-07)
0.1.9 (2014-07-01)
0.1.8 (2014-06-29)
0.1.7 (2014-05-31)
0.1.6 (2014-05-30)
0.1.5 (2014-05-29)
0.1.4 (2014-04-25)
0.1.3 (2014-04-12)
0.1.2 (2014-04-11)
0.1.1 (2014-04-10)
Wiki Tutorials
Package Dependencies
System Dependencies
Dependant Packages
Name | Deps |
---|---|
sound_classification |
Launch files
- sample/sample_wrench_to_spectrogram.launch
-
- gui [default: true]
- filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]
- sample/sample_audio_to_spectrogram.launch
- data flow
-
- gui [default: true]
- filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
- launch/audio_to_spectrogram.launch
- data flow
-
- launch_audio_capture [default: true]
- audio_capture_ns [default: /]
- bitdepth [default: 16]
- mic_sampling_rate [default: 16000]
- n_channel [default: 1]
- target_channel [default: 0]
- device [default: hw:0,0]
- audio_topic [default: /audio]
- fft_sampling_period [default: 0.3]
- fft_exec_rate [default: 50]
- audio_amp_plot_max_amp [default: 10000.0]
- audio_amp_plot_window_size [default: 10.0]
- audio_amp_plot_rate [default: 10.0]
- spectrogram_source [default: audio_to_spectrum/log_spectrum]
- high_cut_freq [default: 800]
- low_cut_freq [default: 1]
- spectrogram_period [default: 5]
- preprocessed_spectrogram_source_plot_min_amp [default: 0.0]
- preprocessed_spectrogram_source_plot_max_amp [default: 20.0]
- preprocessed_spectrogram_source_plot_queue_size [default: 1]
- preprocessed_spectrogram_source_plot_max_rate [default: -1]
- gui [default: true]
- launch/spectrum_plot.launch
-
- spectrum
- plotter_name [default: spectrum_plot]
- min_amp [default: 0.0]
- max_amp [default: 20.0]
- queue_size [default: 1]
- max_rate [default: -1]
- gui [default: true]
- launch/wrench_to_spectrogram.launch
- data flow
-
- how_to_get_scalar [default: element_extraction]
- target_element [default: force.z]
- data_sampling_rate [default: 500]
- wrench_topic [default: /ft_sensor]
- fft_sampling_period [default: 0.3]
- fft_exec_rate [default: 50]
- data_amp_plot_max_amp [default: 10.0]
- data_amp_plot_window_size [default: 10.0]
- data_amp_plot_rate [default: 10.0]
- spectrogram_source [default: data_to_spectrum/log_spectrum]
- high_cut_freq [default: 250]
- low_cut_freq [default: 5]
- spectrogram_period [default: 5]
- preprocessed_spectrogram_source_plot_min_amp [default: -10.0]
- preprocessed_spectrogram_source_plot_max_amp [default: 10.0]
- preprocessed_spectrogram_source_plot_queue_size [default: 1]
- preprocessed_spectrogram_source_plot_max_rate [default: -1]
- normalized_half_spectrum_plot_min_amp [default: 0.0]
- normalized_half_spectrum_plot_max_amp [default: 0.2]
- normalized_half_spectrum_plot_queue_size [default: 1]
- normalized_half_spectrum_plot_max_rate [default: -1]
- gui [default: true]
- launch/spectrum_to_spectrogram.launch
-
- spectrum
- data_sampling_rate [default: 500]
- high_cut_freq [default: 250]
- low_cut_freq [default: 5]
- spectrogram_height [default: 300]
- spectrogram_width [default: 300]
- spectrogram_period [default: 5]
- preprocessed_spectrum_plot_min_amp [default: -10.0]
- preprocessed_spectrum_plot_max_amp [default: 10.0]
- preprocessed_spectrum_plot_queue_size [default: 1]
- preprocessed_spectrum_plot_max_rate [default: -1]
- gui [default: true]
- do_dynamic_scaling [default: true]
- colormap [default: 2]
- launch/data_to_spectrum.launch
-
- data_topic
- expression_to_get_data [default: m.data]
- data_sampling_rate [default: 500]
- fft_sampling_period [default: 0.3]
- is_integer [default: false]
- is_signed [default: true]
- bitdepth [default: 64]
- n_channel [default: 1]
- target_channel [default: 0]
- fft_exec_rate [default: 50]
- data_amp_plot_max_amp [default: 10.0]
- data_amp_plot_window_size [default: 10.0]
- data_amp_plot_rate [default: 10.0]
- gui [default: true]
- launch/audio_to_spectrum.launch
-
- audio_topic [default: /audio]
- n_channel [default: 1]
- target_channel [default: 0]
- mic_sampling_rate [default: 16000]
- fft_sampling_period [default: 0.3]
- bitdepth [default: 16]
- fft_exec_rate [default: 50]
- audio_amp_plot_max_amp [default: 10000.0]
- audio_amp_plot_window_size [default: 10.0]
- audio_amp_plot_rate [default: 10.0]
- gui [default: true]