k2kobayashi/Shifter

bug in transform(......)

xiaoqiang-ok opened this issue · 2 comments

I got a corruption when using function: f0trans.transform(....)

mycode is like below:

def changePitch(pitch_r, sample_data, sample_rate=16000):
    # F0 transoformation based on WSOLA and resampling
    f0trans = Shifter(sample_rate, pitch_r, frame_ms=20, shift_ms=10)
    transformed = f0trans.transform(sample_data)
    return transformed

--size of sample_data is 416600,pitch_r is 0.9

Error message:
Traceback (most recent call last):
File "audio_process.py", line 269, in
data = audio_process.changePitch(pitch_ratio, data, sample_rate)
File "audio_process.py", line 230, in changePitch
transformed = f0trans.transform(sample_data)
File "audio_process.py", line 59, in transform
wsolaed = self.duration_modification(data)
File "audio_process.py", line 112, in duration_modification
wsolaed[outp:outp + self.sl] = spdata + epdata
ValueError: could not broadcast input array from shape (160) into shape (60)

wsolaed[outp:outp + self.sl] = spdata + epdata #here outp + self.sl may exceed the size of array wsolaed

I found length of wsolaed is 374940,but outp= 374880, self.sl=160
outp + self.sl = 375040 which is bigger than array size of wsolaed

if (outp + self.sl) > len(wsolaed): break;#add this line in function duration_modification(......) to solve this bug
wsolaed[outp:outp + self.sl] = spdata + epdata