Esempio n. 1
0
def choose_vamp_plugin():
    '''Takes nothing, returns a user-chosen vamp plugin'''
    print 'Choose a vamp plugin to use to analyze audio data:\n'
    for index, value in enumerate(vamp.list_plugins()):
        print '%d: %s' % (index, value)
    choice = int(raw_input('Enter the number corresponding to the desired vamp plugin: '))
    return vamp.list_plugins()[choice]
Esempio n. 2
0
def analyzeAudio(audio_array, sample_rate, channels):
    print "Found Vamp plugins:"
    for name in vamp.list_plugins():
        print "  " + name

    # convert audio array to float format expected by vamp
    audio_array2 = audio_array / float(numpy.iinfo(numpy.int16).max)
    audio_array2 = audio_array2.reshape((len(audio_array2)/channels,channels))[:,0]

    if False:
        # chuncked
        results = []
        for subarray in numpy.array_split(audio_array2, numpy.ceil(audio_array2.shape[0] / float(BUFFER_SIZE)), axis=0):
            if DEBUG: print "subarray size: " + str(subarray.shape[0])
            #assert(subarray.shape[0] == BUFFER_SIZE)
            results += [vamp.collect(subarray, sample_rate, VAMP_PLUGIN)]
    else:
        # all at once
        results = vamp.collect(audio_array2, sample_rate, VAMP_PLUGIN)
        if DEBUG: 
            print "Vamp plugin output:"
            for result in results["list"][:15]:
                print "  %s" % result

    results = [(float(row["timestamp"]), float(row["duration"]), int(row["values"][0])) for row in results["list"]]

    return results
Esempio n. 3
0
def index(request):
    os.environ["VAMP_PATH"] = os.path.dirname(os.path.abspath(__file__))
    n = librosa.time_to_samples(3)
    return HttpResponse(
        str(n) + ' [' + ' '.join(vamp.list_plugins()) + '] path=' +
        (os.environ["PATH"] if "PATH" in os.environ else "none") +
        ' vamp_path=' +
        (os.environ["VAMP_PATH"] if "VAMP_PATH" in os.environ else "none") +
        ' dirname=' + os.path.dirname(os.path.abspath(__file__)) + ' cwd=' +
        os.getcwd())
Esempio n. 4
0
def hello():
    # clf = svm.SVC(gamma=0.001, C=100.)
    # clf.fit(digits.data[:-1], digits.target[:-1])
    # prediction = clf.predict(digits.data[-1:])

    # return jsonify({'prediction': repr(prediction)})

    #vamp_plugins = vamp.list_plugins()

    song = librosa.load('/opt/Songs/Kuh muht-TdheW61w4Co.m4a')
    some_samples = song[0][10000:10020]
    vamp_plugins = vamp.list_plugins()
    #return 'Some samples from my song: {} /n My vamp plugins: {}'.format(some_samples, vamp_plugins)
    #return 'hello'

    return render_template('test.html',
                           samples=some_samples,
                           plugins=vamp_plugins)
Esempio n. 5
0
    def __init__(self,
                 input_audio_signal,
                 high_pass_cutoff=100,
                 minimum_frequency=55.0,
                 maximum_frequency=1760.0,
                 voicing_tolerance=0.2,
                 minimum_peak_salience=0.0,
                 compression=0.5,
                 num_overtones=40,
                 apply_vowel_filter=False,
                 smooth_length=5,
                 add_lower_octave=False,
                 mask_type='soft',
                 mask_threshold=0.5):
        # lazy load vamp to check if it exists
        from ... import vamp_imported

        melodia_installed = False
        if vamp_imported:
            melodia_installed = 'mtg-melodia:melodia' in vamp.list_plugins()

        if not vamp_imported or not melodia_installed:
            self._raise_vamp_melodia_error()

        super().__init__(input_audio_signal=input_audio_signal,
                         mask_type=mask_type,
                         mask_threshold=mask_threshold)

        self.high_pass_cutoff = high_pass_cutoff
        self.minimum_frequency = float(minimum_frequency)
        self.maximum_frequency = float(maximum_frequency)
        self.voicing_tolerance = float(voicing_tolerance)
        self.minimum_peak_salience = float(minimum_peak_salience)
        self.compression = compression
        self.apply_vowel_filter = apply_vowel_filter
        self.add_lower_octave = add_lower_octave

        self.melody = None
        self.melody_signal = None
        self.timestamps = None

        self.num_overtones = num_overtones
        self.smooth_length = smooth_length
Esempio n. 6
0
    # 5 - ping property
    pingPropName = "Ping"
    pingPropURI = getRandomURI(ysap.namespaces["qmul"])
    pingPropData = getRandomURI(ysap.namespaces["qmul"])
    pingPropDataSchema = getRandomURI(ysap.namespaces["qmul"])

    # set the forced bindings
    fb = {
        "thingURI": " <%s> " % thingURI,
        "thingName": " '%s' " % thingName,
        "thingDescURI": " <%s> " % thingDescURI,
        "plugPropURI": " <%s> " % plugPropURI,
        "plugPropData": " <%s> " % plugPropData,
        "plugPropName": " '%s' " % plugPropName,
        "plugPropValue": " '%s' " % ",".join(vamp.list_plugins()),
        "plugPropDataSchema": " <%s> " % plugPropDataSchema,
        "wlPropURI": " <%s> " % wlPropURI,
        "wlPropData": " <%s> " % wlPropData,
        "wlPropName": " '%s' " % wlPropName,
        "wlPropValue": " '0' ",
        "wlPropDataSchema": " <%s> " % wlPropDataSchema,
        "pingPropURI": " <%s> " % pingPropURI,
        "pingPropData": " <%s> " % pingPropData,
        "pingPropName": " '%s' " % pingPropName,
        "pingPropDataSchema": " <%s> " % pingPropDataSchema,
        "pingPropValue": " '%s' " % str(time.time()),
        "actionURI": " <%s> " % actionURI,
        "actionName": " '%s' " % actionName,
        "actionComment": " '%s' " % actionComment,
        "inDataSchema": " <%s> " % inDataSchema,
Esempio n. 7
0
#!/usr/bin/python3

# reqs
import vamp
import librosa

# open file
print("Loading audio file...")
data, rate = librosa.load("Rein_-_Occidente.mp3")

# process it
print("Processing audio file...")
chroma = vamp.collect(data, rate, vamp.list_plugins()[0])

# print the results
print(chroma)

# bye!
print("Done!")
Esempio n. 8
0
def test_plugin_exists_module():
    assert plugin_key in vamp.list_plugins()
Esempio n. 9
0
    logging.basicConfig(format='[%(levelname)s] %(message)s',
                        level=logging.DEBUG)
    logging.debug("Logging subsystem initialized")

    # 1 - create an instance of the Device and one of the JSAP
    wt = Device(CONFIG_FILE, "SonicAnnotatorWT")
    jsap = JSAPObject(CONFIG_FILE, 40)

    # 2 - specify properties
    # NOTE: our thing must expose the list of plugins.
    #       we do it through an rfd:Bag.. so to addProperty
    #       we give the URI of a Bag. Then we fill it.
    bagUri = wt.getRandomURI()
    propUri = wt.getRandomURI()
    wt.addProperty(True, "hasPlugin", bagUri, propUri, "rdf:Bag")
    for plugin in vamp.list_plugins():
        wt.addCustomStatement(" <%s> rdf:li '%s' " % (bagUri, plugin))
        break

    # 3 - specify events
    wt.addEvent("Ping")

    # 4 - specify actions
    plugins = subprocess.check_output(SONIC_ANN)
    wt.addAction("invokeSonicAnnotator", None,
                 [{
                     "fieldName": "transform",
                     "fieldType": jsap.namespaces["ac"] + "Transform"
                 }, {
                     "fieldName": "audio",
                     "fieldType": jsap.namespaces["rdfs"] + "Resource"
Esempio n. 10
0
def test_plugin_exists_module():
    assert plugin_key in vamp.list_plugins()