Skip to content
New issue

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

TypeError at use of make_spectrogram #66

Closed
filipthor opened this issue Dec 23, 2019 · 3 comments
Closed

TypeError at use of make_spectrogram #66

filipthor opened this issue Dec 23, 2019 · 3 comments

Comments

@filipthor
Copy link

As the title reads, I have hit a bit of a snub trying the code out.

Trying to run the code:
import thinkdsp

wave = thinkdsp.read_wave('100475__iluppai__saxophone-weep.wav')
spectrogram = wave.make_spectrogram(seg_length=512)
spectrogram.plot(high=700)

on Python 3.6, resulting in:
Traceback (most recent call last):
...
File "/Users/filipthor/PycharmProjects/music/main.py", line 9, in
spectrogram = wave.make_spectrogram(seg_length=512)
File "/Users/filipthor/anaconda/lib/python3.6/site-packages/thinkdsp.py", line 943, in make_spectrogram
segment = self.slice(i, j)
File "/Users/filipthor/anaconda/lib/python3.6/site-packages/thinkdsp.py", line 897, in slice
ys = self.ys[i:j].copy()
TypeError: slice indices must be integers or None or have an index method

Any ideas?

@filipthor
Copy link
Author

"ugly-fixed" it by wrapping i and j with int(), which seems to work

@AllenDowney
Copy link
Owner

In the current version,

        step = int(seg_length // 2)

so i and j should already be ints.

Maybe you have an older version of thinkdsp.py?

@AllenDowney
Copy link
Owner

I just ran a test with current version and all is well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants