<div dir="ltr">Tried with the following with no luck, seems like the callback never gets called<div><br></div><div><div> elif (what == &quot;event&quot; and obj.getHeader(&quot;Event-Name&quot;) == &quot;CUSTOM&quot;):</div>
<div>        session.execute(&quot;avmd&quot;, &quot;stop&quot;)</div><div>        consoleLog(&quot;info&quot;, &quot;Voicemail Detected\n&quot;)</div><div>        session.execute(&quot;speak&quot;, &quot;flite|kal|&#39;Hi this is &#39;&quot;)</div>
<div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jul 26, 2013 at 6:32 PM, raj singh <span dir="ltr">&lt;<a href="mailto:rajictdialer@gmail.com" target="_blank">rajictdialer@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Forgot to mention, i bought the cookbook, good stuff, i hope there could some python examples in the next version. Thanks</div>
<div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jul 26, 2013 at 6:28 PM, raj singh <span dir="ltr">&lt;<a href="mailto:rajictdialer@gmail.com" target="_blank">rajictdialer@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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 &lt;&lt;&lt; AVMD v=0.001063 f=0.728471 927.518323Hz sma=0.701958 sqa=0.493808 &gt;&gt;&gt;</div><div>2013-07-26 18:17:05.888113 [DEBUG] mod_avmd.c:536 &lt;&lt;&lt; AVMD v=0.000980 f=0.691887 880.938146Hz sma=0.698135 sqa=0.488372 &gt;&gt;&gt;</div>


<div>2013-07-26 18:17:05.888113 [DEBUG] mod_avmd.c:559 &lt;&lt;&lt; AVMD - Beep Detected &gt;&gt;&gt;</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" target="_blank">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" target="_blank">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" target="_blank">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" target="_blank">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" target="_blank">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" target="_blank">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" target="_blank">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" target="_blank">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"><div><div>On Fri, Jul 26, 2013 at 5:34 PM, Michael Collins <span dir="ltr">&lt;<a href="mailto:msc@freeswitch.org" target="_blank">msc@freeswitch.org</a>&gt;</span> wrote:<br>


</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><div><div><div><div><div><div>I don&#39;t know Python but if it works like other languages then when an event comes in the input callback is called:<div>


<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 == &quot;dtmf&quot;):</span></div><div><span style="font-family:courier new,monospace">        consoleLog(&quot;info&quot;, what + &quot; from callback &quot; + obj.digit + &quot;\n&quot;)</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 == &quot;event&quot; and session.getVariable(&#39;avmd_</span><span style="font-family:courier new,monospace">detect&#39;) == &quot;TRUE&quot;):</span></div>



<div><span style="font-family:courier new,monospace">        consoleLog(&quot;info&quot;, &quot;Voicemail Detected\n&quot;)</span></div><br><br></div></div>The &quot;what&quot; tells you the type of input. In this case you test for what==&quot;dtmf&quot; (for when the user presses a dtmf key) and for what==&quot;event&quot; 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&#39;s detected a beep. (This is not the optimal method because you can actually check the event headers to make sure it&#39;s the correct event. I&#39;ll leave that as a research project for you.)<br>



<br></div>Again, I&#39;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&#39;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&#39;m assuming that you want to play a message after the beep?) Something like this:<div>


<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 == &quot;dtmf&quot;):</span></div>



<div><span style="font-family:courier new,monospace">        consoleLog(&quot;info&quot;, what + &quot; from callback &quot; + obj.digit + &quot;\n&quot;)</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 == &quot;event&quot; and session.getVariable(&#39;avmd_</span><span style="font-family:courier new,monospace">detect&#39;) == &quot;TRUE&quot;):</span></div>



</div><div><div><span style="font-family:courier new,monospace"></span><span style="font-family:courier new,monospace">        session.execute(&quot;avmd&quot;, &quot;stop&quot;)</span><br></div><span style="font-family:courier new,monospace">


</span></div><div><span style="font-family:courier new,monospace">        consoleLog(&quot;info&quot;, &quot;Voicemail Detected\n&quot;)<br></span><div><div><span style="font-family:courier new,monospace">        session.execute(&quot;speak&quot;, &quot;flite|kal|&#39;Hi this is &#39;&quot;)</span></div>



<span style="font-family:courier new,monospace"></span><br></div></div><div><div><span style="font-family:courier new,monospace">    return &quot;TRUE&quot;</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(&quot;hangup_</span><span style="font-family:courier new,monospace">after_bridge&quot;, &quot;false&quot;)</span></div><span style="font-family:courier new,monospace">
</span><div>

<div><span style="font-family:courier new,monospace">    callback = session.setInputCallback(&quot;</span><span style="font-family:courier new,monospace">input_callback&quot;)</span></div><div><span style="font-family:courier new,monospace">    session.execute(&quot;avmd&quot;, &quot;start&quot;)</span></div>



<div><span style="font-family:courier new,monospace">    consoleLog(&quot;info&quot;, &quot;AVMD start\n&quot;)</span></div></div><span style="font-family:courier new,monospace">
</span></div><div><span style="font-family:courier new,monospace">    session.execute(&quot;sleep&quot;, &quot;18000&quot;) # this could be a playback<br></span></div><div><div>

<div><span style="font-family:courier new,monospace">    consoleLog(&quot;info&quot;, &quot;AVMD status %s\n&quot; % session.getVariable(&#39;avmd_</span><span style="font-family:courier new,monospace">detect&#39;))</span></div>



<div><span style="font-family:courier new,monospace"></span></div></div><div><span style="font-family:courier new,monospace">    session.execute(&quot;avmd&quot;, &quot;stop&quot;)</span></div></div><div>
<div><div><span style="font-family:courier new,monospace">    consoleLog(&quot;info&quot;, &quot;AVMD stop\n&quot;)</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&#39;t think it&#39;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&#39;m co-author of both of those books). Also, don&#39;t be afraid of checking out all the Lua examples. Lua is easy to read if you&#39;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&amp;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><br><br><div class="gmail_quote">On Fri, Jul 26, 2013 at 2:46 PM, raj singh <span dir="ltr">&lt;<a href="mailto:rajictdialer@gmail.com" target="_blank">rajictdialer@gmail.com</a>&gt;</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">&lt;<a href="mailto:msc@freeswitch.org" target="_blank">msc@freeswitch.org</a>&gt;</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 &quot;voicemail&quot; 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">&lt;<a href="mailto:srraghu45@gmail.com" target="_blank">srraghu45@gmail.com</a>&gt;</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 &#39;speak&#39; 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&quot; % what)<br></div>

<div>    return</div><div><br></div><div>def input_callback(session, what, obj):</div><div><br></div><div>    if (what == &quot;dtmf&quot;):</div><div>        consoleLog(&quot;info&quot;, what + &quot; from callback &quot; + obj.digit + &quot;\n&quot;)</div>






<div>        return</div><div>    elif (what == &quot;event&quot; and session.getVariable(&#39;avmd_detect&#39;) == &quot;TRUE&quot;):</div><div>        consoleLog(&quot;info&quot;, &quot;Voicemail Detected\n&quot;)</div>






<div><br></div><div>    return &quot;TRUE&quot;</div><div><br></div><div>def handler(session, args):</div><div><br></div><div>    session.answer()</div></div><div>   # session.setVariable(&quot;hangup_after_bridge&quot;, &quot;false&quot;)</div>




<div>

<div>    callback = session.setInputCallback(&quot;input_callback&quot;)</div><div>    session.execute(&quot;avmd&quot;, &quot;start&quot;)</div><div>    consoleLog(&quot;info&quot;, &quot;AVMD start\n&quot;)</div></div>




<div>    session.execute(&quot;sleep&quot;, &quot;18000&quot;)</div><div>

<div>    consoleLog(&quot;info&quot;, &quot;AVMD status %s\n&quot; % session.getVariable(&#39;avmd_detect&#39;))</div><div><br></div><div>    if session.getVariable(&#39;avmd_detect&#39;):</div></div><div><div>
         consoleLog(&quot;info&quot;, &quot;Beep Detected\n&quot;)</div>

<div>         session.execute(&quot;speak&quot;, &quot;flite|kal|&#39;Hi this is &#39;&quot;)</div><div>         session.execute(&quot;avmd&quot;, &quot;stop&quot;)</div><div><br></div><div>    session.execute(&quot;speak&quot;, &quot;flite|kal|&#39;Hi this is &#39;&quot;)</div>






</div><div>    consoleLog(&quot;info&quot;,&quot;callback returned   %s!!\n\n&quot; % callback)</div><div><div>    session.execute(&quot;avmd&quot;, &quot;stop&quot;)</div><div>    consoleLog(&quot;info&quot;, &quot;AVMD stop\n&quot;)</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>-- <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></div></div><div>_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org" target="_blank">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" target="_blank">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></div></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>