How turn a torch audio to binary wav without saving to disk

I need to send some audio I use a torch based text to speech to generate as a JSON. I cannot find a way to turn it into a base64 without the following awful code:

torchaudio.save('C:/Work/test_images/temp.wav', wav_array, sampling_rate)
wav_file = open('C:/Work/test_images/temp.wav', 'rb')

any ideas how to clean this up? there doesn’t appear to be any built-in functions with torch to do this, but I’m fairly new so would appreciate any help.

I’m not deeply familiar with torchaudio, but would it be possible to use an io.BytesIO object for temporal storage instead of a file work?