Generate Media Element After Script Runs

I was hoping I could get a little direction here. Thanks in advance.

I have a Streamlit form working properly that is triggering some scripts that generate an audio file. I would like to be able to use and display st.audio() with the generated URL that only exists after the scripts are run.

Does anyone have an example they could show or point me to that can do this? I’m guessing it would have to do with state, but I’m not exactly sure the best way to do this. Thanks!

I guess I am misunderstanding your question.

st.audio(URL)

Yes, but URL does not exist until after the form runs, and there is an error if URL doesn’t exist yet.

Moreover, I have to pass the value of URL from the scripts back into the Streamlit UI page and I was hoping there was an easier way that a succession of callbacks.

Call st.audio after the form has run.

That depends on how the scripts work.