Play beep toward end of recording

I’d like to create a dial plan context where people can dial in and record a message, up to 2 minutes in length. 30 seconds before their recording time period is up I’d like to play a beep tone, which will indicate to them that their recording time is running out. Is there a way to do this?

Thanks.

Make a context who record the call , and then use Local channel and the L option of the dial command to dial to the recoding context and remember to use the LIMIT_WARNING_FILE variable to play the beep

_set(LIMIT_WARNING_FILE=beep)

thanks for the quick response. From my research I was led to believe that this is was for call duration. That is, after the duration set in Limit the call would end. I have more in my context after the recording is finished. So, from what your’re saying I can use limit for Record, and then let the dial plan context continue.

The L option Limit the call to x milliseconds. After that time the call will be terminated

Thanks, then that’s not what I’m looking for. I want to limit the duration of the recording time for the voice message they leave. After that my system will play more prompts: give them the opportunity to review their message, re-record, save, etc. So, the call can’t end right away. After the 2 minute recording limit the call remains and the dial plan continues to the caller.

You didnt provided a detailed description of you needs in your first post , as you are doing now, anyway thinking fast I just can suggest use the maxduration option on the record() application, Maybe tomorrow when I have some free time, I can provide you a more detailed solution if you havent figure out how to do it

You could use the PERIODIC_HOOK function for this. If the periodic interval is set to 90 seconds, it should trigger 30 seconds before your 2 minute mark. At 2 minutes, the recording will be stopped and the call - presumably - hung up.

Thanks for pointing out PERIODIC_HOOK. I’ve tried running the test example at https://reviewboard.asterisk.org/r/3362/diff/3-4/ but I don’t hear the beep. The Asterisk CLI doesn’t show any particular errors. I’m running Asterisk 13.6.0 IncrediblePBX.

Here is a portion of the CLI log:

    -- Goto (test,100,1)
    -- Executing [100@test:1] Answer("SIP/voipms-00000036", "") in new stack
    -- Executing [100@test:2] Set("SIP/voipms-00000036", "BEEP_ID=6") in new stack
    -- Executing [100@test:3] Wait("SIP/voipms-00000036", "20") in new stack
    -- Called hook@__func_periodic_hook_context__
    -- Executing [hook@__func_periodic_hook_context__:1] Set("Local/hook@__func_periodic_hook_context__-00000021;2", "EncodedChannel=SIP/voipms-00000036") in new stack
    -- Executing [hook@__func_periodic_hook_context__:2] Set("Local/hook@__func_periodic_hook_context__-00000021;2", "GROUP_NAME=SIP/voipms-000000366") in new stack
    -- Executing [hook@__func_periodic_hook_context__:3] Set("Local/hook@__func_periodic_hook_context__-00000021;2", "GROUP(periodic-hook)=SIP/voipms-000000366") in new stack
    -- Executing [hook@__func_periodic_hook_context__:4] ExecIf("Local/hook@__func_periodic_hook_context__-00000021;2", "0?Hangup()") in new stack
    -- Executing [hook@__func_periodic_hook_context__:5] Set("Local/hook@__func_periodic_hook_context__-00000021;2", "ChannelToSpy=SIP/voipms-00000036") in new stack
    -- Executing [hook@__func_periodic_hook_context__:6] ChanSpy("Local/hook@__func_periodic_hook_context__-00000021;2", "SIP/voipms-00000036,qEB") in new stack
    -- Local/hook@__func_periodic_hook_context__-00000021;1 answered
    -- Executing [beep@hooks:1] Answer("Local/hook@__func_periodic_hook_context__-00000021;1", "") in new stack
    -- Executing [beep@hooks:2] Verbose("Local/hook@__func_periodic_hook_context__-00000021;1", "1,Channel name: SIP/voipms-00000036") in new stack
 Channel name: SIP/voipms-00000036
    -- Executing [beep@hooks:3] Verbose("Local/hook@__func_periodic_hook_context__-00000021;1", "1,Hook ID: 6") in new stack
 Hook ID: 6
    -- Executing [beep@hooks:4] Playback("Local/hook@__func_periodic_hook_context__-00000021;1", "beep") in new stack
    -- <Local/hook@__func_periodic_hook_context__-00000021;1> Playing 'beep.gsm' (language 'en')
  == Spying on channel SIP/voipms-00000036
[2016-12-12 10:37:01] NOTICE[18139][C-00000077]: app_chanspy.c:501 start_spying: Attaching Local/hook@__func_periodic_hook_context__-00000021;2 to SIP/voipms-00000036
[2016-12-12 10:37:01] NOTICE[18139][C-00000077]: app_chanspy.c:501 start_spying: Attaching Local/hook@__func_periodic_hook_context__-00000021;2 to SIP/voipms-00000036
    -- Auto fallthrough, channel 'Local/hook@__func_periodic_hook_context__-00000021;1' status is 'UNKNOWN'
  == Done Spying on channel SIP/voipms-00000036
    -- Stopped spying due to the spied-on channel hanging up.
  == Spawn extension (__func_periodic_hook_context__, hook, 6) exited non-zero on 'Local/hook@__func_periodic_hook_context__-00000021;2'
    -- Called hook@__func_periodic_hook_context__
    -- Executing [hook@__func_periodic_hook_context__:1] Set("Local/hook@__func_periodic_hook_context__-00000022;2", "EncodedChannel=SIP/voipms-00000036") in new stack
    -- Executing [hook@__func_periodic_hook_context__:2] Set("Local/hook@__func_periodic_hook_context__-00000022;2", "GROUP_NAME=SIP/voipms-000000366") in new stack
    -- Executing [hook@__func_periodic_hook_context__:3] Set("Local/hook@__func_periodic_hook_context__-00000022;2", "GROUP(periodic-hook)=SIP/voipms-000000366") in new stack
    -- Executing [hook@__func_periodic_hook_context__:4] ExecIf("Local/hook@__func_periodic_hook_context__-00000022;2", "0?Hangup()") in new stack
    -- Executing [hook@__func_periodic_hook_context__:5] Set("Local/hook@__func_periodic_hook_context__-00000022;2", "ChannelToSpy=SIP/voipms-00000036") in new stack
    -- Executing [hook@__func_periodic_hook_context__:6] ChanSpy("Local/hook@__func_periodic_hook_context__-00000022;2", "SIP/voipms-00000036,qEB") in new stack
    -- Local/hook@__func_periodic_hook_context__-00000022;1 answered
    -- Executing [beep@hooks:1] Answer("Local/hook@__func_periodic_hook_context__-00000022;1", "") in new stack
    -- Executing [beep@hooks:2] Verbose("Local/hook@__func_periodic_hook_context__-00000022;1", "1,Channel name: SIP/voipms-00000036") in new stack
 Channel name: SIP/voipms-00000036
    -- Executing [beep@hooks:3] Verbose("Local/hook@__func_periodic_hook_context__-00000022;1", "1,Hook ID: 6") in new stack
 Hook ID: 6
    -- Executing [beep@hooks:4] Playback("Local/hook@__func_periodic_hook_context__-00000022;1", "beep") in new stack
    -- <Local/hook@__func_periodic_hook_context__-00000022;1> Playing 'beep.gsm' (language 'en')
  == Spying on channel SIP/voipms-00000036
[2016-12-12 10:37:06] NOTICE[18142][C-00000079]: app_chanspy.c:501 start_spying: Attaching Local/hook@__func_periodic_hook_context__-00000022;2 to SIP/voipms-00000036
[2016-12-12 10:37:06] NOTICE[18142][C-00000079]: app_chanspy.c:501 start_spying: Attaching Local/hook@__func_periodic_hook_context__-00000022;2 to SIP/voipms-00000036
    -- Auto fallthrough, channel 'Local/hook@__func_periodic_hook_context__-00000022;1' status is 'UNKNOWN'
  == Done Spying on channel SIP/voipms-00000036
    -- Stopped spying due to the spied-on channel hanging up.
  == Spawn extension (__func_periodic_hook_context__, hook, 6) exited non-zero on 'Local/hook@__func_periodic_hook_context__-00000022;2'
    -- Called hook@__func_periodic_hook_context__
    -- Executing [hook@__func_periodic_hook_context__:1] Set("Local/hook@__func_periodic_hook_context__-00000023;2", "EncodedChannel=SIP/voipms-00000036") in new stack

In the snippet above, the end of the Local channel that is playing beep is executing before the other end of the Local channel has started its spying. That’s possibly happening because the act of attaching the spying channel takes some coordination inside Asterisk, and while it’s attempting to start the spy, it starts executing the ;1 side of the Local channel. (I’m guessing, but are you running on some hardware that’s a bit limited? That would probably cause this to happen.)

Anyway, an easy fix would be to just add a Wait(1) to the beep dialplan:

exten => beep,1,Answer()
 same => n,Wait(1)
 same => n,Verbose(...)
 ...
 same => n,Playback(beep)

That should cause the ;1 channel to give up its control of the processor for a second, allowing the ;2 channel to attach to the SIP channel.

Thanks for the recommendation. I did add the Wait command, and the spying channel becomes attached before playing the beep. However, I still do not hear the beep. Here is the latest logging:
START ============================================== START
– Goto (test,100,1)
– Executing [100@test:1] Answer(“SIP/voipms-00000038”, “”) in new stack
– Executing [100@test:2] Set(“SIP/voipms-00000038”, “BEEP_ID=8”) in new stack
– Executing [100@test:3] Wait(“SIP/voipms-00000038”, “20”) in new stack
– Called hook@func_periodic_hook_context
– Executing [hook@func_periodic_hook_context:1] Set(“Local/hook@func_periodic_hook_context-0000002d;2”, “EncodedChannel=SIP/voipms-00000038”) in new stack
– Executing [hook@func_periodic_hook_context:2] Set(“Local/hook@func_periodic_hook_context-0000002d;2”, “GROUP_NAME=SIP/voipms-000000388”) in new stack
– Executing [hook@func_periodic_hook_context:3] Set(“Local/hook@func_periodic_hook_context-0000002d;2”, “GROUP(periodic-hook)=SIP/voipms-000000388”) in new stack
– Executing [hook@func_periodic_hook_context:4] ExecIf(“Local/hook@func_periodic_hook_context-0000002d;2”, “0?Hangup()”) in new stack
– Executing [hook@func_periodic_hook_context:5] Set(“Local/hook@func_periodic_hook_context-0000002d;2”, “ChannelToSpy=SIP/voipms-00000038”) in new stack
– Executing [hook@func_periodic_hook_context:6] ChanSpy(“Local/hook@func_periodic_hook_context-0000002d;2”, “SIP/voipms-00000038,qEB”) in new stack
– Local/hook@func_periodic_hook_context-0000002d;1 answered
– Executing [beep@hooks:1] Answer(“Local/hook@func_periodic_hook_context-0000002d;1”, “”) in new stack
– Executing [beep@hooks:2] Wait(“Local/hook@func_periodic_hook_context-0000002d;1”, “1”) in new stack
== Spying on channel SIP/voipms-00000038
[2016-12-12 12:38:32] NOTICE[26771][C-00000091]: app_chanspy.c:501 start_spying: Attaching Local/hook@func_periodic_hook_context-0000002d;2 to SIP/voipms-00000038
[2016-12-12 12:38:32] NOTICE[26771][C-00000091]: app_chanspy.c:501 start_spying: Attaching Local/hook@func_periodic_hook_context-0000002d;2 to SIP/voipms-00000038
– Executing [beep@hooks:3] Verbose(“Local/hook@func_periodic_hook_context-0000002d;1”, “1,Channel name: SIP/voipms-00000038”) in new stack
Channel name: SIP/voipms-00000038
– Executing [beep@hooks:4] Verbose(“Local/hook@func_periodic_hook_context-0000002d;1”, “1,Hook ID: 8”) in new stack
Hook ID: 8
– Executing [beep@hooks:5] Playback(“Local/hook@func_periodic_hook_context-0000002d;1”, “beep”) in new stack
– <Local/hook@func_periodic_hook_context-0000002d;1> Playing ‘beep.gsm’ (language ‘en’)
– Auto fallthrough, channel ‘Local/hook@func_periodic_hook_context-0000002d;1’ status is ‘UNKNOWN’
== Done Spying on channel SIP/voipms-00000038
– Stopped spying due to the spied-on channel hanging up.
== Spawn extension (func_periodic_hook_context, hook, 6) exited non-zero on ‘Local/hook@func_periodic_hook_context-0000002d;2’
– Called hook@func_periodic_hook_context
– Executing [hook@func_periodic_hook_context:1] Set(“Local/hook@func_periodic_hook_context-0000002e;2”, “EncodedChannel=SIP/voipms-00000038”) in new stack
– Executing [hook@func_periodic_hook_context:2] Set(“Local/hook@func_periodic_hook_context-0000002e;2”, “GROUP_NAME=SIP/voipms-000000388”) in new stack

I’m running Asterisk 13.6.0. The beep.gsm file plays correctly elsewhere in the dial plan. Any other thoughts? Thanks in advance.