コード例 #1
0
    if not leslie:
        #make transcript file name
        tf = dataset + '_transcript' + str(audio_file_num).zfill(3) + '.txt'
        # print(lf)

        #correct inconsistent naming
        if dataset == 'tests':
            inner_folder = 'test'
        else:
            inner_folder = dataset

        #get sent timestamps (use memoisation to save too much disk access)
        if TRANSCRIPT_DIR.format(inner_folder) + tf in memo:
            sent_timestamps = memo[TRANSCRIPT_DIR.format(inner_folder) + tf]
        else:
            _, sent_timestamps, _ = process_transcript(
                TRANSCRIPT_DIR.format(inner_folder) + tf)
            memo[TRANSCRIPT_DIR.format(inner_folder) + tf] = sent_timestamps

        #get start timestamp for this utterance (in seconds)
        #note we probs won't need end_time
        #(but can use it to sanity check that we have the correct file if u want...)
        utt_start, _ = sent_timestamps[sent_num - 1]
        # print(sent_num-1, sent_timestamps, utt_start, '\n')

        #use dict to keep the data for this dialog file for each emotion
        #key='arousal' value=[0.3004, 0.3005, 0.3006, ...]
        emotion_data = {}

        #load emotion data in for this dialog
        for emotion in ['arousal', 'expectancy', 'power', 'valence']:
            #get the continuous emotion feature file paths
コード例 #2
0
    # print(transcript_files, wav_files)

    #work through each dialog one at a time
    for transcript_file, wav_file in zip(transcript_files, wav_files):

        if INCLUDE_LIST:
            if transcript_file not in INCLUDE_LIST:
                print(transcript_file, "NOT IN INCLUDE LIST")
                continue #will skip over any files which aren't in the include list
        if EXCLUDE_LIST:
            if transcript_file in EXCLUDE_LIST:
                print(transcript_file, "IN EXCLUDE LIST")
                continue

        #read in transcript file and get sentences, sent and word time stamps
        output_sentences, sent_timestamps, word_timestamps = process_transcript(INPUT_FOLDER + TRANSCRIPT_FOLDER + inner_folder + transcript_file)

        #use sentence timestamps to segment the dialog wav files into wav files only containing sentences
        #also create txt files that contain transcriptions for each sentence
        i = 1
        for sentence, timestamps in zip(output_sentences, sent_timestamps):
            begin = str(datetime.timedelta(seconds=timestamps[0]))
            end = str(datetime.timedelta(seconds=timestamps[1]))

            file_name = wav_file[:-4] #get rid of .wav extension
            file_name = file_name + '_sent{}'.format(str(i).zfill(3))

            #if a filename is in the exclude sent list, then continue this for loop
            if file_name in SENT_EXCLUDE_LIST:
                print(file_name, 'in SENT_EXCLUDE_LIST')
            else: