Giter Site home page Giter Site logo

audio_stream_arecord_hack's Introduction

audio_stream_arecord_hack

Just a simple package/script to get audio using arecord and publishing it in a audio_common_msgs/AudioData message.

Usage

rosrun audio_stream_arecord_hack audio_streamer_arecord.py

or

roslaunch audio_stream_arecord_hack audio_stream.launch

You should see your data spitting out at:

rostopic echo /audio_stream/audio_data

Custom config

You can change the blocksize, so the amount of data on every message. You can also change the arecord command to your needed flags.

Easiest way is to change the launchfile that looks like:

<launch>
    <node name="audio_stream" 
          pkg="audio_stream_arecord_hack"
          type="audio_streamer_arecord.py" 
          output="screen"
          args="2048 arecord -f S16_LE -r 16000 -t raw">
          <!-- first argument is blocksize, the rest is the full arecord command -->
</launch>

Plot audio data

 rosrun audio_stream_arecord_hack audio_topic_plotter.py

Change the topic with:

 rosrun audio_stream_arecord_hack audio_topic_plotter.py /audio_stream/audio_data:=/your_AudioData_topic

audio plot

Requires:

sudo pip install pyqtgraph
sudo apt-get install python-qt4
sudo apt-get install python-numpy

Hacky slow terminal plotting of audio data

Just in case you need a super basic way of plotting the audio data... you can use gnuplot_audio_data.py script. It calls with subprocess gnuplot.

You may want to tune up the line gnuplot.stdin.write("set term dumb 200 60\n") which sets the number of characters on X and Y to use for the plot.

Looks like this:

  40000 ++---------+-----------+----------+----------+-----------+---------++
        +          +           +          +          +         Line1 **A*** +
  30000 ++ A                           AA   A  A    A AA     AA A          ++
        |  A                           *A   AAAA    A AAAA   AAAA           |
        |  A      A      A             AA   AA**    A A*AA   *AAA           |
  20000 ++ A      A      A      A      A*   *A*A   AA*AAAA A AAAA A        ++
        | AA     AA  A A A      A      AA   AAA* A A A*AAA AA **A A         |
  10000 ++AA     AA AA A A*     AAA  A *A   *A*A A A A AAA AA AA* A        ++
        | AA     AA AA A AA     AAAA A AA   AAA* A A A AAAA A AAA A         |
        | * AAA  * AAA *AAA A   A*AA A *AAA AA*A A A A A*AA A *AAA          |
      0 A+A AAA  A **A AAAA A A AA** A AAAA AAA *AAA A AAAA A AA A         ++
        A A *AA  A AAA AA AAA AAAAAAA AAAAA AA* AAAA A AA A A *A A          |
 -10000 A+A AAAA A *AAAAA AAAAAA *AAA AAAAAAA*A A AA   AA A A AA A         ++
        AAA *AAA A A* AA  AAAAAA AAAA AA AAAAAA A A    A  A   A*            |
        |AA AAAAAA AA AA  AA AAA AA*A AA A A AA A A           *A            |
 -20000 ++A AAA AA AA AA  AA     AAAA A* A   *A A A           AA           ++
        |   A   AA AA AA  AA     AAAA AA     AA                             |
 -30000 ++  A   AA AA A   AA     AAAA A      *A                            ++
        |   A   A  AA A   AA     AA   A      AA                             |
        +          +           +          +          +           +          +
 -40000 ++---------+-----------+----------+----------+-----------+---------++
        0         200         400        600        800         1000       1200

audio_stream_arecord_hack's People

Contributors

awesomebytes avatar

Watchers

Jesse Clark avatar James Cloos avatar  avatar Benjamin Johnston avatar Xun avatar Nima Ramezani Taghiabadi avatar

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.