<div dir="ltr">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:<div>
<br></div><div><div><div>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 >>></div><div>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 >>></div>
<div>2013-07-26 18:17:05.888113 [DEBUG] mod_avmd.c:559 <<< AVMD - Beep Detected >>></div><div>2013-07-26 18:17:17.708529 [INFO] switch_cpp.cpp:1288 AVMD status TRUE</div><div>EXECUTE dingaling/gtalk/+<a href="mailto:xxxxxxxxxx@voice.google.com">xxxxxxxxxx@voice.google.com</a> avmd(stop)</div>
<div>2013-07-26 18:17:17.708529 [DEBUG] switch_core_media_bug.c:808 Removing BUG from dingaling/gtalk/+<a href="mailto:xxxxxxxxxx@voice.google.com">xxxxxxxxxx@voice.google.com</a></div><div>2013-07-26 18:17:17.708529 [INFO] switch_cpp.cpp:1288 AVMD stop</div>
<div>2013-07-26 18:17:17.708529 [DEBUG] switch_cpp.cpp:670 CoreSession::hangup</div><div>2013-07-26 18:17:17.708529 [NOTICE] switch_cpp.cpp:672 Hangup dingaling/gtalk/+<a href="mailto:xxxxxxxxxx@voice.google.com">xxxxxxxxxx@voice.google.com</a> [CS_EXECUTE] [NORMAL_CLEARING]</div>
<div>2013-07-26 18:17:17.708529 [DEBUG] switch_channel.c:3135 Send signal dingaling/gtalk/+<a href="mailto:xxxxxxxxxx@voice.google.com">xxxxxxxxxx@voice.google.com</a> [KILL]</div><div>2013-07-26 18:17:17.708529 [DEBUG] mod_dingaling.c:2095 dingaling/gtalk/+<a href="mailto:xxxxxxxxxx@voice.google.com">xxxxxxxxxx@voice.google.com</a> CHANNEL KILL</div>
<div>2013-07-26 18:17:17.708529 [DEBUG] switch_core_session.c:1341 Send signal dingaling/gtalk/+<a href="mailto:xxxxxxxxxx@voice.google.com">xxxxxxxxxx@voice.google.com</a> [BREAK]</div><div>2013-07-26 18:17:17.708529 [DEBUG] mod_dingaling.c:2095 dingaling/gtalk/+<a href="mailto:xxxxxxxxxx@voice.google.com">xxxxxxxxxx@voice.google.com</a> CHANNEL KILL</div>
<div>2013-07-26 18:17:17.708529 [INFO] switch_cpp.cpp:1288 hangup hook for RAJ hangup!!</div><div><br></div><div>2013-07-26 18:17:17.708529 [DEBUG] mod_python.c:284 Finished calling python script </div><div>2013-07-26 18:17:17.708529 [DEBUG] switch_cpp.cpp:1051 dingaling/gtalk/+<a href="mailto:xxxxxxxxxx@voice.google.com">xxxxxxxxxx@voice.google.com</a> destroy/unlink session from object</div>
</div></div><div><br></div><div>Any suggestions?</div><div><br></div><div>Thanks</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jul 26, 2013 at 5:34 PM, Michael Collins <span dir="ltr"><<a href="mailto:msc@freeswitch.org" target="_blank">msc@freeswitch.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div>I don't know Python but if it works like other languages then when an event comes in the input callback is called:<div class="im">
<br><br><div><span style="font-family:courier new,monospace">def input_callback(session, what, obj):</span></div>
<div><span style="font-family:courier new,monospace"><br></span></div><div><span style="font-family:courier new,monospace"> if (what == "dtmf"):</span></div><div><span style="font-family:courier new,monospace"> consoleLog("info", what + " from callback " + obj.digit + "\n")</span></div>
<span style="font-family:courier new,monospace">
</span><div><span style="font-family:courier new,monospace"> return</span></div><div><span style="font-family:courier new,monospace"> elif (what == "event" and session.getVariable('avmd_</span><span style="font-family:courier new,monospace">detect') == "TRUE"):</span></div>
<div><span style="font-family:courier new,monospace"> consoleLog("info", "Voicemail Detected\n")</span></div><br><br></div></div>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.)<br>
<br></div>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:<div class="im">
<br>
<br><div><span style="font-family:courier new,monospace">def input_callback(session, what, obj):</span></div><div><span style="font-family:courier new,monospace"><br></span></div><div><span style="font-family:courier new,monospace"> if (what == "dtmf"):</span></div>
<div><span style="font-family:courier new,monospace"> consoleLog("info", what + " from callback " + obj.digit + "\n")</span></div><span style="font-family:courier new,monospace">
</span><div><span style="font-family:courier new,monospace"> return</span></div><div><span style="font-family:courier new,monospace"> elif (what == "event" and session.getVariable('avmd_</span><span style="font-family:courier new,monospace">detect') == "TRUE"):</span></div>
</div><div class="im"><div><span style="font-family:courier new,monospace"></span><span style="font-family:courier new,monospace"> session.execute("avmd", "stop")</span><br></div><span style="font-family:courier new,monospace">
</span></div><div><span style="font-family:courier new,monospace"> consoleLog("info", "Voicemail Detected\n")<br></span><div class="im"><div><span style="font-family:courier new,monospace"> session.execute("speak", "flite|kal|'Hi this is '")</span></div>
<span style="font-family:courier new,monospace"></span><br></div></div><div class="im"><div><span style="font-family:courier new,monospace"> return "TRUE"</span></div><div><span style="font-family:courier new,monospace"><br>
</span></div>
<div><span style="font-family:courier new,monospace">def handler(session, args):</span></div><div><span style="font-family:courier new,monospace"><br></span></div><div><span style="font-family:courier new,monospace"> session.answer()</span></div>
<div><span style="font-family:courier new,monospace"> # session.setVariable("hangup_</span><span style="font-family:courier new,monospace">after_bridge", "false")</span></div><span style="font-family:courier new,monospace">
</span><div>
<div><span style="font-family:courier new,monospace"> callback = session.setInputCallback("</span><span style="font-family:courier new,monospace">input_callback")</span></div><div><span style="font-family:courier new,monospace"> session.execute("avmd", "start")</span></div>
<div><span style="font-family:courier new,monospace"> consoleLog("info", "AVMD start\n")</span></div></div><span style="font-family:courier new,monospace">
</span></div><div><span style="font-family:courier new,monospace"> session.execute("sleep", "18000") # this could be a playback<br></span></div><div><div class="im">
<div><span style="font-family:courier new,monospace"> consoleLog("info", "AVMD status %s\n" % session.getVariable('avmd_</span><span style="font-family:courier new,monospace">detect'))</span></div>
<div><span style="font-family:courier new,monospace"></span></div></div><div class="im"><span style="font-family:courier new,monospace"> session.execute("avmd", "stop")</span></div></div><div class="im">
<div><div><span style="font-family:courier new,monospace"> consoleLog("info", "AVMD stop\n")</span></div>
<span style="font-family:courier new,monospace">
</span><div><span style="font-family:courier new,monospace"> session.setHangupHook(hangup_</span><span style="font-family:courier new,monospace">hook)</span></div><div><span style="font-family:courier new,monospace"> session.hangup() #hangup the call<br>
</span><br></div></div><br></div></div>I don't think it's any more complicated than that. <br><br></div>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. <br>
<br></div>Start by trying to understand <a href="https://wiki.freeswitch.org/index.php?title=Special%3ASearch&search=setInputCallback" target="_blank">setInputCallback</a> and go from there.<br><br></div>Hope this helps,<br>
MC<br><div>
<div><div><div><div><div><div><div class="gmail_extra"><div><div class="h5"><br><br><div class="gmail_quote">On Fri, Jul 26, 2013 at 2:46 PM, raj singh <span dir="ltr"><<a href="mailto:rajictdialer@gmail.com" target="_blank">rajictdialer@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">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?<div>
<br></div><div>Thanks</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Fri, Jul 26, 2013 at 1:25 PM, Michael Collins <span dir="ltr"><<a href="mailto:msc@freeswitch.org" target="_blank">msc@freeswitch.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr"><div>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.<br></div>-MC<br></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Thu, Jul 25, 2013 at 7:33 PM, Raghu <span dir="ltr"><<a href="mailto:srraghu45@gmail.com" target="_blank">srraghu45@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">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:<div>
<br></div><div><div><div>from freeswitch import *</div><div><br></div><div># WARNING: known bugs with hangup hooks, use with extreme caution</div><div>def hangup_hook(session, what):</div></div><div>
<div> %s!!\n\n" % what)<br></div>
<div> return</div><div><br></div><div>def input_callback(session, what, obj):</div><div><br></div><div> if (what == "dtmf"):</div><div> consoleLog("info", what + " from callback " + obj.digit + "\n")</div>
<div> return</div><div> elif (what == "event" and session.getVariable('avmd_detect') == "TRUE"):</div><div> consoleLog("info", "Voicemail Detected\n")</div>
<div><br></div><div> return "TRUE"</div><div><br></div><div>def handler(session, args):</div><div><br></div><div> session.answer()</div></div><div> # session.setVariable("hangup_after_bridge", "false")</div>
<div>
<div> callback = session.setInputCallback("input_callback")</div><div> session.execute("avmd", "start")</div><div> consoleLog("info", "AVMD start\n")</div></div>
<div> session.execute("sleep", "18000")</div><div>
<div> consoleLog("info", "AVMD status %s\n" % session.getVariable('avmd_detect'))</div><div><br></div><div> if session.getVariable('avmd_detect'):</div></div><div><div>
consoleLog("info", "Beep Detected\n")</div>
<div> session.execute("speak", "flite|kal|'Hi this is '")</div><div> session.execute("avmd", "stop")</div><div><br></div><div> session.execute("speak", "flite|kal|'Hi this is '")</div>
</div><div> consoleLog("info","callback returned %s!!\n\n" % callback)</div><div><div> session.execute("avmd", "stop")</div><div> consoleLog("info", "AVMD stop\n")</div>
<div> session.setHangupHook(hangup_hook)</div><div> session.hangup() #hangup the call</div></div></div><div><br></div><div>Appreciate it!</div><div><br></div></div><br clear="all"></blockquote></div></div></blockquote>
</div></div></blockquote></div><br></div></div><div class="im">-- <br>Michael S Collins<br>Twitter: @mercutioviz<br><a href="http://www.FreeSWITCH.org" target="_blank">http://www.FreeSWITCH.org</a><br><a href="http://www.ClueCon.com" target="_blank">http://www.ClueCon.com</a><br>
<a href="http://www.OSTAG.org" target="_blank">http://www.OSTAG.org</a><br><br>
</div></div></div></div></div></div></div></div></div></div>
<br>_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>
<a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br></div>