No version for distro humble showing jade. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 1.2.19
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 2025-05-14
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

Convert audio (audio_common_msgs/AudioData) to spectrogram (sensor_msgs/Image)

Additional Links

No additional links.

Maintainers

  • Naoya Yamaguchi

Authors

No additional 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.

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package audio_to_spectrogram

1.2.19 (2025-05-14)

  • Merge pull request #2879 from jsk-ros-pkg/add_license add LICENSE
  • add LICENSE
  • ad LICENSE
  • Contributors: Kei Okada

1.2.18 (2025-05-10)

  • [audio_to_spectrogram] Fix when to use catkin_install_python (#2859) Conditional branch introduced by https://github.com/jsk-ros-pkg/jsk_recognition/pull/2743 is wrong

  • Add missing ros_environment dependency to package.xml (#2837)

    Any package that evaluates ROS_VERSION, ROS_DISTRO or ROS_PYTHON_VERSION at build time should add ros_environment as a dependency.

  • Contributors: Jeremy Kolb, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Yuki Furuta

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)
  • [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)

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

  • 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/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]
  • 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/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/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/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]
  • sample/sample_audio_to_spectrogram.launch
    • data flow
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
  • sample/sample_wrench_to_spectrogram.launch
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange

No version for distro jazzy showing jade. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 1.2.19
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 2025-05-14
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

Convert audio (audio_common_msgs/AudioData) to spectrogram (sensor_msgs/Image)

Additional Links

No additional links.

Maintainers

  • Naoya Yamaguchi

Authors

No additional 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.

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package audio_to_spectrogram

1.2.19 (2025-05-14)

  • Merge pull request #2879 from jsk-ros-pkg/add_license add LICENSE
  • add LICENSE
  • ad LICENSE
  • Contributors: Kei Okada

1.2.18 (2025-05-10)

  • [audio_to_spectrogram] Fix when to use catkin_install_python (#2859) Conditional branch introduced by https://github.com/jsk-ros-pkg/jsk_recognition/pull/2743 is wrong

  • Add missing ros_environment dependency to package.xml (#2837)

    Any package that evaluates ROS_VERSION, ROS_DISTRO or ROS_PYTHON_VERSION at build time should add ros_environment as a dependency.

  • Contributors: Jeremy Kolb, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Yuki Furuta

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)
  • [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)

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

  • 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/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]
  • 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/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/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/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]
  • sample/sample_audio_to_spectrogram.launch
    • data flow
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
  • sample/sample_wrench_to_spectrogram.launch
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange

No version for distro kilted showing jade. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 1.2.19
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 2025-05-14
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

Convert audio (audio_common_msgs/AudioData) to spectrogram (sensor_msgs/Image)

Additional Links

No additional links.

Maintainers

  • Naoya Yamaguchi

Authors

No additional 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.

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package audio_to_spectrogram

1.2.19 (2025-05-14)

  • Merge pull request #2879 from jsk-ros-pkg/add_license add LICENSE
  • add LICENSE
  • ad LICENSE
  • Contributors: Kei Okada

1.2.18 (2025-05-10)

  • [audio_to_spectrogram] Fix when to use catkin_install_python (#2859) Conditional branch introduced by https://github.com/jsk-ros-pkg/jsk_recognition/pull/2743 is wrong

  • Add missing ros_environment dependency to package.xml (#2837)

    Any package that evaluates ROS_VERSION, ROS_DISTRO or ROS_PYTHON_VERSION at build time should add ros_environment as a dependency.

  • Contributors: Jeremy Kolb, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Yuki Furuta

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)
  • [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)

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

  • 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/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]
  • 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/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/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/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]
  • sample/sample_audio_to_spectrogram.launch
    • data flow
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
  • sample/sample_wrench_to_spectrogram.launch
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange

No version for distro rolling showing jade. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 1.2.19
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 2025-05-14
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

Convert audio (audio_common_msgs/AudioData) to spectrogram (sensor_msgs/Image)

Additional Links

No additional links.

Maintainers

  • Naoya Yamaguchi

Authors

No additional 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.

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package audio_to_spectrogram

1.2.19 (2025-05-14)

  • Merge pull request #2879 from jsk-ros-pkg/add_license add LICENSE
  • add LICENSE
  • ad LICENSE
  • Contributors: Kei Okada

1.2.18 (2025-05-10)

  • [audio_to_spectrogram] Fix when to use catkin_install_python (#2859) Conditional branch introduced by https://github.com/jsk-ros-pkg/jsk_recognition/pull/2743 is wrong

  • Add missing ros_environment dependency to package.xml (#2837)

    Any package that evaluates ROS_VERSION, ROS_DISTRO or ROS_PYTHON_VERSION at build time should add ros_environment as a dependency.

  • Contributors: Jeremy Kolb, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Yuki Furuta

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)
  • [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)

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

  • 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/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]
  • 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/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/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/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]
  • sample/sample_audio_to_spectrogram.launch
    • data flow
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
  • sample/sample_wrench_to_spectrogram.launch
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange

No version for distro ardent showing jade. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 1.2.19
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 2025-05-14
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

Convert audio (audio_common_msgs/AudioData) to spectrogram (sensor_msgs/Image)

Additional Links

No additional links.

Maintainers

  • Naoya Yamaguchi

Authors

No additional 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.

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package audio_to_spectrogram

1.2.19 (2025-05-14)

  • Merge pull request #2879 from jsk-ros-pkg/add_license add LICENSE
  • add LICENSE
  • ad LICENSE
  • Contributors: Kei Okada

1.2.18 (2025-05-10)

  • [audio_to_spectrogram] Fix when to use catkin_install_python (#2859) Conditional branch introduced by https://github.com/jsk-ros-pkg/jsk_recognition/pull/2743 is wrong

  • Add missing ros_environment dependency to package.xml (#2837)

    Any package that evaluates ROS_VERSION, ROS_DISTRO or ROS_PYTHON_VERSION at build time should add ros_environment as a dependency.

  • Contributors: Jeremy Kolb, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Yuki Furuta

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)
  • [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)

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

  • 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/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]
  • 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/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/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/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]
  • sample/sample_audio_to_spectrogram.launch
    • data flow
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
  • sample/sample_wrench_to_spectrogram.launch
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange

No version for distro bouncy showing jade. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 1.2.19
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 2025-05-14
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

Convert audio (audio_common_msgs/AudioData) to spectrogram (sensor_msgs/Image)

Additional Links

No additional links.

Maintainers

  • Naoya Yamaguchi

Authors

No additional 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.

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package audio_to_spectrogram

1.2.19 (2025-05-14)

  • Merge pull request #2879 from jsk-ros-pkg/add_license add LICENSE
  • add LICENSE
  • ad LICENSE
  • Contributors: Kei Okada

1.2.18 (2025-05-10)

  • [audio_to_spectrogram] Fix when to use catkin_install_python (#2859) Conditional branch introduced by https://github.com/jsk-ros-pkg/jsk_recognition/pull/2743 is wrong

  • Add missing ros_environment dependency to package.xml (#2837)

    Any package that evaluates ROS_VERSION, ROS_DISTRO or ROS_PYTHON_VERSION at build time should add ros_environment as a dependency.

  • Contributors: Jeremy Kolb, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Yuki Furuta

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)
  • [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)

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

  • 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/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]
  • 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/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/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/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]
  • sample/sample_audio_to_spectrogram.launch
    • data flow
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
  • sample/sample_wrench_to_spectrogram.launch
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange

No version for distro crystal showing jade. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 1.2.19
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 2025-05-14
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

Convert audio (audio_common_msgs/AudioData) to spectrogram (sensor_msgs/Image)

Additional Links

No additional links.

Maintainers

  • Naoya Yamaguchi

Authors

No additional 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.

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package audio_to_spectrogram

1.2.19 (2025-05-14)

  • Merge pull request #2879 from jsk-ros-pkg/add_license add LICENSE
  • add LICENSE
  • ad LICENSE
  • Contributors: Kei Okada

1.2.18 (2025-05-10)

  • [audio_to_spectrogram] Fix when to use catkin_install_python (#2859) Conditional branch introduced by https://github.com/jsk-ros-pkg/jsk_recognition/pull/2743 is wrong

  • Add missing ros_environment dependency to package.xml (#2837)

    Any package that evaluates ROS_VERSION, ROS_DISTRO or ROS_PYTHON_VERSION at build time should add ros_environment as a dependency.

  • Contributors: Jeremy Kolb, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Yuki Furuta

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)
  • [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)

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

  • 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/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]
  • 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/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/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/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]
  • sample/sample_audio_to_spectrogram.launch
    • data flow
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
  • sample/sample_wrench_to_spectrogram.launch
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange

No version for distro eloquent showing jade. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 1.2.19
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 2025-05-14
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

Convert audio (audio_common_msgs/AudioData) to spectrogram (sensor_msgs/Image)

Additional Links

No additional links.

Maintainers

  • Naoya Yamaguchi

Authors

No additional 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.

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package audio_to_spectrogram

1.2.19 (2025-05-14)

  • Merge pull request #2879 from jsk-ros-pkg/add_license add LICENSE
  • add LICENSE
  • ad LICENSE
  • Contributors: Kei Okada

1.2.18 (2025-05-10)

  • [audio_to_spectrogram] Fix when to use catkin_install_python (#2859) Conditional branch introduced by https://github.com/jsk-ros-pkg/jsk_recognition/pull/2743 is wrong

  • Add missing ros_environment dependency to package.xml (#2837)

    Any package that evaluates ROS_VERSION, ROS_DISTRO or ROS_PYTHON_VERSION at build time should add ros_environment as a dependency.

  • Contributors: Jeremy Kolb, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Yuki Furuta

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)
  • [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)

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

  • 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/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]
  • 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/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/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/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]
  • sample/sample_audio_to_spectrogram.launch
    • data flow
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
  • sample/sample_wrench_to_spectrogram.launch
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange

No version for distro dashing showing jade. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 1.2.19
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 2025-05-14
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

Convert audio (audio_common_msgs/AudioData) to spectrogram (sensor_msgs/Image)

Additional Links

No additional links.

Maintainers

  • Naoya Yamaguchi

Authors

No additional 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.

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package audio_to_spectrogram

1.2.19 (2025-05-14)

  • Merge pull request #2879 from jsk-ros-pkg/add_license add LICENSE
  • add LICENSE
  • ad LICENSE
  • Contributors: Kei Okada

1.2.18 (2025-05-10)

  • [audio_to_spectrogram] Fix when to use catkin_install_python (#2859) Conditional branch introduced by https://github.com/jsk-ros-pkg/jsk_recognition/pull/2743 is wrong

  • Add missing ros_environment dependency to package.xml (#2837)

    Any package that evaluates ROS_VERSION, ROS_DISTRO or ROS_PYTHON_VERSION at build time should add ros_environment as a dependency.

  • Contributors: Jeremy Kolb, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Yuki Furuta

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)
  • [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)

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

  • 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/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]
  • 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/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/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/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]
  • sample/sample_audio_to_spectrogram.launch
    • data flow
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
  • sample/sample_wrench_to_spectrogram.launch
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange

No version for distro galactic showing jade. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 1.2.19
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 2025-05-14
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

Convert audio (audio_common_msgs/AudioData) to spectrogram (sensor_msgs/Image)

Additional Links

No additional links.

Maintainers

  • Naoya Yamaguchi

Authors

No additional 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.

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package audio_to_spectrogram

1.2.19 (2025-05-14)

  • Merge pull request #2879 from jsk-ros-pkg/add_license add LICENSE
  • add LICENSE
  • ad LICENSE
  • Contributors: Kei Okada

1.2.18 (2025-05-10)

  • [audio_to_spectrogram] Fix when to use catkin_install_python (#2859) Conditional branch introduced by https://github.com/jsk-ros-pkg/jsk_recognition/pull/2743 is wrong

  • Add missing ros_environment dependency to package.xml (#2837)

    Any package that evaluates ROS_VERSION, ROS_DISTRO or ROS_PYTHON_VERSION at build time should add ros_environment as a dependency.

  • Contributors: Jeremy Kolb, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Yuki Furuta

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)
  • [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)

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

  • 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/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]
  • 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/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/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/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]
  • sample/sample_audio_to_spectrogram.launch
    • data flow
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
  • sample/sample_wrench_to_spectrogram.launch
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange

No version for distro foxy showing jade. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 1.2.19
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 2025-05-14
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

Convert audio (audio_common_msgs/AudioData) to spectrogram (sensor_msgs/Image)

Additional Links

No additional links.

Maintainers

  • Naoya Yamaguchi

Authors

No additional 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.

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package audio_to_spectrogram

1.2.19 (2025-05-14)

  • Merge pull request #2879 from jsk-ros-pkg/add_license add LICENSE
  • add LICENSE
  • ad LICENSE
  • Contributors: Kei Okada

1.2.18 (2025-05-10)

  • [audio_to_spectrogram] Fix when to use catkin_install_python (#2859) Conditional branch introduced by https://github.com/jsk-ros-pkg/jsk_recognition/pull/2743 is wrong

  • Add missing ros_environment dependency to package.xml (#2837)

    Any package that evaluates ROS_VERSION, ROS_DISTRO or ROS_PYTHON_VERSION at build time should add ros_environment as a dependency.

  • Contributors: Jeremy Kolb, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Yuki Furuta

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)
  • [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)

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

  • 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/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]
  • 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/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/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/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]
  • sample/sample_audio_to_spectrogram.launch
    • data flow
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
  • sample/sample_wrench_to_spectrogram.launch
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange

No version for distro iron showing jade. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 1.2.19
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 2025-05-14
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

Convert audio (audio_common_msgs/AudioData) to spectrogram (sensor_msgs/Image)

Additional Links

No additional links.

Maintainers

  • Naoya Yamaguchi

Authors

No additional 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.

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package audio_to_spectrogram

1.2.19 (2025-05-14)

  • Merge pull request #2879 from jsk-ros-pkg/add_license add LICENSE
  • add LICENSE
  • ad LICENSE
  • Contributors: Kei Okada

1.2.18 (2025-05-10)

  • [audio_to_spectrogram] Fix when to use catkin_install_python (#2859) Conditional branch introduced by https://github.com/jsk-ros-pkg/jsk_recognition/pull/2743 is wrong

  • Add missing ros_environment dependency to package.xml (#2837)

    Any package that evaluates ROS_VERSION, ROS_DISTRO or ROS_PYTHON_VERSION at build time should add ros_environment as a dependency.

  • Contributors: Jeremy Kolb, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Yuki Furuta

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)
  • [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)

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

  • 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/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]
  • 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/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/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/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]
  • sample/sample_audio_to_spectrogram.launch
    • data flow
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
  • sample/sample_wrench_to_spectrogram.launch
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange

No version for distro lunar showing jade. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 1.2.19
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 2025-05-14
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

Convert audio (audio_common_msgs/AudioData) to spectrogram (sensor_msgs/Image)

Additional Links

No additional links.

Maintainers

  • Naoya Yamaguchi

Authors

No additional 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.

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package audio_to_spectrogram

1.2.19 (2025-05-14)

  • Merge pull request #2879 from jsk-ros-pkg/add_license add LICENSE
  • add LICENSE
  • ad LICENSE
  • Contributors: Kei Okada

1.2.18 (2025-05-10)

  • [audio_to_spectrogram] Fix when to use catkin_install_python (#2859) Conditional branch introduced by https://github.com/jsk-ros-pkg/jsk_recognition/pull/2743 is wrong

  • Add missing ros_environment dependency to package.xml (#2837)

    Any package that evaluates ROS_VERSION, ROS_DISTRO or ROS_PYTHON_VERSION at build time should add ros_environment as a dependency.

  • Contributors: Jeremy Kolb, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Yuki Furuta

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)
  • [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)

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

  • 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/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]
  • 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/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/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/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]
  • sample/sample_audio_to_spectrogram.launch
    • data flow
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
  • sample/sample_wrench_to_spectrogram.launch
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange

Package Summary

Tags No category tags.
Version 1.2.19
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 2025-05-14
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

Convert audio (audio_common_msgs/AudioData) to spectrogram (sensor_msgs/Image)

Additional Links

No additional links.

Maintainers

  • Naoya Yamaguchi

Authors

No additional 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.

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package audio_to_spectrogram

1.2.19 (2025-05-14)

  • Merge pull request #2879 from jsk-ros-pkg/add_license add LICENSE
  • add LICENSE
  • ad LICENSE
  • Contributors: Kei Okada

1.2.18 (2025-05-10)

  • [audio_to_spectrogram] Fix when to use catkin_install_python (#2859) Conditional branch introduced by https://github.com/jsk-ros-pkg/jsk_recognition/pull/2743 is wrong

  • Add missing ros_environment dependency to package.xml (#2837)

    Any package that evaluates ROS_VERSION, ROS_DISTRO or ROS_PYTHON_VERSION at build time should add ros_environment as a dependency.

  • Contributors: Jeremy Kolb, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Yuki Furuta

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)
  • [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)

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

  • 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/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]
  • 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/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/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/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]
  • sample/sample_audio_to_spectrogram.launch
    • data flow
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
  • sample/sample_wrench_to_spectrogram.launch
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange

Package Summary

Tags No category tags.
Version 1.2.19
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 2025-05-14
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

Convert audio (audio_common_msgs/AudioData) to spectrogram (sensor_msgs/Image)

Additional Links

No additional links.

Maintainers

  • Naoya Yamaguchi

Authors

No additional 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.

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package audio_to_spectrogram

1.2.19 (2025-05-14)

  • Merge pull request #2879 from jsk-ros-pkg/add_license add LICENSE
  • add LICENSE
  • ad LICENSE
  • Contributors: Kei Okada

1.2.18 (2025-05-10)

  • [audio_to_spectrogram] Fix when to use catkin_install_python (#2859) Conditional branch introduced by https://github.com/jsk-ros-pkg/jsk_recognition/pull/2743 is wrong

  • Add missing ros_environment dependency to package.xml (#2837)

    Any package that evaluates ROS_VERSION, ROS_DISTRO or ROS_PYTHON_VERSION at build time should add ros_environment as a dependency.

  • Contributors: Jeremy Kolb, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Yuki Furuta

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)
  • [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)

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

  • 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/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]
  • 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/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/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/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]
  • sample/sample_audio_to_spectrogram.launch
    • data flow
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
  • sample/sample_wrench_to_spectrogram.launch
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange

Package Summary

Tags No category tags.
Version 1.2.19
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 2025-05-14
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

Convert audio (audio_common_msgs/AudioData) to spectrogram (sensor_msgs/Image)

Additional Links

No additional links.

Maintainers

  • Naoya Yamaguchi

Authors

No additional 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.

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package audio_to_spectrogram

1.2.19 (2025-05-14)

  • Merge pull request #2879 from jsk-ros-pkg/add_license add LICENSE
  • add LICENSE
  • ad LICENSE
  • Contributors: Kei Okada

1.2.18 (2025-05-10)

  • [audio_to_spectrogram] Fix when to use catkin_install_python (#2859) Conditional branch introduced by https://github.com/jsk-ros-pkg/jsk_recognition/pull/2743 is wrong

  • Add missing ros_environment dependency to package.xml (#2837)

    Any package that evaluates ROS_VERSION, ROS_DISTRO or ROS_PYTHON_VERSION at build time should add ros_environment as a dependency.

  • Contributors: Jeremy Kolb, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Yuki Furuta

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)
  • [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)

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

  • 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/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]
  • 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/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/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/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]
  • sample/sample_audio_to_spectrogram.launch
    • data flow
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
  • sample/sample_wrench_to_spectrogram.launch
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange

Package Summary

Tags No category tags.
Version 1.2.19
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 2025-05-14
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

Convert audio (audio_common_msgs/AudioData) to spectrogram (sensor_msgs/Image)

Additional Links

No additional links.

Maintainers

  • Naoya Yamaguchi

Authors

No additional 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.

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package audio_to_spectrogram

1.2.19 (2025-05-14)

  • Merge pull request #2879 from jsk-ros-pkg/add_license add LICENSE
  • add LICENSE
  • ad LICENSE
  • Contributors: Kei Okada

1.2.18 (2025-05-10)

  • [audio_to_spectrogram] Fix when to use catkin_install_python (#2859) Conditional branch introduced by https://github.com/jsk-ros-pkg/jsk_recognition/pull/2743 is wrong

  • Add missing ros_environment dependency to package.xml (#2837)

    Any package that evaluates ROS_VERSION, ROS_DISTRO or ROS_PYTHON_VERSION at build time should add ros_environment as a dependency.

  • Contributors: Jeremy Kolb, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Yuki Furuta

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)
  • [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)

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

  • 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/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]
  • 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/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/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/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]
  • sample/sample_audio_to_spectrogram.launch
    • data flow
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
  • sample/sample_wrench_to_spectrogram.launch
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange

Package Summary

Tags No category tags.
Version 1.2.19
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 2025-05-14
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

Convert audio (audio_common_msgs/AudioData) to spectrogram (sensor_msgs/Image)

Additional Links

No additional links.

Maintainers

  • Naoya Yamaguchi

Authors

No additional 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.

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package audio_to_spectrogram

1.2.19 (2025-05-14)

  • Merge pull request #2879 from jsk-ros-pkg/add_license add LICENSE
  • add LICENSE
  • ad LICENSE
  • Contributors: Kei Okada

1.2.18 (2025-05-10)

  • [audio_to_spectrogram] Fix when to use catkin_install_python (#2859) Conditional branch introduced by https://github.com/jsk-ros-pkg/jsk_recognition/pull/2743 is wrong

  • Add missing ros_environment dependency to package.xml (#2837)

    Any package that evaluates ROS_VERSION, ROS_DISTRO or ROS_PYTHON_VERSION at build time should add ros_environment as a dependency.

  • Contributors: Jeremy Kolb, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Yuki Furuta

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)
  • [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)

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

  • 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/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]
  • 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/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/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/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]
  • sample/sample_audio_to_spectrogram.launch
    • data flow
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
  • sample/sample_wrench_to_spectrogram.launch
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange

Package Summary

Tags No category tags.
Version 1.2.19
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 2025-05-14
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

Convert audio (audio_common_msgs/AudioData) to spectrogram (sensor_msgs/Image)

Additional Links

No additional links.

Maintainers

  • Naoya Yamaguchi

Authors

No additional 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.

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package audio_to_spectrogram

1.2.19 (2025-05-14)

  • Merge pull request #2879 from jsk-ros-pkg/add_license add LICENSE
  • add LICENSE
  • ad LICENSE
  • Contributors: Kei Okada

1.2.18 (2025-05-10)

  • [audio_to_spectrogram] Fix when to use catkin_install_python (#2859) Conditional branch introduced by https://github.com/jsk-ros-pkg/jsk_recognition/pull/2743 is wrong

  • Add missing ros_environment dependency to package.xml (#2837)

    Any package that evaluates ROS_VERSION, ROS_DISTRO or ROS_PYTHON_VERSION at build time should add ros_environment as a dependency.

  • Contributors: Jeremy Kolb, Shingo Kitagawa, Shun Hasegawa, Yoshiki Obinata, Yuki Furuta

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)
  • [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)

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

  • 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/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]
  • 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/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/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/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]
  • sample/sample_audio_to_spectrogram.launch
    • data flow
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/audio_300hz.bag]
  • sample/sample_wrench_to_spectrogram.launch
      • gui [default: true]
      • filename [default: $(find audio_to_spectrogram)/sample/data/wrench_sensing_drill_vibration.bag]

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged audio_to_spectrogram at Robotics Stack Exchange