Hello everyone, I have a problem. Please help me. Thank you very much!
Background:
Asterisk 16
Originate dials PSTN 13xxx, and dials local extension 888 after the call is connected
Problem:
If the voice speaker of 13xxx number is turned on, it will be automatically connected and call extension 888. When 888 answers, it is an invalid call.
Idea:
During the call of 13xxx, I want to analyze the recording when calling, and use ASR to determine whether it is a voice mailbox. If so, the call will be terminated.
Attempt:
Use MixMonitor and Monitor to record only after connecting 13xxx.
During the call, the size of the recording file is always 44 bytes
I’m not sure I completely follow your scenario, since I don’t understand “If the voice speaker of 13xxx number is turned on” means exactly. My initial thought was you had a SIP device with auto-answer enabled, but then it says you dialed PSTN so I don’t think that’s it.
If you’re ultimately trying to detect if 13xxx is answered by a machine/voicemail, have you looked at the AMD() function of Asterisk? I think that might be what you are needing.
You don’t need to listen/record during the Originate, you need to listen after the Dial to 130 is answered. Put the AMD() call in the exten => 888 before the Dial there. It will then listen to the connected call and determine whether it thinks it was answered by human or machine. Then either make the Dial to 888 or not based on the AMD() result using a ExecIf or something like that.
The 13xxx is a member’s phone number, and I use a third-party service OneOut (SIP TRUNK) to call him. Currently, I can only start recording after the call is connected, which corresponds to item 2 below. The audio during the call setup is not present in the recording file.
Ring: You can hear “After the beep for voicemail, the charge starts. If you don’t want to leave a message, please hang up. Quick message. After the beep, please press the asterisk key.”
Answered: You can hear “You have entered the voicemail of 13xxx. Please leave a message after the beep.”
If using AMD, it can only detect after the call is connected.
I tried adding Answer(), and the recording file then includes the above messages, but Originate will call both 13xxx and 888 simultaneously (I expect it to call 13xxx first, and after it’s connected, then call 888), so it’s not suitable for me.
I found some information that the 183 Session Progress returned from the SIP Trunk provider will have Early media. Currently, Asterisk cannot detect it before the answer.
The calls to 13XXX and 888 are not simultaneous, they just seem like it to you because you have no logic to control if/when the Dial(SIP/888) happens or not. Put a Wait(10) before the Dial(SIP/888) and you’ll see my point.
Personally, I’d do this using ARI with a snoop channel or external media channel to pipe the audio to whatever I was using to do the analysis rather than record to file first. Recording to a file first won’t let you do it in real-time well. Especially not using a .wav format.
If you are going to use a file recording, I’d suggest a different format than .wav. .wav files have a wrapper around the actual data that contains info about the data inside the file (so Windows could understand it). You only want the data within it anyway if you are trying to analyze it in real-time.
I also think to do this in dialplan, you’d need to move your MixMonitor() call to the 888 side of the call and put your logic between that and your Dial() as to whether you actually execute the Dial(SIP/888). The MixMonitor() would need to be proceeded with a Progress() I believe to get the audio path established first to record Early Media. I can’t say this would work for sure as I’ve never tried this in dialplan, but it is what I’d try if I was insisting on going it in dialplan. You may have to put a StopMixMonitor() in there to get the file to write out for sure before you will get data written to the file. There are much better ways to do this.
You should also be using PJSIP, rather than SIP. SIP is going away.
Firstly, thank you for your response and suggestions.
Currently, my plan is also similar to the wait solution, but it processes through AGI, monitoring the recording files. The development is complete and we’re preparing for deployment.
Regarding the mentioned solution of monitoring channels to obtain recordings, I haven’t found a solution yet, so I will conduct further research, including on PSIP.
Once again, thank you for your response and suggestions!