I am new to freeswitch. I am trying to send a message to voicemail using avmd for voicemail detection, here is the code which i am using with originate command: from freeswitch import * # WARNING: known bugs with hangup hooks, use with extreme caution def hangup_hook(session, what): consoleLog("info","hangup hook %s!!\n\n" % what) return def input_callback(session, what, obj): if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): consoleLog("info", "Voicemail Detected\n") return "true" def handler(session, args): session.answer() session.execute("avmd", "start") session.execute("sleep", "25000") callback = session.setInputCallback(input_callback) consoleLog("info","callback returned %s!!\n\n" % callback) while session.getVariable('avmd_detect'): session.execute("speak", "flite|kal|'Hi how are you'") session.execute("avmd", "stop") session.setHangupHook(hangup_hook) session.hangup() #hangup the call I can see avmd getting started but it does detect any beep. Is there a simpler way to check if avmd is working without using 'originate'? Thanks
Hi Raghu, I would put the setInputCallback before the sleep, that way if the avmd is detected while you're sleeping then it should work. -MC On Wed, Jul 24, 2013 at 1:30 PM, Raghu <srraghu45@gmail.com> wrote:
I am new to freeswitch. I am trying to send a message to voicemail using avmd for voicemail detection, here is the code which i am using with originate command:
from freeswitch import *
# WARNING: known bugs with hangup hooks, use with extreme caution def hangup_hook(session, what):
consoleLog("info","hangup hook %s!!\n\n" % what) return
def input_callback(session, what, obj):
if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): consoleLog("info", "Voicemail Detected\n") return "true"
def handler(session, args):
session.answer() session.execute("avmd", "start") session.execute("sleep", "25000") callback = session.setInputCallback(input_callback) consoleLog("info","callback returned %s!!\n\n" % callback) while session.getVariable('avmd_detect'): session.execute("speak", "flite|kal|'Hi how are you'")
session.execute("avmd", "stop") session.setHangupHook(hangup_hook) session.hangup() #hangup the call
I can see avmd getting started but it does detect any beep. Is there a simpler way to check if avmd is working without using 'originate'?
Thanks
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
Thanks MC, i made the change and avmd was able to detect beep on few occasions everything else remaining same. Also, i wasnt able to send the message to voicemail, i tried with invoking sleep of 3secs ---------------------------------------- from freeswitch import * # WARNING: known bugs with hangup hooks, use with extreme caution def hangup_hook(session, what): consoleLog("info","hangup hook for RAJ %s!!\n\n" % what) return def input_callback(session, what, obj): if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): consoleLog("info", "Voicemail Detected\n") return "TRUE" def handler(session, args): session.answer() callback = session.setInputCallback("input_callback") session.execute("avmd", "start") consoleLog("info", "AVMD start\n") session.execute("sleep", "16000") consoleLog("info", "AVMD status %s\n" % session.getVariable('avmd_detect')) if session.getVariable('avmd_detect'): session.execute("sleep", "3000") consoleLog("info", "Beep Detected\n") session.execute("speak", "flite|kal|'Hi this is '") session.execute("avmd", "stop") session.execute("speak", "flite|kal|'Hi this is '") consoleLog("info","callback returned for %s!!\n\n" % callback) session.execute("avmd", "stop") consoleLog("info", "AVMD stop\n") session.setHangupHook(hangup_hook) session.hangup() #hangup the call ----------------------------------------------------------------- Please suggest Thanks On Wed, Jul 24, 2013 at 4:08 PM, Michael Collins <msc@freeswitch.org> wrote:
Hi Raghu,
I would put the setInputCallback before the sleep, that way if the avmd is detected while you're sleeping then it should work.
-MC
On Wed, Jul 24, 2013 at 1:30 PM, Raghu <srraghu45@gmail.com> wrote:
I am new to freeswitch. I am trying to send a message to voicemail using avmd for voicemail detection, here is the code which i am using with originate command:
from freeswitch import *
# WARNING: known bugs with hangup hooks, use with extreme caution def hangup_hook(session, what):
consoleLog("info","hangup hook %s!!\n\n" % what) return
def input_callback(session, what, obj):
if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): consoleLog("info", "Voicemail Detected\n") return "true"
def handler(session, args):
session.answer() session.execute("avmd", "start") session.execute("sleep", "25000") callback = session.setInputCallback(input_callback) consoleLog("info","callback returned %s!!\n\n" % callback) while session.getVariable('avmd_detect'): session.execute("speak", "flite|kal|'Hi how are you'")
session.execute("avmd", "stop") session.setHangupHook(hangup_hook) session.hangup() #hangup the call
I can see avmd getting started but it does detect any beep. Is there a simpler way to check if avmd is working without using 'originate'?
Thanks
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Get a complete console debug log of the call and put onto pastebin so that the gang here can review what's happening. -MC On Wed, Jul 24, 2013 at 11:01 PM, Raghu <srraghu45@gmail.com> wrote:
Thanks MC, i made the change and avmd was able to detect beep on few occasions everything else remaining same. Also, i wasnt able to send the message to voicemail, i tried with invoking sleep of 3secs
---------------------------------------- from freeswitch import *
# WARNING: known bugs with hangup hooks, use with extreme caution def hangup_hook(session, what):
consoleLog("info","hangup hook for RAJ %s!!\n\n" % what) return
def input_callback(session, what, obj):
if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): consoleLog("info", "Voicemail Detected\n")
return "TRUE"
def handler(session, args):
session.answer() callback = session.setInputCallback("input_callback") session.execute("avmd", "start") consoleLog("info", "AVMD start\n") session.execute("sleep", "16000") consoleLog("info", "AVMD status %s\n" % session.getVariable('avmd_detect')) if session.getVariable('avmd_detect'): session.execute("sleep", "3000") consoleLog("info", "Beep Detected\n") session.execute("speak", "flite|kal|'Hi this is '") session.execute("avmd", "stop") session.execute("speak", "flite|kal|'Hi this is '") consoleLog("info","callback returned for %s!!\n\n" % callback) session.execute("avmd", "stop") consoleLog("info", "AVMD stop\n") session.setHangupHook(hangup_hook)
session.hangup() #hangup the call -----------------------------------------------------------------
Please suggest
Thanks
On Wed, Jul 24, 2013 at 4:08 PM, Michael Collins <msc@freeswitch.org>wrote:
Hi Raghu,
I would put the setInputCallback before the sleep, that way if the avmd is detected while you're sleeping then it should work.
-MC
On Wed, Jul 24, 2013 at 1:30 PM, Raghu <srraghu45@gmail.com> wrote:
I am new to freeswitch. I am trying to send a message to voicemail using avmd for voicemail detection, here is the code which i am using with originate command:
from freeswitch import *
# WARNING: known bugs with hangup hooks, use with extreme caution def hangup_hook(session, what):
consoleLog("info","hangup hook %s!!\n\n" % what) return
def input_callback(session, what, obj):
if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): consoleLog("info", "Voicemail Detected\n") return "true"
def handler(session, args):
session.answer() session.execute("avmd", "start") session.execute("sleep", "25000") callback = session.setInputCallback(input_callback) consoleLog("info","callback returned %s!!\n\n" % callback) while session.getVariable('avmd_detect'): session.execute("speak", "flite|kal|'Hi how are you'")
session.execute("avmd", "stop") session.setHangupHook(hangup_hook) session.hangup() #hangup the call
I can see avmd getting started but it does detect any beep. Is there a simpler way to check if avmd is working without using 'originate'?
Thanks
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
I have pasted the console debug logs here <http://pastebin.com/anN768su> , please review it Thanks On Thu, Jul 25, 2013 at 9:06 AM, Michael Collins <msc@freeswitch.org> wrote:
Get a complete console debug log of the call and put onto pastebin so that the gang here can review what's happening. -MC
On Wed, Jul 24, 2013 at 11:01 PM, Raghu <srraghu45@gmail.com> wrote:
Thanks MC, i made the change and avmd was able to detect beep on few occasions everything else remaining same. Also, i wasnt able to send the message to voicemail, i tried with invoking sleep of 3secs
---------------------------------------- from freeswitch import *
# WARNING: known bugs with hangup hooks, use with extreme caution def hangup_hook(session, what):
consoleLog("info","hangup hook for RAJ %s!!\n\n" % what) return
def input_callback(session, what, obj):
if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): consoleLog("info", "Voicemail Detected\n")
return "TRUE"
def handler(session, args):
session.answer() callback = session.setInputCallback("input_callback") session.execute("avmd", "start") consoleLog("info", "AVMD start\n") session.execute("sleep", "16000") consoleLog("info", "AVMD status %s\n" % session.getVariable('avmd_detect')) if session.getVariable('avmd_detect'): session.execute("sleep", "3000") consoleLog("info", "Beep Detected\n") session.execute("speak", "flite|kal|'Hi this is '") session.execute("avmd", "stop") session.execute("speak", "flite|kal|'Hi this is '") consoleLog("info","callback returned for %s!!\n\n" % callback) session.execute("avmd", "stop") consoleLog("info", "AVMD stop\n") session.setHangupHook(hangup_hook)
session.hangup() #hangup the call -----------------------------------------------------------------
Please suggest
Thanks
On Wed, Jul 24, 2013 at 4:08 PM, Michael Collins <msc@freeswitch.org>wrote:
Hi Raghu,
I would put the setInputCallback before the sleep, that way if the avmd is detected while you're sleeping then it should work.
-MC
On Wed, Jul 24, 2013 at 1:30 PM, Raghu <srraghu45@gmail.com> wrote:
I am new to freeswitch. I am trying to send a message to voicemail using avmd for voicemail detection, here is the code which i am using with originate command:
from freeswitch import *
# WARNING: known bugs with hangup hooks, use with extreme caution def hangup_hook(session, what):
consoleLog("info","hangup hook %s!!\n\n" % what) return
def input_callback(session, what, obj):
if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): consoleLog("info", "Voicemail Detected\n") return "true"
def handler(session, args):
session.answer() session.execute("avmd", "start") session.execute("sleep", "25000") callback = session.setInputCallback(input_callback) consoleLog("info","callback returned %s!!\n\n" % callback) while session.getVariable('avmd_detect'): session.execute("speak", "flite|kal|'Hi how are you'")
session.execute("avmd", "stop") session.setHangupHook(hangup_hook) session.hangup() #hangup the call
I can see avmd getting started but it does detect any beep. Is there a simpler way to check if avmd is working without using 'originate'?
Thanks
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE: http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
I copied the logs to http://pastebin.freeswitch.org/21239 so that I could see them more easily. It looks to me like you're just hanging up the call after you detect the beep. If you want to do something else I would just add whatever dialplan apps you want to run. -MC On Thu, Jul 25, 2013 at 10:56 AM, Raghu <srraghu45@gmail.com> wrote:
I have pasted the console debug logs here <http://pastebin.com/anN768su> , please review it
Thanks
On Thu, Jul 25, 2013 at 9:06 AM, Michael Collins <msc@freeswitch.org>wrote:
Get a complete console debug log of the call and put onto pastebin so that the gang here can review what's happening. -MC
On Wed, Jul 24, 2013 at 11:01 PM, Raghu <srraghu45@gmail.com> wrote:
Thanks MC, i made the change and avmd was able to detect beep on few occasions everything else remaining same. Also, i wasnt able to send the message to voicemail, i tried with invoking sleep of 3secs
---------------------------------------- from freeswitch import *
# WARNING: known bugs with hangup hooks, use with extreme caution def hangup_hook(session, what):
consoleLog("info","hangup hook for RAJ %s!!\n\n" % what) return
def input_callback(session, what, obj):
if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): consoleLog("info", "Voicemail Detected\n")
return "TRUE"
def handler(session, args):
session.answer() callback = session.setInputCallback("input_callback") session.execute("avmd", "start") consoleLog("info", "AVMD start\n") session.execute("sleep", "16000") consoleLog("info", "AVMD status %s\n" % session.getVariable('avmd_detect')) if session.getVariable('avmd_detect'): session.execute("sleep", "3000") consoleLog("info", "Beep Detected\n") session.execute("speak", "flite|kal|'Hi this is '") session.execute("avmd", "stop") session.execute("speak", "flite|kal|'Hi this is '") consoleLog("info","callback returned for %s!!\n\n" % callback) session.execute("avmd", "stop") consoleLog("info", "AVMD stop\n") session.setHangupHook(hangup_hook)
session.hangup() #hangup the call -----------------------------------------------------------------
Please suggest
Thanks
On Wed, Jul 24, 2013 at 4:08 PM, Michael Collins <msc@freeswitch.org>wrote:
Hi Raghu,
I would put the setInputCallback before the sleep, that way if the avmd is detected while you're sleeping then it should work.
-MC
On Wed, Jul 24, 2013 at 1:30 PM, Raghu <srraghu45@gmail.com> wrote:
I am new to freeswitch. I am trying to send a message to voicemail using avmd for voicemail detection, here is the code which i am using with originate command:
from freeswitch import *
# WARNING: known bugs with hangup hooks, use with extreme caution def hangup_hook(session, what):
consoleLog("info","hangup hook %s!!\n\n" % what) return
def input_callback(session, what, obj):
if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): consoleLog("info", "Voicemail Detected\n") return "true"
def handler(session, args):
session.answer() session.execute("avmd", "start") session.execute("sleep", "25000") callback = session.setInputCallback(input_callback) consoleLog("info","callback returned %s!!\n\n" % callback) while session.getVariable('avmd_detect'): session.execute("speak", "flite|kal|'Hi how are you'")
session.execute("avmd", "stop") session.setHangupHook(hangup_hook) session.hangup() #hangup the call
I can see avmd getting started but it does detect any beep. Is there a simpler way to check if avmd is working without using 'originate'?
Thanks
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE: http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE: http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
Thanks for checking it Michael. I thought i was trying execute 'speak' when AVMD detects a beep as below, but may be i am missing something. Please review the code and let me know if i am missing anything: from freeswitch import * # WARNING: known bugs with hangup hooks, use with extreme caution def hangup_hook(session, what): %s!!\n\n" % what) return def input_callback(session, what, obj): if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): consoleLog("info", "Voicemail Detected\n") return "TRUE" def handler(session, args): session.answer() # session.setVariable("hangup_after_bridge", "false") callback = session.setInputCallback("input_callback") session.execute("avmd", "start") consoleLog("info", "AVMD start\n") session.execute("sleep", "18000") consoleLog("info", "AVMD status %s\n" % session.getVariable('avmd_detect')) if session.getVariable('avmd_detect'): consoleLog("info", "Beep Detected\n") session.execute("speak", "flite|kal|'Hi this is '") session.execute("avmd", "stop") session.execute("speak", "flite|kal|'Hi this is '") consoleLog("info","callback returned %s!!\n\n" % callback) session.execute("avmd", "stop") consoleLog("info", "AVMD stop\n") session.setHangupHook(hangup_hook) session.hangup() #hangup the call Appreciate it!
I would do your "voicemail" stuff in the callback where you detect that the avmd detected true. I would also put the avmd_stop app in that code block. -MC On Thu, Jul 25, 2013 at 7:33 PM, Raghu <srraghu45@gmail.com> wrote:
Thanks for checking it Michael. I thought i was trying execute 'speak' when AVMD detects a beep as below, but may be i am missing something. Please review the code and let me know if i am missing anything:
from freeswitch import *
# WARNING: known bugs with hangup hooks, use with extreme caution def hangup_hook(session, what): %s!!\n\n" % what) return
def input_callback(session, what, obj):
if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): consoleLog("info", "Voicemail Detected\n")
return "TRUE"
def handler(session, args):
session.answer() # session.setVariable("hangup_after_bridge", "false") callback = session.setInputCallback("input_callback") session.execute("avmd", "start") consoleLog("info", "AVMD start\n") session.execute("sleep", "18000") consoleLog("info", "AVMD status %s\n" % session.getVariable('avmd_detect'))
if session.getVariable('avmd_detect'): consoleLog("info", "Beep Detected\n") session.execute("speak", "flite|kal|'Hi this is '") session.execute("avmd", "stop")
session.execute("speak", "flite|kal|'Hi this is '") consoleLog("info","callback returned %s!!\n\n" % callback) session.execute("avmd", "stop") consoleLog("info", "AVMD stop\n") session.setHangupHook(hangup_hook) session.hangup() #hangup the call
Appreciate it!
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
Can you please tell how callback works, my understanding is that it handles user input, not sure how it works when we are trying to catch voicemails? Thanks On Fri, Jul 26, 2013 at 1:25 PM, Michael Collins <msc@freeswitch.org> wrote:
I would do your "voicemail" stuff in the callback where you detect that the avmd detected true. I would also put the avmd_stop app in that code block. -MC
On Thu, Jul 25, 2013 at 7:33 PM, Raghu <srraghu45@gmail.com> wrote:
Thanks for checking it Michael. I thought i was trying execute 'speak' when AVMD detects a beep as below, but may be i am missing something. Please review the code and let me know if i am missing anything:
from freeswitch import *
# WARNING: known bugs with hangup hooks, use with extreme caution def hangup_hook(session, what): %s!!\n\n" % what) return
def input_callback(session, what, obj):
if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): consoleLog("info", "Voicemail Detected\n")
return "TRUE"
def handler(session, args):
session.answer() # session.setVariable("hangup_after_bridge", "false") callback = session.setInputCallback("input_callback") session.execute("avmd", "start") consoleLog("info", "AVMD start\n") session.execute("sleep", "18000") consoleLog("info", "AVMD status %s\n" % session.getVariable('avmd_detect'))
if session.getVariable('avmd_detect'): consoleLog("info", "Beep Detected\n") session.execute("speak", "flite|kal|'Hi this is '") session.execute("avmd", "stop")
session.execute("speak", "flite|kal|'Hi this is '") consoleLog("info","callback returned %s!!\n\n" % callback) session.execute("avmd", "stop") consoleLog("info", "AVMD stop\n") session.setHangupHook(hangup_hook) session.hangup() #hangup the call
Appreciate it!
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
I don't know Python but if it works like other languages then when an event comes in the input callback is called: def input_callback(session, what, obj): if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): consoleLog("info", "Voicemail Detected\n") The "what" tells you the type of input. In this case you test for what=="dtmf" (for when the user presses a dtmf key) and for what=="event" for when an event comes in. In your specific case you check for an event and to see if the variable avmd_detect is true. If so then you are assuming that this is the mod_avmd event that it's detected a beep. (This is not the optimal method because you can actually check the event headers to make sure it's the correct event. I'll leave that as a research project for you.) Again, I'm not a Python guy so if someone else could verify my logic/syntax that would be good. Under the elif you have a consoleLog function call. After that line you could put all your code for handling the voicemail. Keep in mind that avmd is non-block, i.e. you aren't forced to sleep while detecting the beep. You could be playing a message or whatnot. As soon as the avmd detects a beep it will send the event and the inputcallback will be called and in your case the elif block will get executed. In that block of code you could stop the playback of your sound file and then initiate a new playback. (I'm assuming that you want to play a message after the beep?) Something like this: def input_callback(session, what, obj): if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): session.execute("avmd", "stop") consoleLog("info", "Voicemail Detected\n") session.execute("speak", "flite|kal|'Hi this is '") return "TRUE" def handler(session, args): session.answer() # session.setVariable("hangup_after_bridge", "false") callback = session.setInputCallback("input_callback") session.execute("avmd", "start") consoleLog("info", "AVMD start\n") session.execute("sleep", "18000") # this could be a playback consoleLog("info", "AVMD status %s\n" % session.getVariable('avmd_ detect')) session.execute("avmd", "stop") consoleLog("info", "AVMD stop\n") session.setHangupHook(hangup_hook) session.hangup() #hangup the call I don't think it's any more complicated than that. I highly recommend that you read up in the wiki and in the new FreeSWITCH book about events. Also, the FreeSWITCH Cookbook has good information about events. (Full disclosure: I'm co-author of both of those books). Also, don't be afraid of checking out all the Lua examples. Lua is easy to read if you're familiar with any scripting language and you can borrow ideas from existing scripts. Start by trying to understand setInputCallback<https://wiki.freeswitch.org/index.php?title=Special%3ASearch&search=setInputCallback>and go from there. Hope this helps, MC On Fri, Jul 26, 2013 at 2:46 PM, raj singh <rajictdialer@gmail.com> wrote:
Can you please tell how callback works, my understanding is that it handles user input, not sure how it works when we are trying to catch voicemails?
Thanks
On Fri, Jul 26, 2013 at 1:25 PM, Michael Collins <msc@freeswitch.org>wrote:
I would do your "voicemail" stuff in the callback where you detect that the avmd detected true. I would also put the avmd_stop app in that code block. -MC
On Thu, Jul 25, 2013 at 7:33 PM, Raghu <srraghu45@gmail.com> wrote:
Thanks for checking it Michael. I thought i was trying execute 'speak' when AVMD detects a beep as below, but may be i am missing something. Please review the code and let me know if i am missing anything:
from freeswitch import *
# WARNING: known bugs with hangup hooks, use with extreme caution def hangup_hook(session, what): %s!!\n\n" % what) return
def input_callback(session, what, obj):
if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): consoleLog("info", "Voicemail Detected\n")
return "TRUE"
def handler(session, args):
session.answer() # session.setVariable("hangup_after_bridge", "false") callback = session.setInputCallback("input_callback") session.execute("avmd", "start") consoleLog("info", "AVMD start\n") session.execute("sleep", "18000") consoleLog("info", "AVMD status %s\n" % session.getVariable('avmd_detect'))
if session.getVariable('avmd_detect'): consoleLog("info", "Beep Detected\n") session.execute("speak", "flite|kal|'Hi this is '") session.execute("avmd", "stop")
session.execute("speak", "flite|kal|'Hi this is '") consoleLog("info","callback returned %s!!\n\n" % callback) session.execute("avmd", "stop") consoleLog("info", "AVMD stop\n") session.setHangupHook(hangup_hook) session.hangup() #hangup the call
Appreciate it!
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
I went through all the Lua and Javascripts i could find on the net regarding AVMD, i tried different combinations including the one you suggested but no luck, it seems simple thats the frustrating part :( , i appreciate your response and i am trying hard to get it to work and i will keep doing the research, below is the log after the changes you suggested: 2013-07-26 18:17:05.888113 [DEBUG] mod_avmd.c:536 <<< AVMD v=0.001063 f=0.728471 927.518323Hz sma=0.701958 sqa=0.493808 >>> 2013-07-26 18:17:05.888113 [DEBUG] mod_avmd.c:536 <<< AVMD v=0.000980 f=0.691887 880.938146Hz sma=0.698135 sqa=0.488372 >>> 2013-07-26 18:17:05.888113 [DEBUG] mod_avmd.c:559 <<< AVMD - Beep Detected
2013-07-26 18:17:17.708529 [INFO] switch_cpp.cpp:1288 AVMD status TRUE EXECUTE dingaling/gtalk/+xxxxxxxxxx@voice.google.com avmd(stop) 2013-07-26 18:17:17.708529 [DEBUG] switch_core_media_bug.c:808 Removing BUG from dingaling/gtalk/+xxxxxxxxxx@voice.google.com 2013-07-26 18:17:17.708529 [INFO] switch_cpp.cpp:1288 AVMD stop 2013-07-26 18:17:17.708529 [DEBUG] switch_cpp.cpp:670 CoreSession::hangup 2013-07-26 18:17:17.708529 [NOTICE] switch_cpp.cpp:672 Hangup dingaling/gtalk/+xxxxxxxxxx@voice.google.com [CS_EXECUTE] [NORMAL_CLEARING] 2013-07-26 18:17:17.708529 [DEBUG] switch_channel.c:3135 Send signal dingaling/gtalk/+xxxxxxxxxx@voice.google.com [KILL] 2013-07-26 18:17:17.708529 [DEBUG] mod_dingaling.c:2095 dingaling/gtalk/+ xxxxxxxxxx@voice.google.com CHANNEL KILL 2013-07-26 18:17:17.708529 [DEBUG] switch_core_session.c:1341 Send signal dingaling/gtalk/+xxxxxxxxxx@voice.google.com [BREAK] 2013-07-26 18:17:17.708529 [DEBUG] mod_dingaling.c:2095 dingaling/gtalk/+ xxxxxxxxxx@voice.google.com CHANNEL KILL 2013-07-26 18:17:17.708529 [INFO] switch_cpp.cpp:1288 hangup hook for RAJ hangup!!
2013-07-26 18:17:17.708529 [DEBUG] mod_python.c:284 Finished calling python script 2013-07-26 18:17:17.708529 [DEBUG] switch_cpp.cpp:1051 dingaling/gtalk/+ xxxxxxxxxx@voice.google.com destroy/unlink session from object Any suggestions? Thanks On Fri, Jul 26, 2013 at 5:34 PM, Michael Collins <msc@freeswitch.org> wrote:
I don't know Python but if it works like other languages then when an event comes in the input callback is called:
def input_callback(session, what, obj):
if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): consoleLog("info", "Voicemail Detected\n")
The "what" tells you the type of input. In this case you test for what=="dtmf" (for when the user presses a dtmf key) and for what=="event" for when an event comes in. In your specific case you check for an event and to see if the variable avmd_detect is true. If so then you are assuming that this is the mod_avmd event that it's detected a beep. (This is not the optimal method because you can actually check the event headers to make sure it's the correct event. I'll leave that as a research project for you.)
Again, I'm not a Python guy so if someone else could verify my logic/syntax that would be good. Under the elif you have a consoleLog function call. After that line you could put all your code for handling the voicemail. Keep in mind that avmd is non-block, i.e. you aren't forced to sleep while detecting the beep. You could be playing a message or whatnot. As soon as the avmd detects a beep it will send the event and the inputcallback will be called and in your case the elif block will get executed. In that block of code you could stop the playback of your sound file and then initiate a new playback. (I'm assuming that you want to play a message after the beep?) Something like this:
def input_callback(session, what, obj):
if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): session.execute("avmd", "stop") consoleLog("info", "Voicemail Detected\n") session.execute("speak", "flite|kal|'Hi this is '")
return "TRUE"
def handler(session, args):
session.answer() # session.setVariable("hangup_after_bridge", "false") callback = session.setInputCallback("input_callback") session.execute("avmd", "start") consoleLog("info", "AVMD start\n") session.execute("sleep", "18000") # this could be a playback consoleLog("info", "AVMD status %s\n" % session.getVariable('avmd_ detect')) session.execute("avmd", "stop") consoleLog("info", "AVMD stop\n") session.setHangupHook(hangup_hook) session.hangup() #hangup the call
I don't think it's any more complicated than that.
I highly recommend that you read up in the wiki and in the new FreeSWITCH book about events. Also, the FreeSWITCH Cookbook has good information about events. (Full disclosure: I'm co-author of both of those books). Also, don't be afraid of checking out all the Lua examples. Lua is easy to read if you're familiar with any scripting language and you can borrow ideas from existing scripts.
Start by trying to understand setInputCallback<https://wiki.freeswitch.org/index.php?title=Special%3ASearch&search=setInputCallback>and go from there.
Hope this helps, MC
On Fri, Jul 26, 2013 at 2:46 PM, raj singh <rajictdialer@gmail.com> wrote:
Can you please tell how callback works, my understanding is that it handles user input, not sure how it works when we are trying to catch voicemails?
Thanks
On Fri, Jul 26, 2013 at 1:25 PM, Michael Collins <msc@freeswitch.org>wrote:
I would do your "voicemail" stuff in the callback where you detect that the avmd detected true. I would also put the avmd_stop app in that code block. -MC
On Thu, Jul 25, 2013 at 7:33 PM, Raghu <srraghu45@gmail.com> wrote:
Thanks for checking it Michael. I thought i was trying execute 'speak' when AVMD detects a beep as below, but may be i am missing something. Please review the code and let me know if i am missing anything:
from freeswitch import *
# WARNING: known bugs with hangup hooks, use with extreme caution def hangup_hook(session, what): %s!!\n\n" % what) return
def input_callback(session, what, obj):
if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): consoleLog("info", "Voicemail Detected\n")
return "TRUE"
def handler(session, args):
session.answer() # session.setVariable("hangup_after_bridge", "false") callback = session.setInputCallback("input_callback") session.execute("avmd", "start") consoleLog("info", "AVMD start\n") session.execute("sleep", "18000") consoleLog("info", "AVMD status %s\n" % session.getVariable('avmd_detect'))
if session.getVariable('avmd_detect'): consoleLog("info", "Beep Detected\n") session.execute("speak", "flite|kal|'Hi this is '") session.execute("avmd", "stop")
session.execute("speak", "flite|kal|'Hi this is '") consoleLog("info","callback returned %s!!\n\n" % callback) session.execute("avmd", "stop") consoleLog("info", "AVMD stop\n") session.setHangupHook(hangup_hook) session.hangup() #hangup the call
Appreciate it!
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Forgot to mention, i bought the cookbook, good stuff, i hope there could some python examples in the next version. Thanks On Fri, Jul 26, 2013 at 6:28 PM, raj singh <rajictdialer@gmail.com> wrote:
I went through all the Lua and Javascripts i could find on the net regarding AVMD, i tried different combinations including the one you suggested but no luck, it seems simple thats the frustrating part :( , i appreciate your response and i am trying hard to get it to work and i will keep doing the research, below is the log after the changes you suggested:
2013-07-26 18:17:05.888113 [DEBUG] mod_avmd.c:536 <<< AVMD v=0.001063 f=0.728471 927.518323Hz sma=0.701958 sqa=0.493808 >>> 2013-07-26 18:17:05.888113 [DEBUG] mod_avmd.c:536 <<< AVMD v=0.000980 f=0.691887 880.938146Hz sma=0.698135 sqa=0.488372 >>> 2013-07-26 18:17:05.888113 [DEBUG] mod_avmd.c:559 <<< AVMD - Beep Detected
2013-07-26 18:17:17.708529 [INFO] switch_cpp.cpp:1288 AVMD status TRUE EXECUTE dingaling/gtalk/+xxxxxxxxxx@voice.google.com avmd(stop) 2013-07-26 18:17:17.708529 [DEBUG] switch_core_media_bug.c:808 Removing BUG from dingaling/gtalk/+xxxxxxxxxx@voice.google.com 2013-07-26 18:17:17.708529 [INFO] switch_cpp.cpp:1288 AVMD stop 2013-07-26 18:17:17.708529 [DEBUG] switch_cpp.cpp:670 CoreSession::hangup 2013-07-26 18:17:17.708529 [NOTICE] switch_cpp.cpp:672 Hangup dingaling/gtalk/+xxxxxxxxxx@voice.google.com [CS_EXECUTE] [NORMAL_CLEARING] 2013-07-26 18:17:17.708529 [DEBUG] switch_channel.c:3135 Send signal dingaling/gtalk/+xxxxxxxxxx@voice.google.com [KILL] 2013-07-26 18:17:17.708529 [DEBUG] mod_dingaling.c:2095 dingaling/gtalk/+ xxxxxxxxxx@voice.google.com CHANNEL KILL 2013-07-26 18:17:17.708529 [DEBUG] switch_core_session.c:1341 Send signal dingaling/gtalk/+xxxxxxxxxx@voice.google.com [BREAK] 2013-07-26 18:17:17.708529 [DEBUG] mod_dingaling.c:2095 dingaling/gtalk/+ xxxxxxxxxx@voice.google.com CHANNEL KILL 2013-07-26 18:17:17.708529 [INFO] switch_cpp.cpp:1288 hangup hook for RAJ hangup!!
2013-07-26 18:17:17.708529 [DEBUG] mod_python.c:284 Finished calling python script 2013-07-26 18:17:17.708529 [DEBUG] switch_cpp.cpp:1051 dingaling/gtalk/+ xxxxxxxxxx@voice.google.com destroy/unlink session from object
Any suggestions?
Thanks
On Fri, Jul 26, 2013 at 5:34 PM, Michael Collins <msc@freeswitch.org>wrote:
I don't know Python but if it works like other languages then when an event comes in the input callback is called:
def input_callback(session, what, obj):
if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): consoleLog("info", "Voicemail Detected\n")
The "what" tells you the type of input. In this case you test for what=="dtmf" (for when the user presses a dtmf key) and for what=="event" for when an event comes in. In your specific case you check for an event and to see if the variable avmd_detect is true. If so then you are assuming that this is the mod_avmd event that it's detected a beep. (This is not the optimal method because you can actually check the event headers to make sure it's the correct event. I'll leave that as a research project for you.)
Again, I'm not a Python guy so if someone else could verify my logic/syntax that would be good. Under the elif you have a consoleLog function call. After that line you could put all your code for handling the voicemail. Keep in mind that avmd is non-block, i.e. you aren't forced to sleep while detecting the beep. You could be playing a message or whatnot. As soon as the avmd detects a beep it will send the event and the inputcallback will be called and in your case the elif block will get executed. In that block of code you could stop the playback of your sound file and then initiate a new playback. (I'm assuming that you want to play a message after the beep?) Something like this:
def input_callback(session, what, obj):
if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): session.execute("avmd", "stop") consoleLog("info", "Voicemail Detected\n") session.execute("speak", "flite|kal|'Hi this is '")
return "TRUE"
def handler(session, args):
session.answer() # session.setVariable("hangup_after_bridge", "false") callback = session.setInputCallback("input_callback") session.execute("avmd", "start") consoleLog("info", "AVMD start\n") session.execute("sleep", "18000") # this could be a playback consoleLog("info", "AVMD status %s\n" % session.getVariable('avmd_ detect')) session.execute("avmd", "stop") consoleLog("info", "AVMD stop\n") session.setHangupHook(hangup_hook) session.hangup() #hangup the call
I don't think it's any more complicated than that.
I highly recommend that you read up in the wiki and in the new FreeSWITCH book about events. Also, the FreeSWITCH Cookbook has good information about events. (Full disclosure: I'm co-author of both of those books). Also, don't be afraid of checking out all the Lua examples. Lua is easy to read if you're familiar with any scripting language and you can borrow ideas from existing scripts.
Start by trying to understand setInputCallback<https://wiki.freeswitch.org/index.php?title=Special%3ASearch&search=setInputCallback>and go from there.
Hope this helps, MC
On Fri, Jul 26, 2013 at 2:46 PM, raj singh <rajictdialer@gmail.com>wrote:
Can you please tell how callback works, my understanding is that it handles user input, not sure how it works when we are trying to catch voicemails?
Thanks
On Fri, Jul 26, 2013 at 1:25 PM, Michael Collins <msc@freeswitch.org>wrote:
I would do your "voicemail" stuff in the callback where you detect that the avmd detected true. I would also put the avmd_stop app in that code block. -MC
On Thu, Jul 25, 2013 at 7:33 PM, Raghu <srraghu45@gmail.com> wrote:
Thanks for checking it Michael. I thought i was trying execute 'speak' when AVMD detects a beep as below, but may be i am missing something. Please review the code and let me know if i am missing anything:
from freeswitch import *
# WARNING: known bugs with hangup hooks, use with extreme caution def hangup_hook(session, what): %s!!\n\n" % what) return
def input_callback(session, what, obj):
if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): consoleLog("info", "Voicemail Detected\n")
return "TRUE"
def handler(session, args):
session.answer() # session.setVariable("hangup_after_bridge", "false") callback = session.setInputCallback("input_callback") session.execute("avmd", "start") consoleLog("info", "AVMD start\n") session.execute("sleep", "18000") consoleLog("info", "AVMD status %s\n" % session.getVariable('avmd_detect'))
if session.getVariable('avmd_detect'): consoleLog("info", "Beep Detected\n") session.execute("speak", "flite|kal|'Hi this is '") session.execute("avmd", "stop")
session.execute("speak", "flite|kal|'Hi this is '") consoleLog("info","callback returned %s!!\n\n" % callback) session.execute("avmd", "stop") consoleLog("info", "AVMD stop\n") session.setHangupHook(hangup_hook) session.hangup() #hangup the call
Appreciate it!
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Tried with the following with no luck, seems like the callback never gets called elif (what == "event" and obj.getHeader("Event-Name") == "CUSTOM"): session.execute("avmd", "stop") consoleLog("info", "Voicemail Detected\n") session.execute("speak", "flite|kal|'Hi this is '") On Fri, Jul 26, 2013 at 6:32 PM, raj singh <rajictdialer@gmail.com> wrote:
Forgot to mention, i bought the cookbook, good stuff, i hope there could some python examples in the next version. Thanks
On Fri, Jul 26, 2013 at 6:28 PM, raj singh <rajictdialer@gmail.com> wrote:
I went through all the Lua and Javascripts i could find on the net regarding AVMD, i tried different combinations including the one you suggested but no luck, it seems simple thats the frustrating part :( , i appreciate your response and i am trying hard to get it to work and i will keep doing the research, below is the log after the changes you suggested:
2013-07-26 18:17:05.888113 [DEBUG] mod_avmd.c:536 <<< AVMD v=0.001063 f=0.728471 927.518323Hz sma=0.701958 sqa=0.493808 >>> 2013-07-26 18:17:05.888113 [DEBUG] mod_avmd.c:536 <<< AVMD v=0.000980 f=0.691887 880.938146Hz sma=0.698135 sqa=0.488372 >>> 2013-07-26 18:17:05.888113 [DEBUG] mod_avmd.c:559 <<< AVMD - Beep Detected >>> 2013-07-26 18:17:17.708529 [INFO] switch_cpp.cpp:1288 AVMD status TRUE EXECUTE dingaling/gtalk/+xxxxxxxxxx@voice.google.com avmd(stop) 2013-07-26 18:17:17.708529 [DEBUG] switch_core_media_bug.c:808 Removing BUG from dingaling/gtalk/+xxxxxxxxxx@voice.google.com 2013-07-26 18:17:17.708529 [INFO] switch_cpp.cpp:1288 AVMD stop 2013-07-26 18:17:17.708529 [DEBUG] switch_cpp.cpp:670 CoreSession::hangup 2013-07-26 18:17:17.708529 [NOTICE] switch_cpp.cpp:672 Hangup dingaling/gtalk/+xxxxxxxxxx@voice.google.com [CS_EXECUTE] [NORMAL_CLEARING] 2013-07-26 18:17:17.708529 [DEBUG] switch_channel.c:3135 Send signal dingaling/gtalk/+xxxxxxxxxx@voice.google.com [KILL] 2013-07-26 18:17:17.708529 [DEBUG] mod_dingaling.c:2095 dingaling/gtalk/+ xxxxxxxxxx@voice.google.com CHANNEL KILL 2013-07-26 18:17:17.708529 [DEBUG] switch_core_session.c:1341 Send signal dingaling/gtalk/+xxxxxxxxxx@voice.google.com [BREAK] 2013-07-26 18:17:17.708529 [DEBUG] mod_dingaling.c:2095 dingaling/gtalk/+ xxxxxxxxxx@voice.google.com CHANNEL KILL 2013-07-26 18:17:17.708529 [INFO] switch_cpp.cpp:1288 hangup hook for RAJ hangup!!
2013-07-26 18:17:17.708529 [DEBUG] mod_python.c:284 Finished calling python script 2013-07-26 18:17:17.708529 [DEBUG] switch_cpp.cpp:1051 dingaling/gtalk/+ xxxxxxxxxx@voice.google.com destroy/unlink session from object
Any suggestions?
Thanks
On Fri, Jul 26, 2013 at 5:34 PM, Michael Collins <msc@freeswitch.org>wrote:
I don't know Python but if it works like other languages then when an event comes in the input callback is called:
def input_callback(session, what, obj):
if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): consoleLog("info", "Voicemail Detected\n")
The "what" tells you the type of input. In this case you test for what=="dtmf" (for when the user presses a dtmf key) and for what=="event" for when an event comes in. In your specific case you check for an event and to see if the variable avmd_detect is true. If so then you are assuming that this is the mod_avmd event that it's detected a beep. (This is not the optimal method because you can actually check the event headers to make sure it's the correct event. I'll leave that as a research project for you.)
Again, I'm not a Python guy so if someone else could verify my logic/syntax that would be good. Under the elif you have a consoleLog function call. After that line you could put all your code for handling the voicemail. Keep in mind that avmd is non-block, i.e. you aren't forced to sleep while detecting the beep. You could be playing a message or whatnot. As soon as the avmd detects a beep it will send the event and the inputcallback will be called and in your case the elif block will get executed. In that block of code you could stop the playback of your sound file and then initiate a new playback. (I'm assuming that you want to play a message after the beep?) Something like this:
def input_callback(session, what, obj):
if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): session.execute("avmd", "stop") consoleLog("info", "Voicemail Detected\n") session.execute("speak", "flite|kal|'Hi this is '")
return "TRUE"
def handler(session, args):
session.answer() # session.setVariable("hangup_after_bridge", "false") callback = session.setInputCallback("input_callback") session.execute("avmd", "start") consoleLog("info", "AVMD start\n") session.execute("sleep", "18000") # this could be a playback consoleLog("info", "AVMD status %s\n" % session.getVariable('avmd_ detect')) session.execute("avmd", "stop") consoleLog("info", "AVMD stop\n") session.setHangupHook(hangup_hook) session.hangup() #hangup the call
I don't think it's any more complicated than that.
I highly recommend that you read up in the wiki and in the new FreeSWITCH book about events. Also, the FreeSWITCH Cookbook has good information about events. (Full disclosure: I'm co-author of both of those books). Also, don't be afraid of checking out all the Lua examples. Lua is easy to read if you're familiar with any scripting language and you can borrow ideas from existing scripts.
Start by trying to understand setInputCallback<https://wiki.freeswitch.org/index.php?title=Special%3ASearch&search=setInputCallback>and go from there.
Hope this helps, MC
On Fri, Jul 26, 2013 at 2:46 PM, raj singh <rajictdialer@gmail.com>wrote:
Can you please tell how callback works, my understanding is that it handles user input, not sure how it works when we are trying to catch voicemails?
Thanks
On Fri, Jul 26, 2013 at 1:25 PM, Michael Collins <msc@freeswitch.org>wrote:
I would do your "voicemail" stuff in the callback where you detect that the avmd detected true. I would also put the avmd_stop app in that code block. -MC
On Thu, Jul 25, 2013 at 7:33 PM, Raghu <srraghu45@gmail.com> wrote:
Thanks for checking it Michael. I thought i was trying execute 'speak' when AVMD detects a beep as below, but may be i am missing something. Please review the code and let me know if i am missing anything:
from freeswitch import *
# WARNING: known bugs with hangup hooks, use with extreme caution def hangup_hook(session, what): %s!!\n\n" % what) return
def input_callback(session, what, obj):
if (what == "dtmf"): consoleLog("info", what + " from callback " + obj.digit + "\n") return elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"): consoleLog("info", "Voicemail Detected\n")
return "TRUE"
def handler(session, args):
session.answer() # session.setVariable("hangup_after_bridge", "false") callback = session.setInputCallback("input_callback") session.execute("avmd", "start") consoleLog("info", "AVMD start\n") session.execute("sleep", "18000") consoleLog("info", "AVMD status %s\n" % session.getVariable('avmd_detect'))
if session.getVariable('avmd_detect'): consoleLog("info", "Beep Detected\n") session.execute("speak", "flite|kal|'Hi this is '") session.execute("avmd", "stop")
session.execute("speak", "flite|kal|'Hi this is '") consoleLog("info","callback returned %s!!\n\n" % callback) session.execute("avmd", "stop") consoleLog("info", "AVMD stop\n") session.setHangupHook(hangup_hook) session.hangup() #hangup the call
Appreciate it!
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
participants (3)
-
Michael Collins
-
Raghu
-
raj singh