[Asterisk-Users] Re: Asterisk2mp3

Stiffe stiffe at gmail.com
Sun Apr 24 07:09:43 MST 2005


Sorry, I forgot to show the script, here it is:

#!/usr/bin/python
import tempfile,os,sys,re,time

monitordir = sys.argv[1]
basename = sys.argv[2]

def runcmd(cmd):
    print cmd
    os.system(cmd)

#mix to one wav
inwav = os.path.join(monitordir, basename+"-in.wav")
outwav = os.path.join(monitordir, basename+"-out.wav")
waste, mixedwav = tempfile.mkstemp(".wav","audiopipe_","/tmp")
runcmd ("soxmix %s %s %s" % (inwav,outwav,mixedwav))

#up sample rate
waste, uppedsamplerate = tempfile.mkstemp(".wav","audiopipe_","/tmp")
runcmd("sox %s -r 22050 %s " % (mixedwav, uppedsamplerate))

#run lame
outfile =  os.path.join(monitordir, basename+".mp3")

#I use gogo instead of lame, cause gogo is a lot faster. But if you
#can't compile gogo, lame will do just fine.
#
runcmd("lame -S -v %s %s" % (uppedsamplerate, outfile))
#runcmd("/usr/local/bin/gogo -v 6  %s %s" % (uppedsamplerate, outfile))





os.remove(inwav)
os.remove(outwav)

#but at least we can waste the temporaries
os.remove(mixedwav)
os.remove(uppedsamplerate)


On 4/24/05, Stiffe <stiffe at gmail.com> wrote:
> Hi folks.
> 
> I have a problem with a pythonscript designed for joining one in-wav
> and one out-wav
> after recording a call.
> 
> Yes, I have the wav-files after a successfull recording...
> 
> Python stops at line 5:    basename = sys.argv[2]
> 
> like:
> 
> [root at asterisk1 bin]# python /usr/local/bin/asterisk2mp3.py
> Traceback (most recent call last):
>  File "/usr/local/bin/asterisk2mp3.py", line 5, in ?
>    basename = sys.argv[2]
> IndexError: list index out of range
> 
> What do I have to do?
> 
> And finally, can I have the script to mail the resulting mp3 to a mailadress
> and after that delete the mp3-file, for saving space?
> 
> Thanks in advance
> 
> //Stefan (from Sweden)
>



More information about the asterisk-users mailing list