Mercurial > hg > audio-features-catalogue
view rdfpy/writeTimbreToolbox.py @ 18:d5012016bf64 tip
added rdfpy and rdfonto directories
author | nothing@tehis.net |
---|---|
date | Tue, 23 Apr 2013 11:49:20 +0100 |
parents | |
children |
line wrap: on
line source
import rdflib, os, fnmatch, urllib2 from rdflib import Graph, RDF, RDFS, plugin, URIRef, Literal, OWL, XSD, Namespace graph = Graph() af = Namespace('http://sovarr.c4dm.eecs.qmul.ac.uk/features/') graph.bind('local', af) dc = Namespace('http://purl.org/dc/elements/1.1/') graph.bind('dc', dc) input = { 'au': "Audio Signal", 'tee': "Temporal Energy Envelope", 'stft': "Short-term Fourier Transform", 'erb': "Auditory model", 'harm': "Harmonic" } features = { 'Global Descriptors': [ {"Attack": "tee"}, {"Decay": "tee"}, {"Release": "tee"}, {"Log-Attack Time": "tee"}, {"Attack Slope": "tee"}, {"DecreaseSlope": "tee"}, {"Temporal Centroid": "tee"}, {"Effective Duration": "tee"}, {"Frequency of Energy Modulation": "tee"}, {"Amplitude of Energy Modulation": "tee"} ], 'Time-Varying Descriptors': [ {"Autocorrelation": 'au'}, {"Zero Crossing Rate": 'au'}, {"RMS-Energy Envelope": 'tee'}, {"Spectral Centroid": 'stft,erb,harm'}, {"Spectral Spread": 'stft,erb,harm'}, {"Spectral Skewness": 'stft,erb,harm'}, {"Spectral Kurtosis": 'stft,erb,harm'}, {"Spectral Slope": 'stft,erb,harm'}, {"Spectral Decrease": 'stft,erb,harm'}, {"Spectral Rolloff": 'stft,erb,harm'}, {"Spectro-temporal Variation": 'stft,erb,harm'}, {"Spectral Flatness": 'stft,erb'}, {"Spectral Crest": 'stft,erb'}, {"Harmonic Energy": 'harm'}, {"Noise Energy": 'harm'}, {"Noisiness": 'harm'}, {"Fundamental Frequency": 'harm'}, {"Inharmonicity": 'harm'}, {"Tristimulus": 'harm'}, {"Harmonic Spectral Deviation": 'harm'}, {"Odd to even harmonic ratio": 'harm'} ] } for temporal in features.keys(): for feature in features[temporal]: name = feature.keys()[0] id = af + name.replace(" ", "") graph.add(( URIRef(id), RDF.type, RDFS.Resource )) graph.add(( URIRef(id), af['feature'], Literal(name) )) graph.add(( URIRef(id), af['feature'], Literal(name) )) for inp in feature[name].split(","): graph.add(( URIRef(id), af['signal'], Literal(input[inp]) )) graph.serialize('/Users/alo/MusicOntology/features/rdf/af-TimbreToolbox.rdf') graph.serialize('/Users/alo/MusicOntology/features/rdfn3/af-TimbreToolbox.n3', format="n3")