jamesb93 / ftis

[F]inding [T]hings [I]n [S]tuff
BSD 3-Clause "New" or "Revised" License
12 stars 2 forks source link

clusteredSegmentation is broken #7

Open tremblap opened 3 years ago

tremblap commented 3 years ago

commit f2945963d

trying it with a valid file, works for the FluidNoveltySlice but then aborts:

Traceback (most recent call last): File "clustered_segmentation.py", line 21, in w.run() File "/Users/pa/Documents/documents@hudd/research/projects/fluid corpus navigation/research/ftis/ftis/ftis/world.py", line 109, in run c.walk_chain() File "/Users/pa/Documents/documents@hudd/research/projects/fluid corpus navigation/research/ftis/ftis/ftis/corpus.py", line 47, in walk_chain forward_connection.walk_chain() File "/Users/pa/Documents/documents@hudd/research/projects/fluid corpus navigation/research/ftis/ftis/ftis/common/analyser.py", line 167, in walk_chain forward_connection.walk_chain() File "/Users/pa/Documents/documents@hudd/research/projects/fluid corpus navigation/research/ftis/ftis/ftis/common/analyser.py", line 151, in walk_chain self.run() File "/Users/pa/Documents/documents@hudd/research/projects/fluid corpus navigation/research/ftis/ftis/ftis/analyser/meta.py", line 144, in run singleproc(self.name, self.analyse, self.input) File "/Users/pa/Documents/documents@hudd/research/projects/fluid corpus navigation/research/ftis/ftis/ftis/common/proc.py", line 28, in singleproc process(x) File "/Users/pa/Documents/documents@hudd/research/projects/fluid corpus navigation/research/ftis/ftis/ftis/analyser/meta.py", line 116, in analyse mfccs = fluid.mfcc( File "/Users/pa/anaconda/envs/ftis4dummies/lib/python3.8/site-packages/flucoma/fluid.py", line 469, in mfcc fftsettings = fftsanitise(fftsettings) File "/Users/pa/anaconda/envs/ftis4dummies/lib/python3.8/site-packages/flucoma/utils.py", line 15, in fftsanitise int(fftsettings[2]) IndexError: list index out of range

jamesb93 commented 3 years ago

Hi PA,

It looks like fftsettings for the mfcc() function are not able to be sanitised because it expects to get 3 values as a list and it cannot index the last value.

Can you post the script here for reference?

tremblap commented 3 years ago

This is fun, since I am not changing them at all...

from ftis.world import World
from ftis.corpus import Corpus
from ftis.analyser.meta import ClusteredSegmentation
from ftis.analyser.slicing import FluidNoveltyslice
from ftis.adapter.reaper import render_tracks
from ftis.common.io import get_sr
from pathlib import Path

c = Corpus("/Volumes/machins/projets/newsfeed/sons/textes/Audio/synth/fromtexttospeech-AmE-George.wav")
nov = FluidNoveltyslice(threshold=0.05, minslicelength=1, fftsettings=[1024,128,1024], filtersize=5, kernelsize=29)
# if we dont set the minslicelength to 2 then we might generate slices too short for the analysis 
seg = ClusteredSegmentation()

c >> nov >> seg

w = World(sink="~/Desktop/clustered_segmentation")
w.build(c)

if __name__ == "__main__":
    w.run()

    tracks = {}
    for media, slices in seg.output.items():
        pos = 0
        sr = get_sr(media)
        items = []
        for start, end in zip(slices, slices[1:]):
            start /= sr
            end /= sr

            item = {
                "file" : media,
                "length" : end - start,
                "start" : start,
                "position" : pos
            }

            pos += end - start

            items.append(item)

        tracks[media] = items

    render_tracks(
        Path("~/Desktop/clustered_segmentation/clustered_slices.rpp").expanduser(), 
        data = tracks
    )
jamesb93 commented 3 years ago

Okay, I do remember we edited the FTIS class ClusteredSegmentation() though so could you dig into that class definition and see what the internal MFCC fftsettings are?

tremblap commented 3 years ago

I deleted the edits, this is a new env and a new pull. So the internals are as is in the commit:

fftsettings=[1024, -1 -1]

jamesb93 commented 3 years ago

Gotchya, I shall investigate and report back

jamesb93 commented 3 years ago

It is a missing comma. Fixed (I think). Can you test? dcd9f1f168dc3844fdf7dd612ffa54ddd5b88d17

tremblap commented 3 years ago

not working despite the comma, but a new bug:

Traceback (most recent call last):
  File "clustered_segmentation.py", line 21, in <module>
    w.run()
  File "/Users/pa/Documents/documents@hudd/research/projects/fluid corpus navigation/research/ftis/ftis/ftis/world.py", line 109, in run
    c.walk_chain()
  File "/Users/pa/Documents/documents@hudd/research/projects/fluid corpus navigation/research/ftis/ftis/ftis/corpus.py", line 47, in walk_chain
    forward_connection.walk_chain()
  File "/Users/pa/Documents/documents@hudd/research/projects/fluid corpus navigation/research/ftis/ftis/ftis/common/analyser.py", line 167, in walk_chain
    forward_connection.walk_chain()
  File "/Users/pa/Documents/documents@hudd/research/projects/fluid corpus navigation/research/ftis/ftis/ftis/common/analyser.py", line 151, in walk_chain
    self.run()
  File "/Users/pa/Documents/documents@hudd/research/projects/fluid corpus navigation/research/ftis/ftis/ftis/analyser/meta.py", line 144, in run
    singleproc(self.name, self.analyse, self.input)
  File "/Users/pa/Documents/documents@hudd/research/projects/fluid corpus navigation/research/ftis/ftis/ftis/common/proc.py", line 28, in singleproc
    process(x)
  File "/Users/pa/Documents/documents@hudd/research/projects/fluid corpus navigation/research/ftis/ftis/ftis/analyser/meta.py", line 123, in analyse
    stats = get_buffer(fluid.stats(mfccs, numderivs=self.numderivs), "numpy")
AttributeError: 'ClusteredSegmentation' object has no attribute 'numderivs'
tremblap commented 3 years ago

but I solved it, line 91

jamesb93 commented 3 years ago

Okay, thanks. That is also pushed to: 7fe83d124a1ca9b3748002e8c8258105c1398e3f

As you can see these classes are not great for extending 👎 and their interface sucks quite a lot but thanks for sticking with it