some ivr example and test scripts

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@915 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 19 years ago
parent 86b5f50725
commit 0d286c8244

@ -0,0 +1,2 @@
Here there are some ivr script examples that illustrate
certain ivr functionality.

@ -0,0 +1,30 @@
# (outgoing) ivr b2bua example
#
#
from log import *
from ivr import *
class IvrDialog(IvrDialogBase):
def onSessionStart(self, hdrs):
info("starting b2bua app ...")
self.setNoRelayonly()
self.audio_msg = IvrAudioFile()
self.audio_msg.open("/home/stefan/sub_nautilus.wav", AUDIO_READ)
self.setTimer(1, 10)
self.enqueue(self.audio_msg,None)
def onEmptyQueue(self):
return
def onTimer(self, timerid):
self.disconnectMedia()
debug('hello kitty')
self.connectCallee(self.dialog.local_party,self.dialog.local_uri, \
self.dialog.remote_party,self.dialog.remote_uri,)
return
def onBye(self):
self.stopSession()

@ -0,0 +1,36 @@
#
# ivr b2bua script example
#
from log import *
from ivr import *
WELLCOME_MSG = "wav/default_en.wav"
CALLEE_URI = "sip:gong@iptel.org"
class IvrDialog(IvrDialogBase):
def onSessionStart(self, hdrs):
info("starting b2bua test ...")
self.setNoRelayonly()
self.welcome_msg = IvrAudioFile()
self.welcome_msg.open(WELLCOME_MSG, AUDIO_READ)
self.enqueue(self.welcome_msg,None)
def onEmptyQueue(self):
info("connecting to To: " + CALLEE_URI + " R-URI: " + CALLEE_URI)
info("\n\n\n original headers are: ---->%s<----\n\n\n" % self.invite_req.hdrs)
self.invite_req.hdrs += "P-SomeMoreFunky: headervalue\r\n"
self.disconnectMedia()
self.mute()
self.connectCallee(CALLEE_URI, CALLEE_URI)
return
def onBye(self):
self.stopSession()

@ -0,0 +1,13 @@
#
# just recording to file
#
from log import *
from ivr import *
class IvrDialog(IvrDialogBase) :
def onSessionStart( self, hdrs ) :
self.audio_msg = IvrAudioFile()
self.audio_msg.open("record.wav", AUDIO_WRITE)
self.enqueue(None,self.audio_msg)

@ -0,0 +1,15 @@
#
# testing mp3: play play.mp3, then record record.mp3
#
from log import *
from ivr import *
class IvrDialog(IvrDialogBase):
def onSessionStart(self, hdrs):
self.voice_msg = IvrAudioFile()
self.voice_msg.open("play.mp3", AUDIO_READ, False)
self.enqueue(self.voice_msg, None)
self.voice_msg.open("record.mp3", AUDIO_WRITE, False)
self.enqueue(None, self.voice_msg)

@ -0,0 +1,18 @@
#
# using IvrAudioFile fpopen
#
from log import *
from ivr import *
import os
class IvrDialog(IvrDialogBase):
def onSessionStart(self, hdrs):
f = open("wav/default_en.wav")
audio = f.read()
debug("Found audio file of length " + str(len(audio)))
fp = os.tmpfile()
fp.write(audio)
fp.seek(0)
wav = IvrAudioFile()
wav.fpopen("tmp.wav", AUDIO_READ, fp)
self.enqueue(wav, None)
Loading…
Cancel
Save