beetbox / audioread

cross-library (GStreamer + Core Audio + MAD + FFmpeg) audio decoding for Python
MIT License
481 stars 108 forks source link

TypeError: expected str, bytes or os.PathLike object, not SpooledTemporaryFile #74

Closed Shivamagrawal2014 closed 5 years ago

Shivamagrawal2014 commented 5 years ago

Hi, I am trying to load my byte data that is in binary format into audioread.audio_open, ideally I should directly give path for the audio file but I am trying to decode the mp3 after loading my audio file into tensorflow and there arises the issue.

Complete Trace Back is as Follows: `TypeError Traceback (most recent call last)

in () ----> 1 au = aio(buffer) c:\users\shivam.agarwal\pycharmprojects\audioapi\venv\lib\site-packages\audioread\__init__.py in audio_open(path) 78 from . import rawread 79 try: ---> 80 return rawread.RawAudioFile(path) 81 except DecodeError: 82 pass c:\users\shivam.agarwal\pycharmprojects\audioapi\venv\lib\site-packages\audioread\rawread.py in __init__(self, filename) 59 """ 60 def __init__(self, filename): ---> 61 self._fh = open(filename, 'rb') 62 63 try: ` I tried to load the bytes as file-like object from SpooledTemporaryFile but this open in 'rb' format keeps giving the issue. How should I load the bytes as file-like object ?
sampsyo commented 5 years ago

Hello! That's not currently possible; the library needs to read a file from the filesystem. You could write the data to a temporary file, for example.

See also https://github.com/beetbox/audioread/pull/37, an in-progress effort to support decoding audio data directly.