I have a python script in which I get bytes corresponding to an audio (I make an API call to another program which returns audio bytes in wav format). I want to do some signal processing using numpy on this audio. Currently I am writing the bytes to a file and loading the wav file back using librosa. But due to the intermediate disk I/O, there is latency. Can I get ndarray from these audio bytes without writing to a file? Below is my code in which I write to a file and read ndarray
def func1():
audioBytes = api_call_to_another_program()
fp = open("tmp.wav", "wb")
fp.write(audioBytes)
return path
def func2(path, sample_rate=someNumber):
myNdArray = librosa.core.load(path, sr=sample_rate)[0]
# some signal processing stuff..
I want something like this
def func1():
audioBytes = api_call_to_another_program()
interRep = someFunction(audioBytes) # an intermediate representation for compressing the data a bit
return interRep
def func2(interRep):
myNdArray = inverseOfSomeFunction(interRep)
# some signal processing stuff..