Beispiel #1
0
from ftis.analyser.descriptor import FluidMFCC
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}
    # #    ]
    # # }
    # #---------------------------------------------------------------------------#
Beispiel #2
0
    default="~/corpus-folder/fluid-dataset",
    type=str,
    help="Folder for output. This will be made if it doesnt exist.",
)
args = parser.parse_args()
"""
Using the python-flucoma package analyser outputs can be turned into datasets.
To do this we have to specifically create an instance of the analyser we are interested in.
After the FTISProcess has run we then extract the output from that instance.
"""

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

world = World(sink=out)

stats = Stats(numderivs=2,
              spec=["stddev", "mean"])  # create an instance of the stats class
src >> CollapseAudio() >> FluidMFCC() >> stats
world.build(src)

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

    # Now that ftis has completed lets pack the data into a fluid dataset
    dataset = dataset.pack(
        stats.output
    )  # use the pack function to marshall it to the right format
    dataset_path = Path(out) / "dataset.json"  # create an output path
    write_json(dataset_path.expanduser(), dataset)  # write to disk
Beispiel #3
0
Give me a crude 3 cluster output of all of the 'static' files. Later on we'll find other files similar to these.
We can use both bits of information to help compose.
"""

output = "../../reaper/Convolutions/base_materials"
em = Corpus("~/Cloud/Projects/ElectroMagnetic/outputs/classification/4_Split/1")

analysis = Chain(
    source = (em),
    folder = output
)

dr = UMAP(components=10, cache=1)
clustering = AgglomerativeClustering(numclusters=3)
analysis.add(
    FluidMFCC(discard=True, numcoeffs=20, fftsettings=[2048, -1, -1], cache=1),
    Stats(numderivs=1, flatten=True, cache=1),
    Standardise(cache=1),
    dr,
    clustering
)

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

    tracks = {}
    for cluster, items in clustering.output.items():
        track_id = cluster
        pos = 0
        for audiofile in items:
            
Beispiel #4
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()