mp3 wav editing in python
Daniel Schüle
uval at rz.uni-karlsruhe.de
Mon Nov 14 13:43:14 EST 2005
yb wrote:
> Hi,
>
> Is there a python based tool to cut mp3 and wav file at a start and end
> time? I'm looking for a python script that can output a new wav or mp3
> file based on star and endpoint.
>
> Thank you
>
there is a wave module
>>> import wave
>>> dir(wave)
['Chunk', 'Error', 'WAVE_FORMAT_PCM', 'Wave_read', 'Wave_write',
'__all__', '__builtin__', '__builtins__', '__doc__', '__file__',
'__name__', '_array_fmts', 'big_endian', 'open', 'openfp', 'struct']
>>> wav= wave.open("/musik/musik/wav/Co - 1.wav")
>>> wav
<wave.Wave_read instance at 0x403ebbac>
>>> dir(wav)
['__del__', '__doc__', '__init__', '__module__', '_compname',
'_comptype', '_convert', '_data_chunk', '_data_seek_needed', '_file',
'_fmt_chunk_read', '_framerate', '_framesize', '_i_opened_the_file',
'_nchannels', '_nframes', '_read_fmt_chunk', '_sampwidth', '_soundpos',
'close', 'getcompname', 'getcomptype', 'getfp', 'getframerate',
'getmark', 'getmarkers', 'getnchannels', 'getnframes', 'getparams',
'getsampwidth', 'initfp', 'readframes', 'rewind', 'setpos', 'tell']
>>> wav.getnchannels()
2
>>>
and so on, this is what google gave me
http://scipy.mit.edu/tutorials/wave.pdf
I did some wave ploting with matplotlib module, so I think
it's feasible to cut and write wave files too
as for mp3, I don't know of any modules
I think mainly because of license issue
you could decode mp3 to wav and process whatever you want to process
but to encode them back into mp3 is a problem
maybe you could use lame or bladeenc as a command line tool
or use ogg instead
http://www.andrewchatham.com/pyogg/
there are de/encoders freely available
this may also be interessting to you
http://pymedia.org/
hth, Daniel
More information about the Python-list
mailing list