[Twisted-Python] PyMedia & Tk - based mp3 sound recorder

Petri Savolainen petri.savolainen at iki.fi
Mon Nov 29 07:55:42 MST 2004


I've tried to write a simple sound recorder for python. Basically, it 
just reads sound from mic or line in, and encodes it to mp3 on the fly. 
See http://pymedia.org/tut/src/voice_recorder.py.html for a simple 
example I've taken the pymedia recorder code from. Works nicely - but no 
GUI etc. of course.

I've added a very simple Tk-base GUI using twisted, using 
task.LoopingCall to drive the recorder loop that reads chunks data from 
sound device and encodes them.

The problem is that the sound is now garbled - it sounds as if the loop 
is not fast enough or it's dropping some sound data. Apart from twisted 
and Tk integration, the code should be essentially the same as the 
original example that works fine.

I''ve tried with different task looping frequencies and even added Psyco 
optiomization to the code, and all this has made but tiny difference 
-and my PC is an AMD 2400+ with plenty of memory so I would think speed 
is not the issue here; the encoding preferences are mono, 22050Hz and 
64kbit/s.

The source code (about 120 lines in all) is attached - any advice or 
improvement suggestions would be greatly appreciated.

Thanks,

  Petri
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: recorderGUI.py
URL: </pipermail/twisted-python/attachments/20041129/9900ba62/attachment.ksh>


More information about the Twisted-Python mailing list