Record and Playback DTMF

I am trying somehow to record a DTMF sequence as WAV that I can playback with asterisk.
What I am trying to achieve is that I can verify if a asterisk system is running and Working correct. What I do is that I call the Asterisk System over Landline or SIP and that system would playback the WAV File I recorded, if the played back DTMF Sequence matches what I expect, everything is ok, if not then I would alarm the admin of that system.
I cant use SendDTMF in the dialplan since this test wouldn’t be quite accurate. I need to now if the AGI is also running and the simplest way to do this would be by playing back a file where I have recorded the DTMF sequence.
Now my problem is that it doesn’t quite work as expected. I have generated a wav file with a perl script I found here:
If I call myself on the cellphone it works, if I use senddtmf it works, so it can only be this wav file I recorded but I have no clue how I could do it so that it works.
Anybody got a hint for me ?

I’m not clear of the path for the cellphone. You didn’t say what was going wrong.

On a SIP system, audio recordings of DTMF will only work reliably if you are using a simple codec, like G.711. If you use a speech only codec, like GSM or G.729, the resulting DTMF is likely to be unusable.

Assuming that you use the info or rfc2833 options, SendDTMF doesn’t generate DTMF withing Asterisk, but just sends a message that causes DTMF to be generated at the PSTN boundary, on the analogue interface card, or in the phone. Mobile phones also don’t send the tones; they are actually generated by the Mobile Switching Centre.

ok let’s forget about the cell phone. The cell phone was just for testing if my DTMF recognition works and it worked.
I might have confused with the landline example. I actual make a SIP call to a carrier which then calls to my pstn.
But I could also do a direct sIP call to the other Asterisk server.
The codec used is alaw and dtmfmode is set to rfc2833
Is it even possible to record the DTMF sequence as wav and then pay it back ?

alaw is G.711, so should work, unless something downstream uses another codec or filters out in band DTMF.

There is a correction given in the comments. I’m not sure if it is for the original script, or one of the alternative programs.

The code is generating 8 bit linear, which is probably good enough, but won’t be as accurate as using 16 bit linear, or 8 bit A-law.

What does it sound like?

For me it sounds “good” but I can’t tell what asterisk thinks it sounds like.
If you want, here is the file I used for testing:
This one is the original, non converted file.
I converted it with this command:
sox dtmf.wav -r 8000 -c 1 -s -w dtmf2.wav resample -ql