Yes, I had a play and got it working on my test box. I had to modify the LUA downloaded from the link in this thread, mainly to fix some minor issues, but also to correctly specify the sound file location.
I downloaded the sound files, they were all in one directory and called lenny1, lenny2, lenny3 etc... They were in ULAW, so I converted them to WAV and renamed them to match what the LUA script was looking for.
If you look at the LUA script you will realise that it runs two loops, one for responses and one for no responses. You will also notice that the sound files are divided into three sub directories: greeting, mainloop, and noinputloop. I had to work out which sound files belong in each directory.
I made a directory called /usr/share/freeswitch/en/au/lenny/ and loaded the sound files into there. If I ever put this into production, I would record my own sound files to avoid any licensing issues.
My modified LUA is shown below and located at /usr/share/freeswitch/scripts/ A screenshot of the dialplan below that. Have fun...
Code:
--[[
It's Lenny in Lua
--]]
local path = '/usr/share/freeswitch/sounds/en/au/lenny/';
local counter_mainloop = 1;
local counter_noinput = 1;
local counter_consec_noinput = 0;
function get_filename (aType, aNumber)
local file = path .. aType .. '/' .. aNumber .. '.wav';
-- local fd = io.open(file, "r");
-- if fd == nil then
-- file = path .. aType .. '/' .. aNumber .. '.gsm';
-- end
-- io.close(fd);
return file;
end
function wait_for_silence(aTimeoutIncrement)
if aTimeoutIncrement == nil then
aTimeoutIncrement = 2000;
end
freeswitch.consoleLog( 'DEBUG', "Lenny - ENTER wait_for_silence " .. aTimeoutIncrement .. "\n" );
if session:ready() ~= true then
return false;
end
session:setVariable("wait_for_silence_timeout" , "");
session:setVariable("wait_for_silence_listenhits", "0");
session:setVariable("wait_for_silence_silence_hits", "0" );
session:execute( "wait_for_silence", "300 30 5 " .. aTimeoutIncrement);
local timeout = tonumber(session:getVariable("wait_for_silence_timeout"));
local speech = tonumber(session:getVariable("wait_for_silence_listenhits"));
local silence = tonumber(session:getVariable("wait_for_silence_silence_hits"));
freeswitch.consoleLog( 'DEBUG', "Lenny - Speech : " .. speech .. " Silence : " .. silence .. "\n" );
if speech > 20 then
wait_for_silence( aTimeoutIncrement );
return true;
else
return false;
end
end
function play_next_mainloop ()
session:execute( "playback", get_filename( 'mainloop', counter_mainloop ) );
counter_mainloop = counter_mainloop + 1;
local fd = io.open( get_filename( 'mainloop', counter_mainloop ) , "r");
if fd == nil then
counter_mainloop = 1;
else
io.close(fd);
end
counter_consec_noinput = 0;
return 2000;
end
function play_next_noinput ()
session:execute("playback", get_filename( 'noinputloop', counter_noinput ) );
counter_noinput = counter_noinput + 1;
counter_consec_noinput = counter_consec_noinput + 1;
local fd = io.open( get_filename( 'noinputloop', counter_noinput ) , "r");
if fd == nil then
counter_noinput = 1;
else
io.close(fd);
end
freeswitch.consoleLog( 'DEBUG', "Lenny - counter_consec_noinput " .. counter_consec_noinput .. "\n" );
if counter_consec_noinput > 3 then
counter_mainloop = 1;
end
return 3200;
end
session:answer();
session:execute( "playback", get_filename( 'greeting', 1 ) );
local SilenceTimeout = 4000;
while session:ready() == true do
if wait_for_silence( SilenceTimeout ) ~= true then
if counter_consec_noinput > 6 then
break;
end
SilenceTimeout = play_next_noinput();
else
SilenceTimeout = play_next_mainloop();
end
end
session:hangup();
View attachment 2179