Hi Guys,

Jason's proposal would work as well. Just for the completeness, I fixed the script sent by Rafael and attached it to this email (tstivr.py). The important difference is that the file has to be closed, or at least deallocated. This way, the WAV header can be written, and the file is complete.

The main difference between both strategies (Rafael's, and the one proposed by Jason) is that in one case (Rafael's) the wav file will stop recording when 5 seconds of audio are recorded in the file, whereby in Jason's case, the file will be closed anyway after 5 seconds, no matter what happens. In fact, the audio file does not record anything if the caller does not speak and its phone has voice activity detection. So, i think that Jason's would be by far better for your purposes, whereby somewhat more complex.

Cheers
Raphael.

Jason Penton wrote:
Hi Rafael
Im also still new to SEMS, but Id suggest looking at using one of the user timers and then disconnecting the audio from the session and closing the wav file in the onTimer function. Let me know if you come right! Cheers
Jason

On 6/27/08, [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    Hi All,
    i am new in ser and sems.
    i have running sersasi with sems 1.0.0
    i have a ivr python scrip that record my voice for e.g. 5 seconds
    and save it as a wave file on my harddisc.
    my problem is that the wave file is finaly saved only if i hang up
    (send bye) but the wave file should be saved directly after the 5
    seconds without hang up the phone.
    Can someone help me?
    here my script:

    from log import *
    from ivr import *
hallo = "/usr/audio/hallo_1oder2.wav"
    record = "/usr/audio/record.wav"
class IvrDialog(IvrDialogBase) : def onSessionStart(self,hdrs): self.audio_play = IvrAudioFile()
                            self.audio_play.open(hallo, AUDIO_READ)
                            self.enqueue(self.audio_play,None)
def onDtmf(self,event,duration): if event ==1:
                                       self.audio_rec = None
self.audio_rec = IvrAudioFile() self.audio_rec.open("/usr/audio/record.wav", AUDIO_WRITE,) self.audio_rec.setRecordTime(5*1000)
                                       self.enqueue(None,self.audio_rec)
if event ==2:
                                       self.audio_play = None
self.audio_play = IvrAudioFile()
                                       self.audio_play.open(record,
    AUDIO_READ)
                                       self.enqueue(self.audio_play,None)
                def onBye(self):
                            self.bye()
                            self.stopSession()

    regards
    rafael
    ------------------------------------------------------------------------
    *AOL eMail auf Ihrem Handy!*Ab sofort können Sie auch unterwegs
    Ihre AOL email abrufen. Registrieren <http://www.aol.de/Webmail/>
    Sie sich jetzt kostenlos.
    _______________________________________________
    Sems mailing list
    [email protected] <mailto:[email protected]>
    http://lists.iptel.org/mailman/listinfo/sems


------------------------------------------------------------------------

_______________________________________________
Sems mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/sems

from log import *
from ivr import *

hallo = "wav/default_en.wav"
record = "/tmp/record.wav"

class IvrDialog(IvrDialogBase) :
       
       def onSessionStart(self,hdrs):
              info("******** onSessionStart ********\n")
              
       def onDtmf(self,event,duration):

              if event ==1:
                     self.audio_rec = None
                     self.audio_rec = IvrAudioFile()
                            
                     self.audio_rec.open(record, AUDIO_WRITE,False)
                     self.audio_rec.setRecordTime(5*1000)
                     self.enqueue(None,self.audio_rec)
                            
              if event ==2:
                     self.stop_recording()
                     self.audio_play = None
                     self.audio_play = IvrAudioFile()
                     
                     self.audio_play.open(hallo, AUDIO_READ)
                     self.enqueue(self.audio_play,None)

       def onEmptyQueue(self):
              self.stop_recording()

       def onBye(self):
              self.stop_recording()
              self.bye()
              self.stopSession()

       def stop_recording(self):
              if self.audio_rec != None:
                     self.audio_rec.close()
                     self.audio_rec = None
_______________________________________________
Sems mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/sems

Reply via email to