mrkrd / cochlea

Inner ear models for Python
GNU General Public License v3.0
108 stars 42 forks source link

example does not work #7

Closed xiaokebubu closed 6 years ago

xiaokebubu commented 6 years ago

I installed cochlea-master on Windows 8 with Anaconda(python2.7 64-bit). It works successfully in jupyter notebook to processing a generated sound as shown in usage website. Then I am trying to run the example by using a sound file but there is something wrong.

C:\Users\Alice\Desktop\cochlea-master\cochlea-master\scripts>python run_zilany2014 --hsr=100 --msr=75 --lsr=25 --cf=1000 --species=human --seed=0 --dbspl=60 tone.wav Processing tone.wav Traceback (most recent call last): File "run_zilany2014", line 162, in main(args) File "run_zilany2014", line 155, in main space File "run_zilany2014", line 108, in convert_sound_to_mat_unpack convert_sound_to_mat(**args) File "run_zilany2014", line 72, in convert_sound_to_mat sound_raw = wv.resample(sound_raw, int(f.samplerate), int(fs)) File "C:\ProgramData\Anaconda3\envs\py27\lib\site-packages\thorns\waves.py", l ine 100, in resample new_signal = dsp.resample(signal, len(signal)*new_fs/fs) File "C:\ProgramData\Anaconda3\envs\py27\lib\site-packages\scipy\signal\signal tools.py", line 2203, in resample Y = zeros(newshape, 'D') TypeError: 'float' object cannot be interpreted as an index I tried to transform the datatype into int waves.py 100: new_signal = dsp.resample(signal, len(signal)*new_fs/fs) replaced by: new_signal = dsp.resample(signal, int(len(signal)*new_fs/fs)) but then there were some other asserting problems. (like "assert sound.ndim == 1". I checked my data, in which the sound.ndim=2). I am new to python and I 'm not sure why this may be. Could you help me with it?
mrkrd commented 6 years ago

Hi! Thanks for the bug report in the resample(). I've fixed it in the repository of thorns.

but then there were some other asserting problems. (like "assert sound.ndim == 1". I checked my data, in which the sound.ndim=2).

I am new to python and I 'm not sure why this may be. Could you help me with it?

So run_zilany2014() is a model of a single ear, i.e., it expects one dimensional signal as input. I guess that you are using a wave file with 2 channels (stereo). If you convert it to mono, it should work.

xiaokebubu commented 6 years ago

Problem solved! Thanks very much for your help : ).