<commit_before>import glob, os
import audioBasicIO, sys, csv
import scipy.io.wavfile as wavfile


def annotation2files(wavFile, csvFile):
    '''
        Break an audio stream to segments of interest, 
        defined by a csv file
        
        - wavFile:    path to input wavfile
        - csvFile:    path to csvFile of segment limits
        
        Input CSV file must be of the format <T1>\t<T2>\t<Label>
    '''    
    
    [Fs, x] = audioBasicIO.readAudioFile(wavFile)
    with open(csvFile, 'rb') as csvfile:
        reader = csv.reader(csvfile, delimiter='\t', quotechar='|')
        for j, row in enumerate(reader):
            T1 = float(row[0].replace(",","."))
            T2 = float(row[1].replace(",","."))            
            label = "%s_%s_%.2f_%.2f.wav" % (wavFile, row[2], T1, T2)
            label = label.replace(" ", "_")
            xtemp = x[round(T1*Fs):round(T2*Fs)]            
            print T1, T2, label, xtemp.shape
            wavfile.write(label, Fs, xtemp)  

def main(argv):
    if argv[1] == "-f":<commit_msg>minor change in segment limit selection<commit_after>import glob, os
import audioBasicIO, sys, csv
import scipy.io.wavfile as wavfile


def annotation2files(wavFile, csvFile):
    '''
        Break an audio stream to segments of interest, 
        defined by a csv file
        
        - wavFile:    path to input wavfile
        - csvFile:    path to csvFile of segment limits
        
        Input CSV file must be of the format <T1>\t<T2>\t<Label>
    '''    
    
    [Fs, x] = audioBasicIO.readAudioFile(wavFile)
    with open(csvFile, 'rb') as csvfile:
        reader = csv.reader(csvfile, delimiter='\t', quotechar='|')
        for j, row in enumerate(reader):
            T1 = float(row[0].replace(",","."))
            T2 = float(row[1].replace(",","."))            
            label = "%s_%s_%.2f_%.2f.wav" % (wavFile, row[2], T1, T2)
            label = label.replace(" ", "_")
            xtemp = x[int(round(T1*Fs)):int(round(T2*Fs))]            
            print T1, T2, label, xtemp.shape
            wavfile.write(label, Fs, xtemp)  

def main(argv):
    if argv[1] == "-f":
{'fraction_non_alphanumeric': 0.14033457249070633, 'fraction_numerical': 0.015799256505576207, 'mean_word_length': 2.0582386363636362, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2819931', 'n_tokens_mistral': 752, 'n_tokens_neox': 724, 'n_words': 188}