Exemple #1
0
def PlotWaveformWClasses(k, feature_holder, classes):
    index_time_map = feature_holder.get_index_time_map()
    print "Original File:", feature_holder.filename

    # for each class k
    events = np.zeros((60 * 6 * 44100, 1))
    segment_classes = GetClassFromSegment(k, index_time_map, classes)
    for i in sorted(segment_classes.keys()):
        # Find all time segments that go with this class
        timeSegments = [index_time_map[j] for j in sorted(segment_classes[i])]

        # Write all these time segments to a single file
        audioSegments, fs = af.get_arbitrary_file_segments(
            feature_holder.filename, timeSegments)

        for j in range(len(timeSegments)):
            print j, timeSegments[j]
            if (timeSegments[j][0] + timeSegments[j][1]) < 60 * 6:

                startIndex = int(timeSegments[j][0] * fs)
                endIndex = int(
                    float(timeSegments[j][0] + timeSegments[j][1]) * fs)

                diff = len(audioSegments[j]) - len(events[startIndex:endIndex])
                events[startIndex:endIndex + diff] = audioSegments[j]

    plt.plot(events[::100])
    plt.show()
Exemple #2
0
def PlotWaveformWClasses(k, feature_holder, classes):
    index_time_map = feature_holder.get_index_time_map()
    print "Original File:", feature_holder.filename

    
    # for each class k
    events = np.zeros((60*6*44100,1))
    segment_classes = GetClassFromSegment(k, index_time_map, classes)
    for i in sorted(segment_classes.keys()):
        # Find all time segments that go with this class
        timeSegments = [ index_time_map[j] for j  in sorted(segment_classes[i])]
        
        
        
        # Write all these time segments to a single file
        audioSegments, fs = af.get_arbitrary_file_segments(feature_holder.filename, timeSegments)
        
        for j in range(len(timeSegments)):
            print j, timeSegments[j]
            if (timeSegments[j][0]+timeSegments[j][1]) < 60*6:
                
                startIndex = int(timeSegments[j][0]*fs)
                endIndex = int(float(timeSegments[j][0]+timeSegments[j][1])*fs)
                
                diff = len(audioSegments[j])-len(events[startIndex:endIndex])
                events[startIndex:endIndex+diff] = audioSegments[j]
                
    plt.plot(events[::100]);plt.show()
Exemple #3
0
def WriteAudioFromClasses(k, feature_holder, classes):
    ''' given the class labels, write the audio associated with each one '''
    index_time_map = feature_holder.get_index_time_map()
    print "Original File:", feature_holder.filename

    # for each class k
    segment_classes = GetClassFromSegment(k, index_time_map, classes)
    for i in sorted(segment_classes.keys()):
        # Find all time segments that go with this class
        timeSegments = [ index_time_map[j] for j  in sorted(segment_classes[i])]

        #print timeSegments
        # Write all these time segments to a single file
        audioSegments, fs = af.get_arbitrary_file_segments(feature_holder.filename, timeSegments)
        resultDir = './results'
        af.write_segment_audio("%s/class-%d.wav" % (resultDir, i), audioSegments, fs)
Exemple #4
0
def WriteAudioFromClasses(k, feature_holder, classes):
    ''' given the class labels, write the audio associated with each one '''
    index_time_map = feature_holder.get_index_time_map()
    print "Original File:", feature_holder.filename

    # for each class k
    segment_classes = GetClassFromSegment(k, index_time_map, classes)
    for i in sorted(segment_classes.keys()):
        # Find all time segments that go with this class
        timeSegments = [index_time_map[j] for j in sorted(segment_classes[i])]

        #print timeSegments
        # Write all these time segments to a single file
        audioSegments, fs = af.get_arbitrary_file_segments(
            feature_holder.filename, timeSegments)
        resultDir = './results'
        af.write_segment_audio("%s/class-%d.wav" % (resultDir, i),
                               audioSegments, fs)