Playing an audio file during Dial() [SOLVED]

Hi,

I am a beginner Asterisk developer :open_mouth: .
I would like to know if there is a way to play an audio file during a call started with Dial() application.
My first attempt was to use Dial() with A(x) option in this way:

[InternalRecord]
exten => 1000,1,Dial(DAHDI/1/number_to_call,20,A(audiofile1))

but it dials the number_to_call without playing audiofile1.

The second attempt was to use PlayBack() in this way:

[InternalRecord]
exten => 1000,1,Dial(DAHDI/1/number_to_call,20)
exten => 1000,2,PlayBack(audiofile1)

but Dial() does not return if the called party off hook the phone (starting the call), so PlayBack() never starts while Dial() is “running”.

Can someone help me…? :blush:
Thanks in advance!!

I’m running CentOS 6 with Asterisk 1.8.24 and I’m using a TDM410 card with 2 FXO modules (channels 1 and 2) and 2 FXS modules (channels 3 and 4).

Your first method, assuming the file exists in the right place, can be used to play something to just the called party, between when they answer and connecting the speech path. The second will only play the sound after the call fails.

My impression is that you are trying to achieve non-standard behaviour, and are doing something that requres well beyond newbie skill levels.

If you want to play sound continuously during the call (almost certainly annoying to both parties) you will probably have to use the whisper mechanism or create a conference. Have look at the discussion for people trying to play music after the first digit during dialing.

Also please note that the right forum for support questions is Asterisk Support.

Hi,

thank you for your support and sorry for my post in the wrong section.

My goal is to test the quality of PSTN line playing an audio file from the calling party, recording it on the called party and later compare the two signals with an external software. So I’m going to use MixMonitor application (is it right??) before call start for recording, but I’m not able to play the desired audio file for line testing.

If this is not possible, can I use the Originate application in the following way?

In file /var/spool/asterisk/outgoing/SimpleCall.call:

Channel: DAHDI/1/number_to_call
MaxRetries: 5
RetryTime: 30
WaitTime: 30
Application: Playback
Data: myaudiofile

In the DialPlan:

[TestOutgoing]
exten => 100,1,Answer

And then in Asterisk CLI:

originate DAHDI/1/number_to_call extension 100@TestOutgoing

Actually, this procedure does not seem to work, but I’m not sure about the syntax. Anyway, this can be a possible way to go on?

Thanks!

So you are not using Dial() at all!

You seem to have configuration for two different ways of originating a call (call file and CLI originate).

An extension consisting just of Answer will answer the call and then, immediately drop it.

Yes, but I use them alternatively.

I’m searching a way to automatically play an audio file from the calling party, DURING the call.

Do you know if there is a way to do that with Originate -or others- application ?

Playing a file to the called party is fairly easy (it is often done for phone spam) and your call file should do that.

Playing a file in parallel with other activity on a call is more difficult and you should look at the DTMF postings already mentioned.

I am getting confused as to which of these you are trying to do. Your descriptiion of your test doesn’t require what I would call playing during a call, but only the first case, i.e. the dump an advert on the answering machine mode.

Note you may require quite complex comparison software. Some parts of modern phone systems, particularly mobile networks and VoIP don’t try and reproduce the original waveform, but just something recognizable as the original spoken words. For that part of the distortion comparisons are actually made with panels of human listeners, not by machines.

Sorry for my bad explanation :mrgreen:

I just have to play my audio file at the establishment of the call, so when the called party hook off the phone. My goal is to dump an “advert” on the answering machine mode as you said. I don’t need any DTMF tone.

You said that playing a file to the called party is fairly easy, but how can I do that? I’m rather confused. :open_mouth:

As regards file comparison I already have a software.

Thank you again!!

Your call file should do it.

I’ve finally solved my problem in the way you said, so using .call file:

In .call file:

Channel: DAHDI/1/number_to_call
MaxRetries: 5
RetryTime: 30
WaitTime: 30
Context: TestOutgoing
Extension: 100

And my DialPlan is:

[TestOutgoing]
exten => 100,1,Wait(15)
exten => 100,n,Playback(myAudioFile)
exten => 100,n,Wait(2)
exten => 100,n,Hangup()

In this way, Asterisk starts a call to number_to_call, than DialPlan is executed with audio file playback correctly accomplished.

Thanks