Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #36562

Re: Getting audio input and processing it?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <d@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'encoded': 0.05; 'pop': 0.05; 'that?': 0.05; 'apis': 0.07; 'bits': 0.07; 'pypi': 0.07; 'sanity': 0.07; 'type,': 0.07; '128': 0.09; 'before.': 0.09; 'input,': 0.09; 'subject:Getting': 0.09; 'threshold': 0.09; 'ignore': 0.13; 'english.': 0.15; 'bits).': 0.16; 'energy.': 0.16; 'expected,': 0.16; 'frequencies': 0.16; 'mark.': 0.16; 'nonzero': 0.16; 'outputs': 0.16; 'subject:audio': 0.16; 'wrote:': 0.17; 'byte': 0.17; 'bytes': 0.17; 'detect': 0.17; 'input': 0.18; '(or': 0.18; 'translate': 0.20; 'not,': 0.21; 'filtering': 0.22; "i'd": 0.22; "i've": 0.23; 'project,': 0.24; 'feature': 0.24; 'header:In- Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'values': 0.26; 'this?': 0.28; 'represent': 0.28; 'measure': 0.29; 'quiet': 0.29; 'probably': 0.29; 'code': 0.31; 'gets': 0.32; 'system,': 0.32; 'space,': 0.32; "who's": 0.32; 'done,': 0.33; 'like:': 0.33; 'zero': 0.33; 'to:addr:python-list': 0.33; 'point.': 0.33; 'project': 0.34; 'done': 0.34; 'bigger': 0.35; 'so,': 0.35; 'pm,': 0.35; 'subject:?': 0.35; 'something': 0.35; 'there': 0.35; 'add': 0.36; 'michael': 0.36; 'but': 0.36; 'operating': 0.36; 'ones': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'possible.': 0.38; 'sure': 0.38; 'gives': 0.39; 'to:addr:python.org': 0.39; 'takes': 0.39; 'received:192': 0.39; 'short': 0.39; 'received:192.168': 0.40; 'end': 0.40; 'your': 0.60; 'information': 0.63; 'fun': 0.64; 'frequency': 0.65; 'header :Reply-To:1': 0.68; 'dit': 0.71; 'received:74.208': 0.71; 'wave': 0.71; 'reply-to:no real name:2**0': 0.72; 'detecting': 0.84; 'presumably': 0.84; 'noise': 0.91
Date Thu, 10 Jan 2013 00:46:55 -0500
From Dave Angel <d@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1
MIME-Version 1.0
To python-list@python.org
Subject Re: Getting audio input and processing it?
References <480ea35c-82b5-4199-a569-c3857061f6be@googlegroups.com>
In-Reply-To <480ea35c-82b5-4199-a569-c3857061f6be@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:fMdtv76YrdedCuSilsCjQUDUdykWdAh3clDrGvExV+o ZExKmIhQBufSZcPlWP+vofvpEXzGw8Sn1b3mnV7C7o1LcezSIk E/B5O7oj40sfXLuUEvSxqN4YmZanNaHIJAFEs0RMA7IooZcLcD xCcg+Ddhi11TW6P5ML4z5jlnYC79IiMfU+W6DyQ3fN+59k7JPF w29CPKth++WvpxxP3VJbO5sb3Fmq6A8yq/IyJhvvSrKCeUNFQB 1r8uFRdvFsLFZXvLZR55HCZRy1x0BSjynWxJj4NE1Y+n2FQ7Gj urIk+9BiE30/kX3mfDXPyx0gR9b+bj+RgUwS5KE+atEiIoKEQ= =
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To d@davea.name
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.363.1357796838.2939.python-list@python.org> (permalink)
Lines 36
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1357796838 news.xs4all.nl 6903 [2001:888:2000:d::a6]:51196
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:36562

Show key headers only | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Getting audio input and processing it? Michael Curry <michaeldcurry1@gmail.com> - 2013-01-09 16:20 -0800
  Re: Getting audio input and processing it? Dave Angel <d@davea.name> - 2013-01-10 00:46 -0500

csiph-web