Zulko / pianoputer

Use your computer keyboard as a "piano".
http://zulko.github.io/blog/2014/03/29/soundstretching-and-pitch-shifting-in-python/
Other
324 stars 92 forks source link

Unable to Transpond Sound File #7

Closed MustafaHaddara closed 6 years ago

MustafaHaddara commented 7 years ago

Tried running this on macOS 10.12.3, python 2.7.13, scipy 0.18.1, numpy 1.12.0, pygame 1.9.3

Got the following error:

$ python pianoputer.py 
Transponding sound file... Traceback (most recent call last):
  File "pianoputer.py", line 126, in <module>
    main()
  File "pianoputer.py", line 90, in main
    transposed_sounds = [pitchshift(sound, n) for n in tones]
  File "pianoputer.py", line 49, in pitchshift
    stretched = stretch(snd_array, 1.0/factor, window_size, h)
  File "pianoputer.py", line 22, in stretch
    result = np.zeros(len(snd_array) / factor + window_size)
TypeError: 'float' object cannot be interpreted as an index
wupanhao commented 6 years ago

line22 :result = np.zeros(int(len(snd_array) / factor + window_size)) line37:

i = int(i)        
i2 = int(i/factor)

and that's worked for me

Zulko commented 6 years ago

should be fixed thanks to @dudektria