I am building a gradio app to play multiple audio files in sequence with a delay of 2 seconds. I am using stop listener in a way that when one audio file ends, Stop listener gets triggered and another audio file start playing in autoplay mode.
The issue is, it stops working after second audio file and doesn’t give any error or exception. ChatGPT refers using javascript code.
import gradio as gr
speaker_idx = gr.State(0)
files = ["audios/speech1.mp3","audios/speech2.wav","audios/speech.mp3","audios/speech.mp3"]
render_audio_component = gr.Audio(label="speaking",autoplay=True,value = "audios/speech0.mp3")
def continue_audio(speaker_idx):
speaker_idx +=1
#time.sleep(2)
return files[speaker_idx]
render_audio_component.stop(continue_audio,inputs = speaker_idx,outputs=render_audio_component)