# ensure the main ad3 module is on the path parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) if parent_dir not in sys.path: sys.path.append(parent_dir) import ad3 import ad3.models import ad3.models.sql from ad3.models.sql import AudioFile, Plugin from ad3.learning.euclid import Euclidean from ad3.controller import Controller model = ad3.models.sql euclid = Euclidean(model) controller = Controller(model, euclid) controller.initialize_storage() # Create an audio file object for each file in the listings file # (Also dynamically create tags to represent each tag in the file) files = [ (u"audio/Cello note a.wav", u"cello strings"), (u"audio/Cello note c.wav", u"cello strings"), (u"audio/Cello note g.wav", u"cello strings"), (u"audio/Baritone saxophone C major scale ascending descend_BLASTWAVEFX_27547.wav", u"saxophone"), (u"audio/Beat musical acoustic guitar progression loop 01_SFXBible_ss00381.wav", u"guitar"), (u"audio/banjo.wav", u""), (u"audio/drums.wav", u"noise drums"), (u"audio/happy-wind-bed-100b.wav", u"wind"), (u"audio/_01 Eine Kleine Nachtmusik I_ Allegro.m4a.wav", u""),
import sys import os # ensure the main ad3 module is on the path parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) if parent_dir not in sys.path: sys.path.append(parent_dir) import getopt import ad3.models.sql from ad3.learning.euclid import Euclidean from ad3.controller import Controller model = ad3.models.sql euclid = Euclidean(model) controller = Controller(model, euclid) try: # Parse the command line options opts, args = getopt.getopt(sys.argv[1:], "f:t:r:", ["file=", "tags=", "tolerance="]) # Filter unique tags tags = " ".join(filter(None, [opt[1] for opt in opts if opt[0] in ("-t", "--tags")])) # use the first tolerance provided, or default to 10 tolerances = [int(opt[1]) for opt in opts if opt[0] in ("-r", "--tolerance")] if len(tolerances) > 0: tolerance = tolerances[0] else: tolerance = 10
if __name__ == "__main__": import sys import os # ensure the main ad3 module is on the path parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) if parent_dir not in sys.path: sys.path.append(parent_dir) import ad3.models.sql from ad3.learning.euclid import Euclidean from ad3.controller import Controller model = ad3.models.sql euclid = Euclidean(model) controller = Controller(model, euclid) controller.create_vectors() controller.update_tag_vectors()