ml4a / ml4a-ofx

A collection of openFrameworks apps for working with machine learning
http://ml4a.github.io
1.22k stars 279 forks source link

Errors using scripts/tSNE-audio.py #49

Open FunctionalJerk opened 11 months ago

FunctionalJerk commented 11 months ago

I was trying to recreate the projects that I realized last year with the help of this script, found several issues and managed to solve them:

In line 42 and line 63 I added the sample rate argument, otherwise librosa.load() defaults to 22050Hz.:

y, sr = librosa.load(source_audio, sr=None)

I also had to change line 69 to:

tsne = TSNE(n_components=tsne_dimensions, learning_rate=200, perplexity=tsne_perplexity, verbose=2, angle=0.1).fit_transform(np.array([f["features"] for f in feature_vectors]))

Before I was getting an Error hinting at the fact that fit_transform isn't given the numpy-array that it expects:

    File ~/.local/lib/python3.10/site-packages/sklearn/manifold/_t_sne.py:821
    if self.perplexity >= X.shape[0]:
    ^
    AttributeError: 'list' object has no attribute 'shape'

I'm on Python 3.10.12, with librosa==0.10.1 scikit-learn==1.3.2