471,349 Members | 1,412 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,349 software developers and data experts.

Edit Audio Using Python?

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 :)

Jun 20 '07 #1
4 6340
Ah! I found this on the official website:
http://www.python.org/doc/1.5.2p2/li...e-audioop.html

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

Jun 20 '07 #2
On Jun 20, 12:21 pm, Ultrus <ownthe...@gmail.comwrote:
Ah! I found this on the official website:http://www.python.org/doc/1.5.2p2/li...e-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

Jun 20 '07 #3
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

Jun 21 '07 #4
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
Jun 29 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Bruce Bon | last post: by
1 post views Thread by Noah | last post: by
24 posts views Thread by Dave Benjamin | last post: by
1 post views Thread by Ron Provost | last post: by
reply views Thread by apa7hy.spam | last post: by
2 posts views Thread by andrea valle | last post: by
2 posts views Thread by Pan Xingzhi | last post: by
5 posts views Thread by skip | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.