We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am getting a casting error when trying to run the afromb example:
/home/ubuntu/anaconda/lib/python2.7/site-packages/echonest/remix/audio.py in mix(dataA, dataB, mix) 824 else: 825 newdata = AudioData(ndarray=dataB.data, sampleRate=dataB.sampleRate, numChannels=dataB.numChannels, defer=False) --> 826 newdata.data *= 1 - float(mix) 827 newdata.data[:dataA.endindex] += dataA.data[:] * float(mix) 828 return newdata TypeError: Cannot cast ufunc multiply output from dtype('float64') to dtype('int16') with casting rule 'same_kind'
/home/ubuntu/anaconda/lib/python2.7/site-packages/echonest/remix/audio.py in mix(dataA, dataB, mix) 824 else: 825 newdata = AudioData(ndarray=dataB.data, sampleRate=dataB.sampleRate, numChannels=dataB.numChannels, defer=False) --> 826 newdata.data *= 1 - float(mix) 827 newdata.data[:dataA.endindex] += dataA.data[:] * float(mix) 828 return newdata
TypeError: Cannot cast ufunc multiply output from dtype('float64') to dtype('int16') with casting rule 'same_kind'
which looks very similar to the closed issue #13
I'm using an Anaconda Python 2.7 install which might contribute to the problem, though other examples work fine.
The text was updated successfully, but these errors were encountered:
I could fix it by changing the mix() function in audio.py. Not sure if this is very effective, but it works for me:
def mix(dataA, dataB, mix=0.5): """ Mixes two `AudioData` objects. Assumes they have the same sample rate and number of channels. Mix takes a float 0-1 and determines the relative mix of two audios. i.e., mix=0.9 yields greater presence of dataA in the final mix. """ if dataA.endindex > dataB.endindex: newdata = AudioData(ndarray=dataA.data, sampleRate=dataA.sampleRate, numChannels=dataA.numChannels, defer=False) tempdataA = newdata.data.astype(numpy.float64) tempdataA *= float(mix) tempdataB = dataB.data.astype(numpy.float64)[:] tempdataA[:dataB.endindex] += tempdataB * (1 - float(mix)) else: newdata = AudioData(ndarray=dataB.data, sampleRate=dataB.sampleRate, numChannels=dataB.numChannels, defer=False) tempdataA = newdata.data.astype(numpy.float64) tempdataA *= 1 - float(mix) tempdataB = dataA.data.astype(numpy.float64)[:] tempdataA[:dataA.endindex] += tempdataB * float(mix) newdata.data = tempdataA.astype(numpy.int16,casting='unsafe') return newdata
Sorry, something went wrong.
No branches or pull requests
I am getting a casting error when trying to run the afromb example:
which looks very similar to the closed issue #13
I'm using an Anaconda Python 2.7 install which might contribute to the problem, though other examples work fine.
The text was updated successfully, but these errors were encountered: