Esempio n. 1
0
args = parser.parse_args()

"""
I'm going to take an example of slicing a Corpus to introduce you to the fundamentals of FTIS.
FTIS always starts with the creation of a "Corpus" and a "Process"
You will always import at the ftis.process.FTISProcess and ftis.corpus.Corpus to get these
Follow along with  the comments to see how this works.
"""

# We make a 'Corpus' object below by creating an instance of that object with a string to the location of our corpus
src = Corpus(args.input)
out = args.output  # we also set an output path, in FTIS speak a 'sink'.

# Now we make an instance of a FTIS process.
# This is where we set up the inputs and outputs of that FTISProcess, known as a 'source' and a 'sink'
world = World(sink=out)

# Once we have a FTISProcess (process is the variable name here) we add 'analysers' to that process
# You can see the various analysers imported at the top of the page under the module space...
# ...ftis.analyser followed by .category.

# To find other analysers see the complete list in the documentation.

# To add analysers, we simply pass the class along with its parameters to the process.add() function.
# This will connect those process in series, passing their outputs to the next analyser in the chain.
src >> FluidNoveltyslice(kernelsize=5) >> ExplodeAudio()
world.build(src)

# Lastly we call process.run(). We should always call it inside the __name__ == "__main__" block
# Why? We use multiprocessing to speed things up under the hood and running outside this results in errors.
if __name__ == "__main__":
Esempio n. 2
0
)
parser.add_argument(
    "-o",
    "--output",
    default="~/corpus-folder/corpus-management",
    type=str,
    help="Folder for output. This will be made if it doesnt exist.",
)
args = parser.parse_args()
"""
Corpus objects overload the addition operator.
This allows you to add Corpus objects together to create a new Corpus from their materials.
"""

em = Corpus(args.corpusone)  # first corpus
db = Corpus(args.corpustwo)  # second corpus
corpus = em + db  # compose a corpus of both sub-corpora

# adding two Corpus() objects together modifies their contents
# em + db is NOT the same as db + em, unless you are assigning the output
# If you want to add the contents of db to em, you would need to structure it...
# ```em + db```
# and use em as the 'source' for the FTISProcess

world = World(sink=args.output)
corpus >> FluidMFCC()
world.build(corpus)

if __name__ == "__main__":
    world.run()
Esempio n. 3
0
from ftis.analyser.stats import Stats
from ftis.analyser.clustering import AgglomerativeClustering
from ftis.analyser.audio import CollapseAudio
from ftis.world import World
from ftis.corpus import Corpus
from ftis.common.io import get_sr, get_duration
from pathlib import Path

# instantiate
sink = "~/reaperising-ftis-2"
c = Corpus("~/Documents/Max 8/Packages/TB2-Alpha06-MacOS-Max/media")
clustering = AgglomerativeClustering(numclusters=3)

# script connection
c >> CollapseAudio() >> FluidMFCC() >> Stats() >> clustering
w = World(sink=sink)
w.build(c)
if __name__ == "__main__":
    w.run()

    # #---------- Data for render_tracks would look something like this ----------#
    # # data = {
    # #    "track1" : [
    # #        {"file" : None, "length": 1.0, "start": 0.0, "position": 0.0}
    # #    ],
    # #    "track2" : [
    # #        {"file" : None, "length": 1.0, "start": 0.0, "position": 0.0}
    # #    ]
    # # }
    # #---------------------------------------------------------------------------#
Esempio n. 4
0
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("~/corpus-folder/corpus2")
nov = FluidNoveltyslice(threshold=0.2, minslicelength=2, cache=True)
# if we dont set the minslicelength to 2 then we might generate slices too short for the analysis
seg = ClusteredSegmentation(cache=True)

c >> nov >> seg

w = World(sink="~/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 = {
Esempio n. 5
0
    "-i",
    "--input",
    default="~/corpus-folder/corpus1",
    type=str,
    help="Folder for input. This should contain some audio files.",
)
parser.add_argument(
    "-o",
    "--output",
    default="~/corpus-folder/spec-decomposition",
    type=str,
    help="Folder for output. This will be made if it doesnt exist.",
)
args = parser.parse_args()

src = Corpus(args.input)
out = args.output

process = Chain(source=src, sink=out)

process.add(
    ClusteredNMF(
        min_cluster_size=2,
        min_samples=1,
        cluster_selection_method="leaf",
        components=10,
    ))

if __name__ == "__main__":
    process.run()
Esempio n. 6
0
from ftis.corpus import Corpus
import argparse

parser = argparse.ArgumentParser(
    description="Process input and output location")
parser.add_argument(
    "-i",
    "--input",
    default="~/corpus-folder/corpus1",
    type=str,
    help="Folder for input. This should contain some audio files.",
)
parser.add_argument(
    "-o",
    "--output",
    default="~/corpus-folder/flux",
    type=str,
    help="Folder for output. This will be made if it doesnt exist.",
)
args = parser.parse_args()

src = Corpus(args.input)
out = args.output

process = World(source=src, sink=out)

process.add(CollapseAudio(), Flux())

if __name__ == "__main__":
    process.run()
Esempio n. 7
0
corpus = Corpus("~/corpus-folder/corpus1")
collapse = CollapseAudio()
pitch = FluidPitch(fftsettings=[1024, 512, 1024])
pitch_stats = Stats(spec=["median"])
loudness = FluidLoudness(windowsize=1024, hopsize=512)
loudness_stats = Stats(spec=["mean"])


def mask_with_loudness(self):
    for k, v in loudness_stats.output.items():
        mean = v[0]
        for i, (x, y) in enumerate(loudness.output.items()):
            dbfs = y[0]
            if sum(dbfs) / len(dbfs) < mean:
                del self.output[k][0][i]
                del self.output[k][1][i]


pitch.post = mask_with_loudness

# script the connections
corpus >> collapse
collapse >> loudness >> loudness_stats
collapse >> pitch >> pitch_stats

# setup the world
world = World(sink="~/corpus-folder/overloading")

if __name__ == "__main__":
    # add our corpus node to the world
    world.add(corpus)
Esempio n. 8
0
args = parser.parse_args()

"""
FTIS implements sink level caching when you run processes.
FTIS always makes files in the output folder containing data such as slices, descriptors etc. 
If the order of analysers doesnt change in a process and the inputs haven't been modified in anyway...
...repeated runs can be sped up by simply reading the files from disk rather than re-running analysis
Caching by default is set to true and is specified at the analyser level.
This means you can switch it off for specific processes which you need to run from scratch.
Try running this script twice in your terminal to watch the speed increase.
"""

src = Corpus(args.input)
out = args.output

process = World(sink=out)

# we can also instantiate analysers as instances of their classes
# In this scenario using an anonymous class isn't very different but we might want to access the outputs of each analyser after the process has finished

flux = Flux(
    cache=1, windowsize=2048
)  # rerunning the script will load flux from cache where the parameters are the same between runs
stats = Stats(numderivs=1, cache=True)

src >> flux >> stats 

process.build(src)

if __name__ == "__main__":
    process.run()
Esempio n. 9
0
from ftis.analyser.audio import CollapseAudio
from ftis.corpus import Corpus
from ftis.world import World
import argparse

parser = argparse.ArgumentParser(
    description="Process input and output location")
parser.add_argument(
    "-i",
    "--input",
    default="~/corpus-folder/corpus1",
    type=str,
    help="Folder for input. This should contain some audio files.",
)
parser.add_argument(
    "-o",
    "--output",
    default="~/corpus-folder/collapse",
    type=str,
    help="Folder for output. This will be made if it doesnt exist.",
)
args = parser.parse_args()

process = World(source=Corpus(args.input), sink=args.output)

process.add(CollapseAudio())

if __name__ == "__main__":
    process.run()
Esempio n. 10
0
from ftis.analyser.stats import Stats
from pathlib import Path

corpus = Corpus("~/corpus-folder/corpus1")
collapse = CollapseAudio()
pitch = FluidPitch(fftsettings=[1024, 512, 1024], cache=True)
stats = Stats()


def mask_by_confidence(self):
    for k, v in self.output.items():
        freq = v[0]  # list of frequencies
        conf = v[1]  # list of confidences
        for i, c in enumerate(conf):
            if c < 0.90:
                del self.output[k][0][i]
                del self.output[k][1][i]


pitch.post = mask_by_confidence

# script the connections
corpus >> collapse
collapse >> pitch >> stats

# setup the world
world = World(sink="~/corpus-folder/overloading2", quiet=True)
world.build(corpus)

if __name__ == "__main__":
    world.run()
Esempio n. 11
0
def test_instantiation():
    test = World(test_yaml)
    assert test.config_path == test_yaml
Esempio n. 12
0
    '--input',
    default="~/corpus-folder/corpus1",
    type=str,
    help="Folder for input. This should contain some audio files.")
parser.add_argument(
    '-o',
    '--output',
    default="~/corpus-folder/lambdas",
    type=str,
    help='Folder for output. This will be made if it doesnt exist.')
args = parser.parse_args()
"""
We can pre and process data in place, rather than having to create new analysers to process input and output data.
This functionality is inherited from the base analyser class, so everything can do it, you just need to implement what you want to do.
In this example, I simply reset the values in the output of the FluidLoudness() class after processing
"""

out = args.output
world = World(sink=out)


def remove_truepeak(self):
    self.output = {k: v[0] for k, v in self.output.items()}


corpus = Corpus(args.input)
corpus >> CollapseAudio() >> FluidLoudness(post=remove_truepeak)
world.build(corpus)

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