Example #1
0
def enhanceAccuracy():
    
    nDescriptors = len(SA.descriptorMapping)
    #nDescriptors = 1
    iterations = 10
    best = 0.0
    accuracies = []
    
    for i in range(nDescriptors):
        
        accumulator = 0.0
        for itr in range(iterations):
            try:
                (totalSounds, nIncorrectClassified) = SA.clusterSounds("sounds", nCluster = 10, descInput = [5,12,11,14,9])
                accuracy = float(100.0*float(totalSounds-nIncorrectClassified)/totalSounds)
                accumulator += accuracy
            except:
                print("Error at step {}".format(i))
            
        baseline = float(accumulator/10)
        accuracies.append(baseline)
        if baseline > best: 
            best = baseline
            bestDesc = i
            
    print("Best performance (over {} iterations): {}%, obtained with descriptors (5, 12, 11, 14, 9)".format(iterations, best, bestDesc))
Example #2
0
def computeClusteringBaseline():
    
    nDescriptors = len(SA.descriptorMapping)
    iterations = 10
    accuracies = []
    errorsSteps = []
    best = 0.0
    bestDesc = (-1,-1)
    
    for i in range(nDescriptors):
        for j in range(nDescriptors):
            
            if j <= i:      # the descriptors are equal or the pair has already been computed
                continue
            #SA.descriptorPairScatterPlot("sounds", descInput = (i,j), anotOn = 0)
            
            # compute the mean k-means clustering performance over 10 iterations
            accumulator = 0.0
            for itr in range(iterations):
                try:
                    (totalSounds, nIncorrectClassified) = SA.clusterSounds("sounds", nCluster = 10, descInput = [i,j])
                    accuracy = float(100.0*float(totalSounds-nIncorrectClassified)/totalSounds)
                    accumulator += accuracy
                except:
                    print("Error clustering {} and {}".format(SA.descriptorMapping[i], SA.descriptorMapping[j]))
                    errorsSteps.append((i,j))
                    pass
            
            baseline = float(accumulator/10)
            accuracies.append(baseline)
            if baseline > best: 
                best = baseline
                bestDesc = (i,j)
            
            print("Descriptors: {}-{}, {}-{}".format(i, SA.descriptorMapping[i], j, SA.descriptorMapping[j]))
            print("Accuracy: {}%".format(round(baseline,2)))

    print("Best performance (over {} iterations): {}%, obtained with descriptors {}".format(iterations, best, bestDesc))
    
    return (errorsSteps, accuracies)
import soundAnalysis as SA

SA.clusterSounds('testDownload/', nCluster=3, descInput=[3,11,13])
Example #4
0
def cluster(desc):
    SA.clusterSounds(Dir, nCluster = 3, descInput = desc)
Example #5
0
import soundAnalysis as sa
import matplotlib.pyplot as plt

# 'lowlevel.mfcc.mean.2', 'sfx.logattacktime.mean'
#sa.descriptorPairScatterPlot('joeDown', (3,13))

# 'lowlevel.spectral_contrast.mean.3', 'lowlevel.mfcc.mean.2'
#sa.descriptorPairScatterPlot('joeDown', (13,8))

# 'lowlevel.mfcc.mean.3', 'lowlevel.mfcc.mean.2',
#sa.descriptorPairScatterPlot('joeDown', (13,14))

#[3,8,13,14]
#sa.clusterSounds('joeDown', 3, [3,13])
#sa.clusterSounds('joeDown', 3, [8,13])
sa.clusterSounds('joeDown', 12, [13, 14])

#sa.clusterSounds('joeDown', 3, [11, 11, 14, 1, 3])

#sa.clusterSounds('joeDown', 3, [11, 15, 3])
#sa.clusterSounds('joeDown', 3, [3, 11, 11])
Example #6
0
import soundAnalysis as sa
import matplotlib.pyplot as plt


# 'lowlevel.mfcc.mean.2', 'sfx.logattacktime.mean'
#sa.descriptorPairScatterPlot('joeDown', (3,13))


# 'lowlevel.spectral_contrast.mean.3', 'lowlevel.mfcc.mean.2'
#sa.descriptorPairScatterPlot('joeDown', (13,8))



# 'lowlevel.mfcc.mean.3', 'lowlevel.mfcc.mean.2',
#sa.descriptorPairScatterPlot('joeDown', (13,14))

#[3,8,13,14]
#sa.clusterSounds('joeDown', 3, [3,13])
#sa.clusterSounds('joeDown', 3, [8,13])
sa.clusterSounds('joeDown', 12, [13,14])

#sa.clusterSounds('joeDown', 3, [11, 11, 14, 1, 3])

#sa.clusterSounds('joeDown', 3, [11, 15, 3])
#sa.clusterSounds('joeDown', 3, [3, 11, 11])
Example #7
0
                      7: 'lowlevel.spectral_contrast.mean.2',
                      8: 'lowlevel.spectral_contrast.mean.3',
                      9: 'lowlevel.spectral_contrast.mean.4',
                      10: 'lowlevel.spectral_contrast.mean.5',
                      11: 'lowlevel.mfcc.mean.0',
                      12: 'lowlevel.mfcc.mean.1',
                      13: 'lowlevel.mfcc.mean.2',
                      14: 'lowlevel.mfcc.mean.3',
                      15: 'lowlevel.mfcc.mean.4',
                      16: 'lowlevel.mfcc.mean.5'
                    }


'''

N = 17  # number of descriptors

# Iterate through all the possible pairs for descriptors and see if they cluster the sounds good or they don't

for i in range(N):
    for j in range(N):
        SA.descriptorPairScatterPlot('downloaded/', descInput=(i, j), anotOn=0)

# Cluster sounds using k-means algorithm
SA.clusterSounds('downloaded/',
                 nCluster=10,
                 descInput=[4, 8, 9, 10, 11, 12, 13, 14, 15])

# Final choice of descriptors: 4,8,9,10,11,12,13,14,15
# Mean accuracy of 68.65% using k-means algorithm with 10 clusters
Example #8
0
print "-----------"
SD.downloadSoundsFreesound(queryText = "trumpet", API_Key = my_API_Key, outputDir = "./testCluster", topNResults = 2, duration = (0,10), tag = "single-note")
print "-----------"
print "Download of set-4 completed"
print "\n"

#Get sound visual info
SA.showDescriptorMapping()

print "Starting plotting:"
#idx = 1
#while(idx<=16):
#    SA.descriptorPairScatterPlot("./testDownload", descInput = (0,idx))
#    print "idx = " + str(idx)
#    print "\n"
#    idx = idx + 1

SA.descriptorPairScatterPlot("./testDownload", descInput = (0,15))
print "Plot completed"
print "\n"

print "Starting clustering:"
SA.clusterSounds("./testDownload", nCluster = 3, descInput = [0,1,14,15])
print "Clustering completed"
print "\n"

print "Starting kNN clustering:"
SA.classifySoundkNN("./testCluster/trumpet/247171/247171_637616-lq.json","./testDownload/", 3, descInput = [0,1,14,15])
print "kNN clustering completed"
print "\n"