Stream audio .wav file from S3

I’d like to reproduce S3 .wav audio files in my Dash application. At this moment, locally the files can be reproduced properly from my dashboard using html.Audio(id="audio", src=f"assets/{file_name}", controls=True), this assumes you have physically the files and are located on assets folder. I don’t want to store the files, because the number can go to thousands, so I’d like to stream the files from S3 every time is needed.

Another thing is that the S3 bucket is protected, so I cannot do html.Audio(id="audio", src="/url-s3-bucket/audio.wav", controls=True).

How can I reproduce the audios under these conditions?, any suggestions?

sending it as base 64encoding
Im doing something similar where Im trimming audio from a big audio file (I want to save the large file in an S3 bucket but working on functionality first). To play the clip using pydub AudioSegment its need to be converted to base64 string. Its being exported as a wav file but not saved to any directory then i turn it to a base64 encoded string and add that ‘data:audio…’.

if you can just open the file and read it this should help shrug good luck

convert_file = clip[start:end].export(format=“wav”)
out = base64.b64encode(convert_file.read()).decode(‘ascii’)
out = ‘data:audio/wav;base64,’ + out