def generateSegmentGraphs(segments, filenames, segmentMarkers, tempos): # training set timeMarkers = [(26.516,131.312),(4.746,172.450),(41.044,201.012),(82.312,175.997),(15.370,46.003),(122.042,213.469),(30.887,122.294),(0.000,272.304),(37.785,195.357),(15.230,195.357),(37.539,172.498),(67.721,157.716),(37.282,125.899),(147.876,325.127),(14.775,192.008),(213.437,298.800),(29.553,86.022),(238.297,294.371),(21.150,193.356),(41.625,138.350)] # validation set timeMarkers = [(4.0,141.0),(25.0,177.0),(17.0,188.0),(16.0,129.0),(17.0,177.0),(15.0,136.0),(87.0,149.0),(98.0,173.0),(106.0,212.0),(0.0,104.0)] timeMarkers = [(37,125)] myMarkers = [(j.index(min(j.that(selection.start_during_range(i[0], i[0]+1.0)))),j.index(min(j.that(selection.start_during_range(i[1], i[1]+10.0))))) for j,i in zip(segments,timeMarkers)] for i in range(len(segments)): pyplot.figure(i,(16,9)) windowLen3 = int((16.0/tempos[i])*60.0/(matlib.mean(matlib.array(segments[i].durations)))) lpf3 = signal.lfilter(np.ones(windowLen3)/windowLen3,1,segments[i].loudness_max) + signal.lfilter(np.ones(windowLen3)/windowLen3,1,segments[i].loudness_max[::-1])[::-1] lpf3 = np.convolve(segments[i].loudness_max,np.ones(windowLen3)/windowLen3)[windowLen3/2:-(windowLen3/2)] lpf3[0:windowLen3/2] = lpf3[windowLen3/2] lpf3[-(windowLen3/2):] = lpf3[-(windowLen3/2)] pyplot.plot(lpf3) pyplot.xlabel('Segment Number') pyplot.ylabel('Loudness (dB)') #pyplot.vlines(segmentMarkers[i][0], min(lpf3), max(segments[i].loudness_max), 'g') #pyplot.vlines(segmentMarkers[i][1], min(lpf3), max(segments[i].loudness_max), 'g') pyplot.vlines(myMarkers[i][0], min(lpf3), max(segments[i].loudness_max), 'r') pyplot.vlines(myMarkers[i][1], min(lpf3), max(segments[i].loudness_max), 'r') pyplot.legend(["Loudness", #"Autmatically selected start time: " + str(action.humanize_time(segments[i][segmentMarkers[i][0]].start)), #"Automatically selected end time: " + str(action.humanize_time(segments[i][segmentMarkers[i][1]].start)), "Manually selected start time: " + str(action.humanize_time(timeMarkers[i][0])), "Manually selected end time: " + str(action.humanize_time(timeMarkers[i][1]))]) pyplot.title(filenames[i]) pyplot.show()
def display_actions(actions): total = 0 print "<playlist>" for a in actions: total += a.duration try: print "%s\t %s\t %s" % (humanize_time(total), round(total, 2), unicode(a)) except AttributeError: print "%s\t %s\t NA" % (humanize_time(total), round(total, 2)) print "</playlist>"
def display_actions(actions): total = 0 print for a in actions: print "%s\t %s" % (humanize_time(total), unicode(a)) total += a.duration print