The AGI script is executing the requests before finishing the audio, I don’t want that.
Is it possible to execute the requests line only after I finish playing the Playback?
Don’t send requests blind. AGI scripts should read out the initial AGI parameters and should also read out every response, as it arrives.
There is actually a small risk of a deadlock if don’t do this, as it is possible for the responses to back up to the point where flow control stalls them, in which case the AGI application cannot read further requests. Also you can get broken pipe errors, if you don’t read out responses properly.
You could try my seaskirt module for Python. It offers both synchronous and asynchronous interfaces to AGI, and also FastAGI. And there is also “Async AGI”, which means you send AGI requests via AMI.