<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.19154">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2 face=Arial>Hello, </FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial>I am creating an external application that uses 
FreeSWITCH ESL to initiate an outbound call and then run a&nbsp;LUA 
script.&nbsp; Within the LUA script I am executing AVMD. I want to see if its a 
human or voicemail on the other end.&nbsp; The outbound call is made 
and&nbsp;the LUA script executes.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial>Currently I would just like to see a consoleLog 
entry made by the onInput function in the LUA script, but that function does not 
seem to be called. AVMD starts the file is streamed then AVMD stops.&nbsp;As 
shown in the log.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial>I think I'm missing something.</FONT></DIV>
<DIV><FONT size=2 face=Arial>Dave Goodwin</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial>Pertinent FreeSWITCH Log Info:</FONT></DIV>
<DIV><FONT size=2 
face=Arial>-------------------------------------------------------------------------------------------------------</FONT></DIV>
<DIV><FONT size=2 face=Arial>EXECUTE <A 
href="mailto:sofia/internal/7202126254@xxx.xx.xxx.xx">sofia/internal/7202126254@xxx.xx.xxx.xx</A> 
avmd(start)<BR>2011-11-03 11:05:27.291678 [DEBUG] switch_core_media_bug.c:360 
Attaching BUG to <A 
href="mailto:sofia/internal/3035649554@xxx.xx.xxx.xx">sofia/internal/7202126254@xxx.xx.xxx.xx</A><BR>2011-11-03 
11:05:28.311249 [DEBUG] switch_ivr_play_say.c:1279 Codec Activated <A 
href="mailto:L16@8000hz">L16@8000hz</A> 1 channels 20ms<BR>2011-11-03 
11:05:28.350313 [DEBUG] switch_rtp.c:3082 Correct ip/port 
confirmed.<BR>2011-11-03 11:05:40.235535 [DEBUG] switch_ivr_play_say.c:1649 done 
playing file<BR>EXECUTE <A 
href="mailto:sofia/internal/3035649554@xxx.xx.xxx.xx">sofia/internal/7202126254@xxx.xx.xxx.xx</A> 
avmd(stop)<BR>2011-11-03 11:05:40.237488 [DEBUG] switch_core_media_bug.c:467 
Removing BUG from <A 
href="mailto:sofia/internal/3035649554@xxx.xx.xxx.xx">sofia/internal/7202126254@xxx.xx.xxx.xx</A><BR></FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial>Lua Script:&nbsp; </FONT></DIV>
<DIV><FONT size=2 
face=Arial>-------------------------------------------------------------------------------------------------------</FONT></DIV>
<DIV><FONT size=2 face=Arial>function onInput(session, type, 
obj)<BR>&nbsp;&nbsp;&nbsp; if type == "dtmf" and obj['digit'] == '1' and 
human_detected == false then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
human_detected = true<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
freeswitch.consoleLog("INFO","Human Detected\n")<BR>&nbsp;&nbsp;return 
"break"<BR>&nbsp;&nbsp;&nbsp; end<BR>&nbsp;&nbsp;&nbsp; if type == "event" and 
voicemail_detected == false then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
voicemail_detected = true<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
freeswitch.consoleLog("INFO","Voicemail 
Detected\n")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 
"break"<BR>&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
freeswitch.consoleLog("INFO","Nothing 
Happened\n")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 
"break"<BR>&nbsp;end<BR>end</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial>if session:ready() then<BR>&nbsp;---&nbsp; the call 
has been 
answered.<BR>&nbsp;session:setInputCallback("onInput")<BR>&nbsp;session:sleep(1000)<BR>&nbsp;session:execute("avmd","start")<BR>&nbsp;session:sleep(1000)<BR>&nbsp;session:streamFile("ivr/" 
.. 
wav_file)<BR>&nbsp;session:execute("avmd","stop")<BR>&nbsp;session:sleep(1000)<BR>&nbsp;fileName 
= "Completed " .. tostring(call_from_num) .. os.time() .. 
tostring(call_to_num)<BR>&nbsp;freeswitch.consoleLog("INFO","FileName = " .. 
fileName .. "\n")<BR>&nbsp;local myfile, ErrStr = io.open("log/outcall/" .. 
fileName,"w")<BR>&nbsp;if myfile then<BR>&nbsp;&nbsp;myfile:write(call_from_num 
.. "|", call_to_num .. "|" , 
os.date())<BR>&nbsp;&nbsp;myfile:flush()<BR>&nbsp;&nbsp;myfile:close()<BR>&nbsp;else<BR>&nbsp;&nbsp;freeswitch.consoleLog("INFO","Error 
writing File = '" .. ErrStr .. "'\n")<BR>&nbsp;end --if<BR>end 
--if<BR></FONT></DIV></BODY></HTML>