def PrintOutFiles(speakers,outputdir):
    
    # Now we will create the times for each speech segment
    for i, segment in enumerate(speakers):
        outputfile = '%d_speakers.txt' % (i)
        file = os.path.join(outputdir,outputfile)
        with open(file,'w') as f:
            for times in segment:
                ostring = '%d,%d\n' % (times[0],times[1])
                f.write(ostring)
    
if __name__ == "__main__":
    
    # Read in the command line prompts
    ThreeCharFile = sys.argv[1]
    DoubleCharFile = sys.argv[2]
    outputdir = sys.argv[3]
    
    # Create the output directory if it does not exist
    if not os.path.exists(outputdir):
        os.makedirs(outputdir)
    
    # Read in the segment times
    ThreeCharTimes = FileReader.read_char_times(ThreeCharFile)
    DoubleCharTimes = FileReader.read_char_times(DoubleCharFile)
    SpeakerTimes = GetTalkingTimes(ThreeCharTimes,DoubleCharTimes)
    
    # Output the files
    PrintOutFiles(SpeakerTimes,outputdir)