[SciPy-Dev] scipy.io.wavfile to read byte array directly?
Miles
milesdowe at gmail.com
Sun Sep 11 14:52:11 EDT 2016
Joseph, Ralf,
Thank you both for your responses! I'm still very much new and
unfamiliar with Python and it's libraries, so I appreciate your quick
and courteous replies.
The BytesIO library was exactly what I needed. I was able to load the
WAV byte array data into scipy using that as a wrapper.
If it's of any interest, my code roughly looked like this:
```
import boto3
import scipy.io.wavfile as sciwav
from io import BytesIO
s3 = boto3.resource('s3')
#access bucket, get WAV data (i.e., b'RIFF\x86x.\x01WAVEfmt ...')
object = s3.Object(bucket_name, key)
result = object.get()['Body'].read()
# wrap data and submit
wrapper = BytesIO(result)
wav_file = sciwav.read(wrapper)
```
I will also go back and review the documentation regarding using
file-like objects and can add those details.
Thank you again,
Miles
More information about the SciPy-Dev
mailing list