Ejemplo n.º 1
0
def extractSubwavs(timeDict, path, fn, outputPath):
    '''
    Extracts segments between tones marked in the output of splitFileOnTone()
    '''
    name = os.path.splitext(fn)[0]

    duration = audio_scripts.getSoundFileDuration(join(path, fn))
    beepEntryList = timeDict[BEEP]
    segmentEntryList = sequences.invertIntervalList(beepEntryList, 0, duration)

    if len(segmentEntryList) > 0:
        numZeroes = int(math.floor(math.log10(len(segmentEntryList)))) + 1
    else:
        numZeroes = 1

    strFmt = "%%s_%%0%dd.wav" % numZeroes  # e.g. '%s_%02d.wav'

    for i, entry in enumerate(segmentEntryList):
        start, stop = entry[:2]

        audio_scripts.extractSubwav(join(path, fn),
                                    join(outputPath, strFmt % (name, i)),
                                    startT=float(start),
                                    endT=float(stop),
                                    singleChannelFlag=True)
Ejemplo n.º 2
0
def extractSubwavs(timeDict, path, fn, outputPath):
    '''
    Extracts segments between tones marked in the output of splitFileOnTone()
    '''
    name = os.path.splitext(fn)[0]
    
    duration = audio_scripts.getSoundFileDuration(join(path, fn))
    beepEntryList = timeDict[BEEP]
    segmentEntryList = sequences.invertIntervalList(beepEntryList, 0, duration)
    
    if len(segmentEntryList) > 0:
        numZeroes = int(math.floor(math.log10(len(segmentEntryList)))) + 1
    else:
        numZeroes = 1
        
    strFmt = "%%s_%%0%dd.wav" % numZeroes  # e.g. '%s_%02d.wav'

    for i, entry in enumerate(segmentEntryList):
        start, stop = entry[:2]
        
        audio_scripts.extractSubwav(join(path, fn),
                                    join(outputPath, strFmt % (name, i)),
                                    startT=float(start), endT=float(stop),
                                    singleChannelFlag=True)
Ejemplo n.º 3
0
 def test_twiceInverted(self):
     invertedList = sequences.invertIntervalList(self.LIST_A, 0, 20)
     twiceInvList = sequences.invertIntervalList(invertedList, 0, 20)
     self.assertEqual(self.LIST_A, twiceInvList)
Ejemplo n.º 4
0
 def test_minValue(self):
     invertedList = sequences.invertIntervalList(self.LIST_A, minValue=3)
     correctAnswer = [(3, 5), (6, 10), (13, 14)]
     self.assertEqual(invertedList, correctAnswer)
Ejemplo n.º 5
0
 def test_maxValue(self):
     invertedList = sequences.invertIntervalList(self.LIST_B, maxValue=20)
     correctAnswer = [(1, 5), (6, 10), (13, 14), (16, 20)]
     self.assertEqual(invertedList, correctAnswer)
Ejemplo n.º 6
0
 def test_startsAtNonZero(self):
     invertedList = sequences.invertIntervalList(self.LIST_A)
     correctAnswer = [(0, 5), (6, 10), (13, 14)]
     self.assertEqual(invertedList, correctAnswer)