Edit Audio Using Python?

U

Ultrus

Hello Python Gurus,
I picked up a book the other day on Python programming. Python rocks!
I'm learning Python as I want to call upon it to handle some intensive
tasks from PHP/web server.

The top goal right now is automating audio editing using Python. Is it
possible? I was able to do this directly through php, but it was
reaaaallllyyyyy slowwwwwwww. PHP is not designed for that sort of
thing.

So far I googled the Snack Sound Toolkit at http://www.speech.kth.se/snack/
.. It seems to have potential, but is very limited, and has not been a
very active project lately from what I can tell. I'm not sure I can
use it without learning C or C++ to make it do what I want (fading
ends, appending - there but not working?, mixing). It may work once I
learn more about it.

Do you know of any other modules, scripts, or whatnot that allows for
fast .wav audio editing from a Python script (not through a visual
interface)? Would it be better to start from scratch?

Thank you much for the advise :)
 
A

aaronwmail-usenet

Ah! I found this on the official website:http://www.python.org/doc/1.5.2p2/lib/module-audioop.html

That should keep me occupied. If you think of anything interesting
however, I would be happy to know. :)

I think you'll find that you have to put a lot of pieces together
to manipulate audio -- it's all there, but it's not straightforward.

I did it in my "skimpygimpy" audio components, which may help
(especially
if you ignore the stranger parts where I went off the deep end).

Start by looking at the "waveTools.toneFile()" method, which, I think,
writes out a wave file containing "concert A".

http://skimpygimpy.sourceforge.net -- follow link to downloads...

-- Aaron Watters

===
an apple every 8 hours
will keep 3 doctors away. -- kliban
 
U

Ultrus

Aaron,
Thanks for sharing this!
I think you'll find that you have to put a lot of pieces together
to manipulate audio -- it's all there, but it's not straightforward.

The challenge of building something unique makes it more worth while.
I did it in my "skimpygimpy" audio components, which may help
(especially
if you ignore the stranger parts where I went off the deep end).

Sweet program. I wish I had access to it on websites where I can never
seem to read the captcha letters.

The waveTools are VERY helpful! My biggest wall was getting samples
from audio files. Your scripts go beyond that. I'll play with the
scripts once I know a bit more on Python, and send you an update if I
expand upon it.

Thank you
 
U

Ultrus

Thanks to Aaron, I was able to read and write audio data using
Python's wave module. Trying to better understand the data I'm looking
at, what does each element of the frame represent, and how do I
convert a sample ranging from -32,768 to 32,768 back to a frame set
like below?

When using a 16 bit mono wav file, reading a frame of audio produces 2
numbers like this:

import wave
file = wave.open("myWave.wav")
frame = file.readframes(1) #read first frame
file.close
#ord(frame[0]) = 0 to 256, ord(frame[1]) = 0 to 256,
#possible max of 65,536, or sample with range of -32,768 to 32,768
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,017
Latest member
GreenAcreCBDGummiesReview

Latest Threads

Top