Getting audio input and processing it?

Discussion in 'Python' started by Michael Curry, Jan 10, 2013.

  1. I've been working on a Morse Code translator, I've made it work so that youcan input English and it will translate it to Morse and play the Audio. I now want to add a feature to the program that takes audio input, processes it and then outputs the English.

    Are there any specific APIs that I can use to take input from a microphone,is there any way to detect frequencies or amplitudes, as well as find out for how long the wave lasts? If not, are there any implementations of this?Would there be a way to do it?
    Michael Curry, Jan 10, 2013
    #1
    1. Advertising

  2. Michael Curry

    Dave Angel Guest

    On 01/09/2013 07:20 PM, Michael Curry wrote:
    > I've been working on a Morse Code translator, I've made it work so that you can input English and it will translate it to Morse and play the Audio. I now want to add a feature to the program that takes audio input, processes it and then outputs the English.
    >
    > Are there any specific APIs that I can use to take input from a microphone, is there any way to detect frequencies or amplitudes, as well as find out for how long the wave lasts? If not, are there any implementations of this? Would there be a way to do it?


    If you find an approach that gets audio information from your hardware,
    and on your operating system, then you presumably end up with a stream
    of bytes (or of some other data type, if the sample size is bigger than
    8 bits). If this were my project, I'd ignore the detecting of frequency
    (though it can be done, by various filtering techniques), and just
    measure energy. Presumably the signal is quiet for space, and noisy for
    mark. So you set a threshold, and measure how long the signal is below
    the threshold, and then how long it's above. The time above the
    threshold is how long the "wave lasts." Presumably you can then set a
    few length thresholds, and short values are dit and longer ones are dah.

    So, how do you measure energy on a byte string? The way I've seen audio
    encoded in 8 bits has 128 as the DC zero reference point. Values above
    and below that represent a nonzero signal voltage. So you'd do
    something like:
    abs( value-128)

    to get an instantaneous energy. Do a sanity check to make sure the
    "quiet" signal gives you a very small energy (some noise expected, of
    course).

    There are lots of refinements possible. But I suspect someone else is
    going to pop in and say that libary xyz on pypi will do it all for you
    automatically. There's probably someone who's done the whole project
    before. But what's the fun in that?


    --

    DaveA
    Dave Angel, Jan 10, 2013
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wayne...
    Replies:
    4
    Views:
    443
    Wayne...
    Sep 17, 2004
  2. Replies:
    3
    Views:
    392
  3. aeonsun
    Replies:
    2
    Views:
    427
    Luc The Perverse
    Mar 11, 2007
  4. Benjamin Oakes

    Audio Processing in Ruby

    Benjamin Oakes, Mar 5, 2008, in forum: Ruby
    Replies:
    3
    Views:
    335
    Benjamin Oakes
    Mar 10, 2008
  5. sick dick
    Replies:
    0
    Views:
    388
    sick dick
    Apr 3, 2006
Loading...

Share This Page