tuanad121 / Python-WORLD

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ValueError

nairaanish opened this issue · comments

I am getting this error every time I try
ValueError: operands could not be broadcast together with shapes (144,) (2,). the code is as follows:

from scipy.io.wavfile import read as wavread
wav_path = '/content/thats-okay-1.wav'
fs, x_int16 = wavread(wav_path)
x = x_int16 / (2 ** 15 - 1)
from world import main
vocoder = main.World()

analysis

dat = vocoder.encode(fs, x,f0_method ='harvest')# f0_method='harvest', is_requiem=False)

can I have your audio file? It would be very helpful

Here's the audio file
thats-okay-1.wav.zip

Ah, yes. The file has 2 channels. Can you try this again:
dat = vocoder.encode(fs, x[0], f0_method ='harvest')
Here we choose 1 channel with x[0].
Let's see if it's ok. Thanks

Getting the following error now

IndexError Traceback (most recent call last)
in ()
1 vocoder = main.World()
2 # analysis
----> 3 dat = vocoder.encode(fs, x[0],f0_method ='harvest')

2 frames
/content/drive/My Drive/PyWORLD/world/harvest.py in OverlapF0Candidates(f0_candidates, max_candidates)
117 number_of_candidates = n * 2 + 1
118 new_f0_candidates = np.zeros((number_of_candidates * max_candidates, f0_candidates.shape[1]))
--> 119 new_f0_candidates[0, :] = f0_candidates[number_of_candidates - 1, :]
120 for i in np.arange(number_of_candidates):
121 st1 = max(-(i - n) + 1, 1)

IndexError: index 0 is out of bounds for axis 0 with size 0

Oh, my mistake. To get one channel we have to do so:
data = vocoder.encode(fs, x[:,0], f0_method='harvest')
x[:,0] instead of x[0].
If you want another channel:
data = vocoder.encode(fs, x[:,1], f0_method='harvest')
Sorry about that.