wav icon indicating copy to clipboard operation
wav copied to clipboard

Support converting in memory bytes?

Open LeiYangGH opened this issue 6 years ago • 2 comments

I tried the converting from pcm to wav file and succeeded. However in my go server I want to reduce disk IO becasue all my data are []bytes in memory(my server can generate pcm bytes by some TTS server and will serve as wav bytes for user to download). NewEncoder function can only accept io.WriteSeeker, and I found a walkaround in stackoverflow to use a in memory one. However I think this walkaround is not elegant nor stable.

So could you consider add such in memory only convertion?

LeiYangGH avatar Oct 30 '19 03:10 LeiYangGH

I'm honestly not too sure how to offer a transparent way to do that since the seeking is needed to finish writing the header of the file. However, as a potential alternative, consider using this package I wrote for this exact use case (short audio files that could stay in memory) https://github.com/mattetti/filebuffer

mattetti avatar Oct 30 '19 03:10 mattetti

thanks! I'll use it. seems it has more stars than https://github.com/orcaman/writerseeker(from above SO comment)

LeiYangGH avatar Oct 30 '19 05:10 LeiYangGH