Use stream_file to play in agi and then stop playing audio after five seconds

Hello, can anyone help me
How do I stop playing audio after playing it in agi

exten => _X.,1,NoOp(ii-oo Incoming call from Dongle to ${EXTEN})
;same => n,Set(CALLERID(name)=Dongle)
same => n,Answer()
same => n,AGI(audio_test.py)
same => n,Hangup()

If you use agi.control_stream_file to play audio in audio_test.py, and stop playing after five seconds, what command do you send

Send agi.send_command(‘EXEC SendDTMF 1’) command. SendDTMF is executed only after the audio is played

play audio is blocking. You need to create a 5 second file. from the original file, before you call it.

Thank you for your reply, this five seconds is just a hypothetical value, what I have to do is
1: call the other person and play the audio
2: In the process of playing, according to the other party’s speech, judge the other party’s idea (please note that this is not the other party’s button)
to judge whether it is necessary to interrupt the playback, and then play the next audio,

so I need to know how to play audio in agi, and be able to interrupt the current audio at any time,How do you write it in agi

If you want to be able to be able to cut off the audio playback external to Asterisk, one technique would be to feed the audio to Asterisk via a pipe. Then you stop audio playback by simply terminating the pipe feeder process.

Thank you for your reply.
would be to feed the audio to Asterisk via a pipe? What does that mean,

How do I pipe audio to asterisk?

audio_file = “en/custom/audio1”
result = agi.stream_file(audio_file)
I’m sorry, but I’m not quite sure about some nouns,This way, is it?

https://man7.org/linux/man-pages/man2/pipe.2.html

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.