[Freeswitch-users] Problems with wait_for_silence API call
Michael Jerris
mike at jerris.com
Fri Jun 10 02:00:59 MSD 2016
Can you please submit a pull request for these changes so they can be reviewed?
> On Jun 9, 2016, at 5:14 PM, Matthew <matthew at brightfire.net> wrote:
>
> Hello All,
>
> After poking around a bit more I realized is that wait_for_silence was
> never actually waiting for silence. It needs to detect non-silence
> before it will ever try to detect silence. That makes it quite useless
> if you call the function from a point where you can't guarantee that
> audio is being received :/ What I did was broke up the function into two
> smaller functions ...
>
> detect_audio <threshold> <audio_hits> <timeout_ms> [<file>]
> detect_silence <threshold> <silence_hits> <timeout_ms> [<file>]
>
> This allowed me the flexibility I needed to build an outbound dial
> solution the way I wanted to. For example, I can now do ...
>
> amd_detect = "person"
> dialout_session:execute( "voice_start" )
> -- wait up to 3 seconds for 5 frames of audio above threshold 300
> dialout_session:execute( "detect_audio", "300 5 3000" )
> detect_audio_timeout = dialout_session:getVariable(
> "detect_audio_timeout" )
> dialout_session:consoleLog( "INFO", "dialout: detect_audio_timeout =
> " .. detect_audio_timeout )
> -- if audio was detected, wait up to 30 seconds for 30 frames of
> silence below threshold 300
> if detect_audio_timeout == "false" then
> dialout_session:execute( "detect_silence", "300 30 30000" )
> end
> dialout_session:execute( "voice_stop" )
> if( dialout_session:getVariable( "amd_status" ) ~= nil ) then
> amd_detect = dialout_session:getVariable( "amd_status" )
> end
> dialout_session:consoleLog( "INFO", "dialout: amd_detect = " ..
> amd_detect )
> if amd_detect == "machine" then
> ...
> else
> ...
> end
>
> I have patches based on a current git repo. Should I submit those
> somewhere for inclusion upstream for other people to use or should I
> just maintain these locally?
>
> Thanks,
>
> -Matthew
>
> On 6/8/2016 4:05 PM, Matthew wrote:
>> Hello All,
>>
>> I've having a problem with the wait_for_silence API call in lua. When I
>> attempt to orginate a call and then check for silence on the line, I'm
>> getting unpredictable results. Sometimes it seems to work, but more
>> times than not it times out ( switch_ivr_wait_for_silence: TIMEOUT 0 ).
>> To test this, I answer the call, speak a short greeting and then mute
>> the handset. In other words, I know the script should be detecting
>> silence on the other end of the call. Here is a good portion of the test
>> script I'm using ...
>>
>> local cid_name = argv[1]
>> local cid_number = argv[2]
>> local gw_string = argv[3]
>> local queue_ext = argv[4]
>>
>> dialout_string =
>> "{origination_caller_id_name='" .. cid_name .. "'," ..
>> "origination_caller_id_number=" .. cid_number .. "," ..
>> "ignore_early_media=true}" .. gw_string
>>
>> dialout_session = freeswitch.Session( dialout_string )
>>
>> while dialout_session:ready() and not dialout_session:answered() do
>> freeswitch.msleep( 250 )
>> end
>>
>> if dialout_session:ready() and dialout_session:answered() then
>>
>> dialout_session:consoleLog( "INFO", "dialout: connected to " ..
>> gw_string ) )
>>
>> dialout_session:execute( "voice_start" )
>> dialout_session:sleep( 2000 )
>> dialout_session:execute( "wait_for_silence", "300 30 15 15000" )
>> dialout_session:execute( "voice_stop" )
>>
>> dialout_session:consoleLog( "INFO", "dialout: amd_detect = " ..
>> amd_detect )
>>
>> end
>>
>> And here is an example of how I would invoke the script ...
>>
>> luarun dialout.lua TEST 1234567890 sofia/gateway/twilio/+1234567890 7000
>>
>> Any ideas why the wait_for_silence API call would be misbehaving? Any
>> suggestions on how I could debug this problem further?
>>
>> Thanks,
>>
>> -Matthew
Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users
mailing list