Exemple #1
0
def run_command(feature_type, missing_data, data_object_base_path_name, base_out_path, input_dims, tone_list, dur_position, num_sampling, d1, d2):
    
    deltas = [
        [d1, d2]
    ]

    output_name_paths = []

    for i, d in enumerate(deltas):
        outp = '{}/input_dims_{}/delta-{}_delta-delta-{}/'.format(base_out_path, input_dims, d[0], d[1])
        output_name_paths.append(outp)

    print 'Missing Data : {}'.format(missing_data)
    print 'Inducing points : 10 percent'

    for idx, output_name in enumerate(output_name_paths):

        delta_bool=deltas[idx][0]
        delta2_bool=deltas[idx][1]

        if missing_data:
            method_name = 'BayesianGPLVMMiniBatch_Missing'
        else :
            method_name = 'BGP_LVM'

        for tone in tone_list:

            print 'Delta : {}, Delta-Dealta : {}'.format(delta_bool, delta2_bool)

            data_object_path = '{}{}.pickle'.format(data_object_base_path_name, tone)

            print 'data path ',data_object_path

            syllable_management = Utility.load_obj(data_object_path)

            if len(syllable_management.syllables_list) == 0:
                print 'No syllable in this object database : {}'.format(tone)
                print '-----------------------------------------------------------------'
                continue

            output_path = '{}/{}_Tone_{}/'.format(output_name, method_name, tone)

            Utility.make_directory(output_path)

            print output_path

            Latent_variable_model_Training.execute_Bayesian_GPLVM_training(
                syllable_management, 
                feature_type, 
                input_dims, 
                output_path,
                num_sampling=num_sampling,
                dur_position=dur_position,
                delta_bool=delta_bool,
                delta2_bool=delta2_bool,
                missing_data=missing_data,
                num_inducing=int(len(syllable_management.syllables_list)*0.1),
                max_iters=500)

    pass
Exemple #2
0
def run_command(feature_type, missing_data, data_object_base_path_name, base_out_path, input_dims, tone_list, dur_position):
    
    deltas = [
        [False, False],
        [True, False],
        [True, True]
    ]

    output_name_paths = []

    for i, d in enumerate(deltas):
        outp = '{}/input_dims_{}/{}_delta-{}_delta-delta-{}/'.format(base_out_path, input_dims, Utility.fill_zero(i+1,2), d[0], d[1])
        output_name_paths.append(outp)

    print 'Missing Data : {}'.format(missing_data)

    for idx, output_name in enumerate(output_name_paths):

        delta_bool=deltas[idx][0]
        delta2_bool=deltas[idx][1]

        if missing_data:
            method_name = 'BayesianGPLVMMiniBatch_Missing'
        else :
            method_name = 'BGP_LVM'

        for tone in tone_list:

            print 'Delta : {}, Delta-Dealta : {}'.format(delta_bool, delta2_bool)

            data_object_path = '{}{}.pickle'.format(data_object_base_path_name, tone)

            print 'data path ',data_object_path

            syllable_management = Utility.load_obj(data_object_path)

            if len(syllable_management.syllables_list) == 0:
                print 'No syllable in this object database : {}'.format(tone)
                print '-----------------------------------------------------------------'
                continue

            output_path = '{}/{}_Tone_{}/'.format(output_name, method_name, tone)

            Utility.make_directory(output_path)

            print output_path

            Latent_variable_model_Training.execute_Bayesian_GPLVM_training(
                syllable_management, 
                feature_type, 
                input_dims, 
                output_path,
                dur_position=dur_position,
                subtract_typical_contour=False,
                exp=False,
                delta_bool=delta_bool,
                delta2_bool=delta2_bool,
                missing_data=missing_data)

    pass
Exemple #3
0
def gen_tonal_part_duration(phone_level_label, pattern, start_set, end_set,
                            outpath):

    for sett in Utility.char_range(start_set, end_set):
        set_path = '{}/{}/'.format(phone_level_label, sett)
        for f in Utility.list_file(set_path):
            if f.startswith('.'): continue
            file_path = '{}/{}'.format(set_path, f)

            phone_frame_list = []
            syllable_count = 0

            for line in Utility.read_file_line_by_line(file_path):
                match = re.match(pattern, line)
                if match:
                    start_time = match.group('start_time')
                    end_time = match.group('end_time')

                    if match.group('phone_position_in_syllable') == 'x':
                        continue

                    phone_position_in_syllable = int(
                        match.group('phone_position_in_syllable'))
                    phone_number_in_syllable = int(
                        match.group('phone_number_in_syllable'))

                    frame = (float(end_time) - float(start_time)) / 50000

                    if phone_position_in_syllable == 1:
                        phone_frame_list = []
                        phone_frame_list.append(frame)
                    elif phone_position_in_syllable == phone_number_in_syllable:
                        phone_frame_list.append(frame)
                        if phone_number_in_syllable == 2:
                            phone_frame_list.append(0)

                        syllable_count += 1
                        print phone_frame_list
                        outfile = '{}/{}/{}/{}_dur.npy'.format(
                            outpath, sett,
                            f.split('.')[0], syllable_count)
                        print outfile
                        Utility.make_directory('{}/{}/{}/'.format(
                            outpath, sett,
                            f.split('.')[0]))
                        Utility.save_obj(phone_frame_list, outfile)
                    elif phone_position_in_syllable == 2:
                        phone_frame_list.append(frame)

                else:
                    print 'Not match', f

                pass
def plot_syllable(lab_path, lf0_path, out_set_path, name, plot_set_out):

    lines = Utility.read_file_line_by_line(lab_path)
    lf0 = Utility.read_lf0_into_ascii(lf0_path)

    print lf0

    path = '{}/{}/'.format(out_set_path, name)

    Utility.make_directory(path)

    for idx, line in enumerate(lines):

        line = Utility.trim(line)
        spl = line.split(' ')
        # print spl

        start = float(spl[0]) / 50000
        end = float(spl[1]) / 50000

        syl = spl[2]

        # print start, end, syl

        if end > len(lf0):
            end = len(lf0) - 1

        cur_lf0 = lf0[start:end]
        # print len(cur_lf0)

        o = '{}_{}'.format((idx + 1), syl)

        out_name = '{}/{}.lf0'.format(path, o)
        print out_name
        # Utility.write_to_file_line_by_line(out_name, cur_lf0)

        Utility.make_directory('{}/{}/'.format(plot_set_out, name))

        plot_out_file_path = '{}/{}/{}.eps'.format(plot_set_out, name, o)

        plot(cur_lf0, plot_out_file_path)

    print len(lf0)

    pass
def run(syllable_object, main_out_path):
    vowel_type = ['v', 'vv', 'vn', 'vvn', 'vsg', 'vvsg']
    tones = ['0', '1', '2', '3', '4']

    syllable_lists = dict()
    for v in vowel_type:
        for t in tones:
            syllable_lists['{}_{}'.format(v, t)] = []

    for syl in syllable_object.syllables_list:
        syllable_lists['{}_{}'.format(syl.get_vowel_length_type(),
                                      syl.tone)].append(syl)

    for s in syllable_lists:
        spl = s.split('_')
        outpath = '{}/{}/{}/'.format(main_out_path, spl[0], spl[1])
        Utility.make_directory(outpath)
        plot_syllable(syllable_lists[s], outpath)
def run_gen_mono(utt_set):

    set_path = '{}/{}/'.format(utterance_path, utt_set)

    set_syllable_base_path = '{}/{}/'.format(syllable_base, utt_set)

    out_set_path = '{}/{}/'.format(output_path, utt_set)
    Utility.make_directory(out_set_path)

    for i in xrange(1, 51):
        utt_file = Utility.yaml_load('{}/tscsd{}{}.utt.yaml'.format(
            set_path, utt_set, Utility.fill_zero(i, 2)))
        # print utt_file

        out_file = '{}/tscsd{}{}.lab'.format(out_set_path, utt_set,
                                             Utility.fill_zero(i, 2))

        stress_list = []
        recursion(utt_file, stress_list)

        syllable_time_label = Utility.read_file_line_by_line(
            '{}/tscsd{}{}.lab'.format(set_syllable_base_path, utt_set,
                                      Utility.fill_zero(i, 2)))
        # print stress_list, len(stress_list)
        # print len(syllable_time_label)
        if len(syllable_time_label) != len(stress_list):
            print utt_set, i
            # print 'Error'
            # sys.exit()

        out = []
        for idx, line in enumerate(syllable_time_label):
            # print line, stress_list[idx]
            o = '{}::{}'.format(
                Utility.trim(line).replace('-', '_').replace('+', '_'),
                stress_list[idx])
            # print o
            out.append(o)

        Utility.write_to_file_line_by_line(out_file, out)

        # sys.exit()

    pass
Exemple #7
0
def gen_file_list():

    outpath = '/home/h1/decha/Dropbox/python_workspace/Inter_speech_2016/playground/list_file_for_preceeding_suceeding/list_gpr_file/'

    label_path = '/work/w2/decha/Data/GPR_data/label/03_GPR_syllable_level/full/tsc/sd/'
    start_set = 'a'
    end_set = 'j'

    for sett in Utility.char_range(start_set, end_set):
        set_path = '{}/{}/'.format(label_path, sett)

        out_set_path = '{}/{}/'.format(outpath, sett)
        Utility.make_directory(out_set_path)

        for f in Utility.list_file(set_path):
            if f.startswith('.'): continue
            file_path = '{}/{}'.format(set_path, f)
            count = 0
            # print f
            file_number = f[6] + f[7]

            out_list = []

            for line in Utility.read_file_line_by_line(file_path):
                # print Utility.trim(line)
                out = ''
                if 'sil-sil+sil/A:' in line:
                    out = 'sil'
                elif 'pau-pau+pau/A:' in line:
                    out = 'pau'
                else:
                    count += 1
                    out = 'tscsd_gpr_{}{}_{}'.format(sett, file_number, count)
                # print out
                out_list.append(out)

            if len(out_list) != len(Utility.read_file_line_by_line(file_path)):
                print file_path

            out_file_name = '{}/{}{}.lab'.format(out_set_path, sett,
                                                 file_number)
            # print out_file_name

            Utility.write_to_file_line_by_line(out_file_name, out_list)
Exemple #8
0
def run_add_and_non_duration(out_base, vowel, d, tone, feature_name, num_dims):

    for n in num_dims:

        print '------------Start-----------'

        print 'Vowel : {}, Delta : {}, Tone : {}'.format(vowel, d, tone)

        base_path = '{}/{}/input_dims_{}/delta-{}_delta-delta-{}/BGP_LVM_Tone_{}/'.format(
            out_base, vowel, n, d[0], d[1], tone)
        syllable_object = '{}/{}/syllable_object_{}_fold/syllable_object_{}_3-fold_'.format(
            object_base, vowel, tone, tone)
        outpath = '{}/{}/input_dims_{}/delta-{}_delta-delta-{}/BGP_LVM_Tone_{}/feed_forword_ann/{}/'.format(
            out_base, vowel, n, d[0], d[1], tone, feature_name)

        print 'ANN outpath : {}'.format(outpath)
        print 'Syllable object : {}'.format(syllable_object)

        Utility.make_directory(outpath)
        run(syllable_object, fold, outpath, feature, [1, 2], d[0], d[1],
            base_path)
        print '------------End-----------'

        print '------------Start-----------'

        print 'Vowel : No_duration_{}, Delta : {}, Tone : {}'.format(
            vowel, d, tone)

        base_path = '{}/{}/input_dims_{}/delta-{}_delta-delta-{}/BGP_LVM_Tone_{}/'.format(
            out_base, 'No_duration_' + vowel, n, d[0], d[1], tone)
        syllable_object = '{}/{}/syllable_object_{}_fold/syllable_object_{}_3-fold_'.format(
            object_base, vowel, tone, tone)
        outpath = '{}/{}/input_dims_{}/delta-{}_delta-delta-{}/BGP_LVM_Tone_{}/feed_forword_ann/{}/'.format(
            out_base, 'No_duration_' + vowel, n, d[0], d[1], tone,
            feature_name)

        print 'ANN outpath : {}'.format(outpath)
        print 'Syllable object : {}'.format(syllable_object)

        Utility.make_directory(outpath)
        run(syllable_object, fold, outpath, feature, [], d[0], d[1], base_path)

        print '------------End-----------'
def run(main_fig_path, out_path):
    vowel_type = ['v', 'vv', 'vn', 'vvn', 'vsg', 'vvsg']
    # vowel_type = ['v', 'vv', 'vn', 'vvn', 'vsg', 'vvsg']
    tones = ['0', '1', '2', '3', '4']

    # vowel_type = ['vv']
    # tones = ['1']

    c = dict()
    c[-1] = 'black'
    c[0] = 'blue'
    c[1] = 'red'
    c[2] = 'green'
    c[3] = 'yellow'

    fig_per_line = 4

    syllable_lists = dict()
    # for v in vowel_type:
    for v in ['vvv', 'vvvn', 'vvvsg']:
        for t in tones:

            if v == 'vvv':
                vv = ['v', 'vv']
            elif v == 'vvvn':
                vv = ['vn', 'vvn']
            elif v == 'vvvsg':
                vv = ['vsg', 'vvsg']
            else:
                print 'wtf'

            dire = '{}/{}/'.format(out_path, v)
            Utility.make_directory(dire)
            latext_out_file = '{}/stress-list_vowel-type-{}_Tone-{}.tex'.format(
                dire, v, t)

            for vi in vv:
                path = '{}/{}/{}/'.format(main_fig_path, vi, t)
                files = Utility.list_file(path)
                file_list = []
                # print files
                for f in files:
                    # tscsd_manual_f17_22_tone_3_dur_15.025_syl_n-aa-m^_stress_0

                    if f.startswith('.'): continue

                    pattern = re.compile(
                        r"""(?P<name>.+)_tone.+dur_(?P<dur>.+)_syl.+_stress_(?P<stress>.+).eps""",
                        re.VERBOSE)
                    match = re.match(pattern, f)
                    # print match
                    if match:
                        dur = float(match.group('dur'))

                        stress = 'Unstress'
                        if int(match.group('stress')) == 1:
                            stress = 'Stress'

                        file_list.append(('{}/{}'.format(path, f), dur, stress,
                                          match.group('name')))

                    else:
                        print f

            Utility.sort_by_index(file_list, 1)
            # print file_list

            eps_list = []
            caption_list = []

            temp_eps = []
            temp_cap = []

            for fi in file_list:
                file_path = fi[0]
                dur = fi[1]
                stress = fi[2]
                name = fi[3]

                group = find_group(t, v, name)
                color = c[group]
                # if group != 0:
                #     print v, t
                #     print group, color
                # print '\\textcolor{{{}}}{{{}}}'.format(color,name)
                name = name.replace('_', '\_')
                # {\color{red} Panda }
                temp_eps.append(file_path)
                temp_cap.append('{{\color{{{}}} {} }}'.format(color, name))

                if fig_per_line == len(temp_eps):
                    eps_list.append(temp_eps)
                    caption_list.append(temp_cap)

                    temp_eps = []
                    temp_cap = []

            eps_list.append(temp_eps)
            caption_list.append(temp_cap)

            # print len(eps_list)
            if len(eps_list) == 1: continue
            Latext_Tool.plot_all_data(eps_list, caption_list, latext_out_file)

        pass
'''

import sys

sys.path.append('/home/h1/decha/Dropbox/python_workspace/Utility/')

from tool_box.util.utility import Utility

if __name__ == '__main__':

    outpath = '/work/w2/decha/Data/GPR_data/GP_LVM_Data/Manual_labeling_stress_unstress/raw/wav/'

    source = '/home/h1/decha/data/TrainingData/wav/16k/test/'

    for ch in Utility.char_range('a', 'h'):
        Utility.make_directory('{}/{}'.format(outpath, ch))

    list = '/work/w2/decha/Data/GPR_data/GP_LVM_Data/Manual_labeling_stress_unstress/raw/stress_unstressed_label_file_index.test.txt'

    for line in Utility.read_file_line_by_line(list):
        label = line.split(' ')

        ori = label[0].split('.')[0]
        dest = label[1].split('.')[0]

        set = dest.split('_')[2][0]

        print ori, dest, set

        src = '{}/{}.wav'.format(source, ori)
        dst = '{}/{}/{}.wav'.format(outpath, set, dest)
Exemple #11
0
def run_command(feature_type, missing_data, data_object_base_path_name,
                base_out_path, input_dims, tone_list, dur_position,
                num_sampling, d1, d2):

    deltas = [[d1, d2]]

    output_name_paths = []

    for i, d in enumerate(deltas):
        outp = '{}/input_dims_{}/delta-{}_delta-delta-{}/'.format(
            base_out_path, input_dims, d[0], d[1])
        output_name_paths.append(outp)

    print 'Missing Data : {}'.format(missing_data)
    print 'Inducing points : 10 percent'

    for idx, output_name in enumerate(output_name_paths):

        delta_bool = deltas[idx][0]
        delta2_bool = deltas[idx][1]

        if missing_data:
            method_name = 'BayesianGPLVMMiniBatch_Missing'
        else:
            method_name = 'BGP_LVM'

        for tone in tone_list:

            print 'Delta : {}, Delta-Dealta : {}'.format(
                delta_bool, delta2_bool)

            data_object_path = '{}{}.pickle'.format(data_object_base_path_name,
                                                    tone)

            print 'data path ', data_object_path

            syllable_management = Utility.load_obj(data_object_path)

            if len(syllable_management.syllables_list) == 0:
                print 'No syllable in this object database : {}'.format(tone)
                print '-----------------------------------------------------------------'
                continue

            print 'Syllable all : {} Syllables'.format(
                len(syllable_management.syllables_list))

            output_path = '{}/{}_Tone_{}/'.format(output_name, method_name,
                                                  tone)

            Utility.make_directory(output_path)

            print output_path

            print 'Feature Key : {}'.format(feature_type)

            Y_full, names, tone, stress, syllable_short_long_type, syllalbe_position, phoneme, syllable_type = syllable_management.get_GP_LVM_training_data(
                feature_key=feature_type,
                dur_position=dur_position,
                delta_bool=delta_bool,
                delta2_bool=delta2_bool,
                missing_data=missing_data,
                num_sampling=num_sampling,
            )

            print 'Y full : {}'.format(np.array(Y_full).shape)

            Y, names, tone, stress, syllable_short_long_type, syllalbe_position, phoneme, syllable_type = syllable_management.get_GP_LVM_training_data(
                feature_key=feature_type,
                dur_position=dur_position,
                delta_bool=delta_bool,
                delta2_bool=delta2_bool,
                missing_data=missing_data,
                num_sampling=num_sampling,
                no_short_duration=True,
                get_only_stress=False,
                exp=False,
                subtract_typical_contour=False,
                non_unlabelled_stress=False,
                get_only_gpr_data=False)

            Latent_variable_model_Training.execute_Bayesian_GPLVM_training_with_Y_names(
                Y,
                names,
                input_dims,
                output_path,
                missing_data=False,
                max_iters=500,
                num_inducing=int(len(Y) * 0.1),
                BayesianGPLVMMiniBatch=False)

    pass
    mono_label = '/work/w2/decha/Data/GPR_speccom_data/mono/tsc/sd/'
    mono_remove_label = '/work/w2/decha/Data/GPR_speccom_data/mono_remove_silence/tsc/sd/'

    cmp_path = '/work/w2/decha/Data/GPR_speccom_data/cmp/tsc/sd/'
    out_path = '/work/w2/decha/Data/GPR_speccom_data/cmp_remove_silence/tsc/sd/'

    lf0_inpath = '/work/w2/decha/Data/GPR_speccom_data/lf0/tsc/sd/'
    mcep_inpath = '/work/w2/decha/Data/GPR_speccom_data/mcep/tsc/sd/'
    bap_inpath = '/work/w2/decha/Data/GPR_speccom_data/bap/tsc/sd/'

    lf0_outpath = '/work/w2/decha/Data/GPR_speccom_data/lf0_remove_silence/tsc/sd/'
    mcep_outpath = '/work/w2/decha/Data/GPR_speccom_data/mcep_remove_silence/tsc/sd/'
    bap_outpath = '/work/w2/decha/Data/GPR_speccom_data/bap_remove_silence/tsc/sd/'

    Utility.make_directory(out_path)
    Utility.make_directory(lf0_outpath)
    Utility.make_directory(mcep_outpath)
    Utility.make_directory(bap_outpath)

    for s in Utility.char_range('a', 'z'):
        mono_set_path = '{}/{}/'.format(mono_label, s)
        mono_remove_silence_path = '{}/{}/'.format(mono_remove_label, s)

        cmp_outpath = '{}/{}/'.format(out_path, s)

        lf0_out_path = '{}/{}/'.format(lf0_outpath, s)
        mcep_out_path = '{}/{}/'.format(mcep_outpath, s)
        bap_out_path = '{}/{}/'.format(bap_outpath, s)

        # Utility.make_directory(cmp_outpath)
Exemple #13
0
    coeffs = [1, 3, 4, 7]
    tones = ['all', 0, 1, 2, 3, 4]
    include_zero = ['include_zero_coeff', 'not_include_zero_coeff']

    for (num_coeff, tone,
         incl_zero) in itertools.product(coeffs, tones, include_zero):

        syl_dict_path = '/work/w2/decha/Data/GPR_speccom_data/Interspeech2017/tone_separated_unstress/tone_{}_dct_coeff_{}.pkl'.format(
            tone, num_coeff)

        syl_dict = Utility.load_obj(syl_dict_path)

        outpath = '/work/w2/decha/Data/GPR_speccom_data/00_syllable_level_data/dct_separated_tone_unstress/{}/{}/{}-coeff/tsc/sd/'.format(
            incl_zero, tone, num_coeff)
        Utility.make_directory(outpath)

        print outpath

        label_path = '/work/w2/decha/Data/GPR_speccom_data/00_syllable_level_data/mono/tsc/sd/'
        for s in Utility.char_range('a', 'z'):
            set_label_path = '{}/{}/'.format(label_path, s)

            set_dct_path = '{}/{}/'.format(outpath, s)
            Utility.make_directory(set_dct_path)

            for x in range(1, 51):

                name = 'tscsd{}{}'.format(s, Utility.fill_zero(x, 2))

                file_path = '{}/{}.lab'.format(set_label_path, name)
    full_path = '/work/w2/decha/Data/GPR_speccom_data/full_time/tsc/sd/'
    out_path = '/work/w2/decha/Data/GPR_speccom_data/speccom2_data/03_3level_full_time_with_stress/tsc/sd/'
    out_full_path = '/work/w2/decha/Data/GPR_speccom_data/speccom2_data/03_3level_full_with_stress/tsc/sd/'

    # for s in Utility.char_range('a', 'z'):
    for s in Utility.char_range('j', 'j'):

        if s in ['k', 'n', 'q', 's']: continue

        print s

        full_set_path = '{}/{}/'.format(full_path, s)
        out_set_path = '{}/{}/'.format(out_path, s)
        out_set_full_path = '{}/{}/'.format(out_full_path, s)

        Utility.make_directory(out_set_path)
        Utility.make_directory(out_set_full_path)

        for f in Utility.list_file(full_set_path):

            if f.startswith('.'): continue

            base = Utility.get_basefilename(f)

            full_file = '{}/{}'.format(full_set_path, f)
            # print full_file

            out_file = '{}/{}'.format(out_set_path, f)
            # print out_file

            out_full_no_time_file = '{}/{}'.format(out_set_full_path, f)
    out_path = '/work/w2/decha/Data/GPR_speccom_data/speccom2_data/utt_with_3_level_se_kernel/tsc/sd/'
    # print db_dict['tscsdv01_29']

    for ch in Utility.char_range('a', 'z'):

        if ch == 'j' : continue

        set_stress_path = '{}/{} lab/'.format(stress_path, ch)

        set_utt_base_path = '{}/{}/'.format(utt_base_path, ch)

        set_syllable_full_path = '{}/{}/'.format(syllable_full_path, ch)

        set_out_path = '{}/{}/'.format(out_path, ch)

        Utility.make_directory(set_out_path)

        if Utility.is_dir_exists(set_stress_path) & Utility.is_dir_exists(set_utt_base_path):
            print ch

            for i in xrange(1, 51):

                name = 'tscsd{}{}'.format(ch, Utility.fill_zero(i, 2))

                yaml_filename = '{}/{}.utt.yaml'.format(set_utt_base_path, name )
                if not Utility.is_file_exist(yaml_filename):
                    continue

                full_file = '{}/{}.lab'.format(set_syllable_full_path, name)

                count = [0]
    pass


if __name__ == '__main__':

    stress_data_path = '/work/w2/decha/Data/GPR_speccom_data/stress label'
    lf0_path = '/work/w2/decha/Data/GPR_speccom_data/lf0/tsc/sd/'

    out_path = '/work/w2/decha/Data/GPR_speccom_data/lf0_in_syllable/'

    plot_out_path = '/work/w2/decha/Data/GPR_speccom_data/f0_in_syllable_plot/'

    start = 'k'
    stop = 'z'

    Utility.make_directory(plot_out_path)

    for sett in Utility.char_range(start, stop):
        print sett

        set_path = '{}/{} lab/'.format(stress_data_path, sett)

        if not Utility.is_dir_exists(set_path):
            print 'Inexist : {}'.format(set_path)
            continue

        lf0_set_path = '{}/{}/'.format(lf0_path, sett)

        out_set_path = '{}/{}/'.format(out_path, sett)

        plot_set_out = '{}/{}/'.format(plot_out_path, sett)
Exemple #17
0
    r"""(?P<filename>.+)\.lab\s(?P<tsc>...)(?P<sd>..)_stust_(?P<sett>.)(?P<index>..)\.lab""",
    re.VERBOSE)

for line in files:
    # print line
    match = re.match(pattern, line)
    if match:
        tsc = match.group('tsc')
        sd = match.group('sd')
        sett = match.group('sett')
        index = match.group('index')
        filename = match.group('filename')

        print(tsc, sd, sett, index, filename)

        file_format = 'lab'

        src = '{}/{}.{}'.format(src_path, filename, file_format)
        print src

        dest = '{}/{}/{}/{}/{}{}_stust_{}{}.{}'.format(dest_path, tsc, sd,
                                                       sett, tsc, sd, sett,
                                                       index, file_format)
        print dest

        Utility.make_directory('{}/{}/{}/{}/'.format(dest_path, tsc, sd, sett))

        Utility.copyFile(src, dest)
        # Utility.copyFile
        # sys.exit()
    # print db
    Utility.save_obj(db, new_db_file)

    pass


if __name__ == '__main__':

    db_path = '/work/w2/decha/Data/GPR_speccom_data/syllable_database/01_database/'

    stress_list_path = '/work/w2/decha/Data/GPR_speccom_data/figure/plot_sort_list/02_check_stress_07_nov/'

    new_db_path = '/work/w2/decha/Data/GPR_speccom_data/syllable_database/02_add_stress_database_07_nov/'

    Utility.make_directory(new_db_path)

    for t in xrange(5):
        for f in ['nasal', 'no', 'non-nasal']:
            for v in ['long', 'short']:
                name = '{}_{}_{}'.format(t, v, f)

                print name

                db_file = '{}/{}.npy'.format(db_path, name)

                new_db_file = '{}/{}.npy'.format(new_db_path, name)

                stress_list_file = '{}/{}.list'.format(stress_list_path, name)

                # name_out_path = '{}/{}/'.format(out_path, name)
Exemple #19
0
    pass


if __name__ == '__main__':

    UNDEF_VALUE = -1.00000000e+10

    dur_path = '/work/w2/decha/Data/GPR_speccom_data/Generated_Parameter/950_GPR/dur/param_mean/'

    mono_path = '/work/w2/decha/Data/GPR_speccom_data/mono/tsc/sd/j/'

    mono_to_syl_path = '/work/w2/decha/Data/GPR_speccom_data/phones_in_syllable_duration_object/j/'

    mono_outpath = '/work/w2/decha/Data/GPR_speccom_data/Generated_Parameter/950_GPR/mono/j/'
    Utility.make_directory(mono_outpath)

    syl_outpath = '/work/w2/decha/Data/GPR_speccom_data/Generated_Parameter/950_GPR/syllable/j/'
    Utility.make_directory(syl_outpath)

    for i in range(1, 51):
        path = '{}/tscsdj{}.npy'.format(dur_path, Utility.fill_zero(i, 2))
        mono = '{}/tscsdj{}.lab'.format(mono_path, Utility.fill_zero(i, 2))

        mono_to_syl = '{}/tscsdj{}.dur'.format(mono_to_syl_path,
                                               Utility.fill_zero(i, 2))

        mono_outfile = '{}/tscsdj{}.lab'.format(mono_outpath,
                                                Utility.fill_zero(i, 2))

        syl_outfile = '{}/tscsdj{}.lab'.format(syl_outpath,
Exemple #20
0
    print 'Alpha {}, Beta {}, LF0 RMSE: {:f} in {} frames'.format(
        alpha, beta, rmse, l)

    pass


if __name__ == '__main__':

    predictive = '/work/w21/decha/Interspeech_2017/Result/03_Given_syllable_dct_with_weigth/num_dct_cov_7/'

    org_path = '/work/w2/decha/Data/GPR_speccom_data/data_before_remove_silence/lf0/tsc/sd/j/'

    tmp_path = './tmp/'

    Utility.make_directory(tmp_path)

    basename = 'tscsdj'

    vuv_path = '/work/w21/decha/Interspeech_2017/GPR_data/450/param_align/lf0/param_mean/'

    for alpha in np.arange(0.1, 2, 0.1):
        for beta in np.arange(0.1, 2, 0.1):

            alpha_beta_path = '{}/alpha_{}_beta_{}/'.format(
                predictive, alpha, beta)

            if Utility.is_dir_exists(alpha_beta_path):
                run_cal_distortion(basename, tmp_path, alpha_beta_path, alpha,
                                   beta)
    def plot_scatter(model, data_object, outpath, label_type=None, target_tone=None, name_index_list=None, phoneme_list=None, plotted_tone=None, bivariate=False, followed_list_file=None, perform_unsupervised=False, get_only_stress=False, non_unlabelled_stress=False, get_only_gpr_data=False,
                    return_after_dbscan=False, get_only_manual_data=False, no_short_duration=False):

        data = model.X.mean

        y, name_index, tone, stress, syllable_short_long_type, syllable_positions, phonemes, syllable_type = data_object.get_GP_LVM_training_data(
            Syllable.Training_feature_tonal_part_raw_remove_head_tail_interpolated , 
            dur_position=[1,2] , no_short_duration=no_short_duration, 
            num_sampling=50, get_only_stress=get_only_stress, non_unlabelled_stress=non_unlabelled_stress, get_only_gpr_data=get_only_gpr_data, get_only_manual_data=get_only_manual_data)

        # print 'Plot scatter'
        # print stress
        # sys.exit()

        # print syllable_type
        # print model.X.mean
        x = []
        y = []

        input_sensitivity = model.input_sensitivity()
        print input_sensitivity

        index = Utility.get_input_sensitivity(input_sensitivity, 3)
        print index

        data = np.array(data)

        name_index_list = np.array(name_index_list)

        index_filter = []
        for n in name_index:
            # print n
            idx = np.where( name_index_list==n ) [0]
            # print idx
            index_filter.append(idx[0])

        data = data[index_filter]

        stress = np.array(stress)

        labels_true = np.arange(len(stress), dtype=int)
        labels_true[stress == 'Stress'] = 1
        labels_true[stress == 'Unstress'] = 0

        # print len(data), len(stress)
        # print len(labels_true), set(labels_true)
        # sys.exit()

        if len(data) != len(stress):
            print 'Error data is not equal'
            return

        plt.clf()

        if perform_unsupervised:
            try:

                DBSCAN_executioner.run(data, labels_true, os.path.dirname(outpath), [index[0], index[1]], input_sensitivity)
                # Kmeans_executioner.run(data, labels_true, os.path.dirname(outpath), [index[0], index[1]], input_sensitivity)
            except:
                print 'Error at path : {}'.format(outpath)
                traceback.print_exc()

        if return_after_dbscan:
            return

        plt.clf()

        print 'Data : {}'.format(len(data))
        print 'Stress : {}'.format(len(stress))
        # print stress

        x = data[:,index[0]]
        x = data[:,1]
        y = data[:,index[1]]
        y = data[:,0]
        z = data[:,index[2]]

        print 'syllable_positions', len(syllable_positions)

        if label_type is GP_LVM_Scatter.LABEL_TYPE_STRESS:
            # Scatter.plot(x, y, outpath, label_list=stress, color=['r','b','g'])
            
            stress_index = np.where(stress == 'Stress')
            unstress_index = np.where(stress == 'Unstress')

            mask = np.ones(len(stress), dtype=bool)
            mask[unstress_index] = False
            # print stress
            # sys.exit()
            # Scatter.plot(x[mask], y[mask], outpath, label_list=stress[mask], color=['r','b','g'], bivariate=bivariate, X_bi=x[stress_index], Y_bi=y[stress_index])
            Scatter.plot(x, y, outpath, label_list=stress, color=['r','b','g'], bivariate=bivariate, X_bi=x[stress_index], Y_bi=y[stress_index])
        elif label_type is GP_LVM_Scatter.LABEL_TYPE_STRESS_3D_COLORING:
            # Scatter.plot(x, y, outpath, label_list=stress, color=['r','b','g'])
            
            stress_index = np.where(stress == 'Stress')
            unstress_index = np.where(stress == 'Unstress')
            normalized = (z-min(z))/(max(z)-min(z)) * 100
            Scatter.plot(x, y, outpath, label_list=None, color=normalized.astype(int).tolist(), cmap='gray')
        elif label_type is GP_LVM_Scatter.LABEL_TYPE_STRESS_SEP_GPR:

            gpr_file_list = []
            for idx, n in enumerate(name_index): 
                if 'gpr' in n:
                    gpr_file_list.append(idx)

            gpr_file_list = np.array(gpr_file_list)

            stress[gpr_file_list] = 'GPR_Stress'

            stress_index = np.where(stress == 'Stress')
            unstress_index = np.where(stress == 'Unstress')

            mask = np.ones(len(stress), dtype=bool)
            mask[unstress_index] = False

            Scatter.plot(x, y, outpath, label_list=stress, color=['r','b','g'], bivariate=bivariate, X_bi=x[stress_index], Y_bi=y[stress_index])
        elif label_type is GP_LVM_Scatter.LABEL_TYPE_STRESS_AND_SPLIT_TONE:

            stress_index = np.where(stress == 'Stress')
            unstress_index = np.where(stress == 'Unstress')

            tone = np.array(tone)

            mask = np.ones(len(stress), dtype=bool)
            mask[unstress_index] = False

            outpath = Utility.get_base_path(outpath)

            canplot = True

            try:
                labels_object = Utility.load_obj('{}/clustered_label.npy'.format(outpath))
                if len(labels_object)!=len(stress):
                    canplot = False
            except:
                canplot = False

            for t in set(tone):

                Utility.make_directory('{}/tone_stress_label/'.format(outpath))
                Utility.make_directory('{}/clustering_label/'.format(outpath))
                print len(x), len(y), len(tone), len(stress) 
                Scatter.plot(x[tone==t], y[tone==t], '{}/tone_stress_label/tone_{}.eps'.format(outpath, t), label_list=stress[tone==t], bivariate=bivariate, X_bi=x[stress_index], Y_bi=y[stress_index])
                if canplot:
                    'Plot label tone {}'.format(t)
                    Scatter.plot(x[tone==t], y[tone==t], '{}/clustering_label//tone_{}.eps'.format(outpath, t), label_list=labels_object[tone==t], bivariate=bivariate, X_bi=x[stress_index], Y_bi=y[stress_index])

        elif label_type is GP_LVM_Scatter.LABEL_TYPE_SYLLABLE_SHORT_LONG:
            Scatter.plot(x, y, outpath, label_list=syllable_short_long_type)
        elif label_type is GP_LVM_Scatter.LABEL_TYPE_SYLLABLE_POSITIONS:

            long_list = []
            short_list = []

            for idx, p in enumerate(phonemes):
                v = p.split('-')[1]
                if v not in Syllable.short_vowel:
                    long_list.append(idx)
                else:
                    short_list.append(idx)

            print len(long_list) , len(x)
            x = np.array(x)
            y = np.array(y)
            syllable_positions = np.array(syllable_positions)
            Scatter.plot(x[long_list], y[long_list], outpath, label_list=syllable_positions[long_list])
        elif label_type is GP_LVM_Scatter.LABEL_TYPE_TONES:
            Scatter.plot(x, y, outpath, label_list=tone, color=['r','g','b','black','yellow'])
        elif label_type is GP_LVM_Scatter.LABEL_TYPE_ONE_TONE_STRESS_UNSTRESS:  
            tone = np.array(map(str, tone))
            stress = np.core.defchararray.add(stress, '_' )
            stress_tone = np.core.defchararray.add(stress, tone)

            target_list = np.array([])
            print target_tone
            for t in target_tone:
                print t, target_list, np.where(tone == t)
                target_list = np.union1d(target_list, np.where(tone == t)[0])
            stress_tone = stress_tone[target_list.astype(int)]#np.delete(stress_tone, delete_list)
            x = x[target_list.astype(int)]#np.delete(x, delete_list)
            y = y[target_list.astype(int)]#np.delete(y, delete_list)
            Scatter.plot(x, y, outpath, label_list=stress_tone)
        elif label_type is None :
            Scatter.plot(x, y, outpath, label_list=None)
        elif label_type is GP_LVM_Scatter.LABEL_TYPE_SYLLABLE_IN_MANUAL_PHRASE:
            name_index = np.array(name_index)
            # print name_index
            single_list = np.array(Utility.load_obj(name_index_list['single']))
            followed_by_sil_list = np.array(Utility.load_obj(name_index_list['followed_by_sil']))
            poly_list = np.array(Utility.load_obj(name_index_list['poly']))

            all_union = []

            single_indices = [] 
            for syl in single_list:
                single_indices = np.union1d(single_indices, np.where( name_index == syl)[0])
            
            followed_by_sil_indices = [] 
            for syl in followed_by_sil_list:
                followed_by_sil_indices = np.union1d(followed_by_sil_indices, np.where( name_index == syl)[0])

            poly_indices = [] 
            for syl in poly_list:
                poly_indices = np.union1d(poly_indices, np.where( name_index == syl)[0])

            name_index[single_indices.astype(int)] = 'Single '
            name_index[followed_by_sil_indices.astype(int)] = 'Followed'
            name_index[poly_indices.astype(int)] = 'Poly'

            all_union = np.union1d(all_union, single_indices)
            all_union = np.union1d(all_union, followed_by_sil_indices)
            all_union = np.union1d(all_union, poly_indices)

            mask = np.ones(len(name_index), dtype=bool)
            mask[all_union.astype(int)] = False
            name_index[mask] = 'Other'

            Scatter.plot(x, y, outpath, label_list=name_index, color=['r','g','b','y'])

        elif label_type is GP_LVM_Scatter.LABEL_TYPE_SYLLABLE_IN_MANUAL_PHRASE_PLUS_SHORT_LONG_SYLLABLE:
            
            name_index = np.array(name_index)
            # print name_index
            single_list = np.array(Utility.load_obj(name_index_list['single']))
            followed_by_sil_list = np.array(Utility.load_obj(name_index_list['followed_by_sil']))
            poly_list = np.array(Utility.load_obj(name_index_list['poly']))

            all_union = []

            single_indices = [] 
            for syl in single_list:
                single_indices = np.union1d(single_indices, np.where( name_index == syl)[0])
            
            followed_by_sil_indices = [] 
            for syl in followed_by_sil_list:
                followed_by_sil_indices = np.union1d(followed_by_sil_indices, np.where( name_index == syl)[0])

            poly_indices = [] 
            for syl in poly_list:
                poly_indices = np.union1d(poly_indices, np.where( name_index == syl)[0])

            name_index[single_indices.astype(int)] = 'Single '
            name_index[followed_by_sil_indices.astype(int)] = 'Followed'
            name_index[poly_indices.astype(int)] = 'Poly'

            all_union = np.union1d(all_union, single_indices)
            all_union = np.union1d(all_union, followed_by_sil_indices)
            all_union = np.union1d(all_union, poly_indices)

            mask = np.ones(len(name_index), dtype=bool)
            mask[all_union.astype(int)] = False
            name_index[mask] = 'Other'

            outpath = outpath.split('.')[0]

            syllable_short_long_type = np.array(syllable_short_long_type)
            short_list = np.where(syllable_short_long_type=='short')[0]
            long_list = np.where(syllable_short_long_type=='long')[0]

            # print short_list, long_list

            Scatter.plot(x[short_list], y[short_list], '{}_short.pdf'.format(outpath), label_list=name_index[short_list], color=['r','g','b','y'])
            Scatter.plot(x[long_list], y[long_list], '{}_long.pdf'.format(outpath), label_list=name_index[long_list], color=['r','g','b','y'])

        elif label_type is GP_LVM_Scatter.LABEL_TYPE_PHONEME:
            phonemes = np.array(phonemes)
            stress = np.array(stress)
            for phoneme in phoneme_list:
                if plotted_tone != '01234':
                    if plotted_tone not in phoneme: continue

                target_index = np.where(phonemes == phoneme)
                stress_index = np.where(stress == 'Stress')
                # print stress_index

                outpath = outpath.split('.')[0]
                Scatter.plot(x[target_index], y[target_index], '{}_{}.pdf'.format(outpath, phoneme), label_list=stress[target_index], bivariate=True, X_bi=x[stress_index], Y_bi=y[stress_index], title=phoneme, xlim=(-4.4657748693986417, 8.1238328278216105), ylim=(-7.2366812187855185, 6.1187134324317736))

        elif label_type is GP_LVM_Scatter.LABEL_TYPE_SYLLABLE_TYPE:

            syllable_type = np.array(syllable_type)
            stress = np.array(stress)
            types = set(syllable_type)

            for typ in types:

                print typ

                typ_index = np.where(syllable_type==typ)

                sub_stress = stress[typ_index]
                sub_x = x[typ_index]
                sub_y = y[typ_index]
                
                stress_index = np.where(sub_stress == 'Stress')
                unstress_index = np.where(sub_stress == 'Unstress')

                mask = np.ones(len(sub_stress), dtype=bool)
                mask[unstress_index] = False

                outpath = outpath.split('.')[0]

                Scatter.plot(sub_x, sub_y, '{}_{}.pdf'.format(outpath, typ), label_list=sub_stress, color=['r','b','g'], bivariate=False, X_bi=sub_x[stress_index], Y_bi=sub_y[stress_index], title=typ, xlim=(-4.4657748693986417, 8.1238328278216105), ylim=(-7.2366812187855185, 6.1187134324317736))

        elif label_type is GP_LVM_Scatter.LABEL_TYPE_FOLLOWED_BY_SIL:
            followed_list = Utility.load_obj(followed_list_file)
            fow_index = []
            name_index = np.array(name_index)
            for f in followed_list:
                k = np.where(name_index == f)[0]
                for kk in k:
                    fow_index.append(kk.astype(int))

            # print fow_index

            stress = np.array(stress)
            stress_index = np.where(stress == 'Stress')
            unstress_index = np.where(stress == 'Unstress')

            stress[stress_index] = 'Unstress'
            stress[fow_index] = 'Stress'

            Scatter.plot(x, y, outpath, label_list=stress, color=['r','b','g'], bivariate=True, X_bi=x[fow_index], Y_bi=y[fow_index])

            tone = np.array(tone)
            for t in [0,1,2,3,4]:

                x_tone = x[np.where(tone == t)]
                y_tone = y[np.where(tone == t)]
                stress_tone = stress[np.where(tone == t)]
                tone_path = '{}_{}.pdf'.format(outpath.split('.')[0], t)
                Scatter.plot(x_tone, y_tone, tone_path, label_list=stress_tone, color=['r','b','g'], bivariate=True, X_bi=x[fow_index], Y_bi=y[fow_index], title='Tone {}'.format(t), xlim=(-3.7420549236630576, 3.7939531202951904), ylim=(-4.2426927228030289, 6.3913714950885101))

            base_path = outpath.split('.')[0] 
            Utility.save_obj(x, '{}_{}.pickle'.format(base_path,'x'))
            Utility.save_obj(y, '{}_{}.pickle'.format(base_path,'y'))
            Utility.save_obj(stress, '{}_{}.pickle'.format(base_path,'stress_followed'))
            Utility.save_obj(tone, '{}_{}.pickle'.format(base_path,'tone'))

        # elif label_type is GP_LVM_Scatter.LABEL_TYPE_SEPARATED_UNSUPERVISED_GROUP:


        pass
Exemple #22
0
        plt.savefig('hist.eps')

        Utility.save_obj(errors, './errors_dict.pkl')

        rmse = np.sqrt(sklearn.metrics.mean_squared_error(
            true, dct_regen)) * 1200 / np.log(2)
        print 'Coeff {} all rmse : '.format(coeff), rmse

        Utility.sort_by_index(errors_tuple, 1)
        Utility.write_to_file_line_by_line('./errors_sorted.txt', errors_tuple)

        print len(syl_dct)

        base = '/work/w2/decha/Data/GPR_speccom_data/Interspeech2017/tone_separated/'

        Utility.make_directory(base)

        Utility.save_obj(
            syl_dct,
            '/work/w2/decha/Data/GPR_speccom_data/Interspeech2017/tone_separated/tone_all_dct_coeff_{}.pkl'
            .format(coeff))

        for t in range(5):

            print t, len(tone_dct_dict[t])

            Utility.save_obj(
                tone_dct_dict[t],
                '/work/w2/decha/Data/GPR_speccom_data/Interspeech2017/tone_separated/tone_{}_dct_coeff_{}.pkl'
                .format(t, coeff))
    basename = 'tscsdj'

    a_start = 1.0
    a_end = 1.1

    b_start = 0.01
    b_end = 0.1

    b_incre = 0.01

    for alpha in np.arange(a_start, a_end, 0.1):
        for beta in np.arange(b_start, b_end, b_incre):

            outpath = '/work/w21/decha/Interspeech_2017/Result/03_Given_syllable_dct_with_weigth/num_dct_cov_{}/alpha_{}_beta_{}/'.format(
                num_coeff, alpha, beta)
            Utility.make_directory(outpath)

            for num in range(1, 51):

                name = '{}{}'.format(basename, Utility.fill_zero(num, 2))

                outfilepath = '{}/{}/'.format(outpath, name)
                Utility.make_directory(outfilepath)

                base_path = '{}/{}/'.format(frame_predicted_lf0_path, name)
                label_path = '{}/{}.lab'.format(syl_duration_path, name)

                config = {
                    'base_path': base_path,
                    'label_path': label_path,
                    'name': name,
    ph0_optimal = np.arange(start_ph_0, end_ph_0, increment)

    data_dict = {
        250 : 'e',
        450 : 'i',
        950 : 't'
    }

    now = datetime.datetime.now()

    method = '/{}_{}_{}/Syllable_training_size_{}_block_size_{}_num_coeff_{}/tone_{}/'.format(method_name, phone_type, now.strftime("%Y-%m-%d"), training_size, block_size, num_coeff, tone)

    outname = '{}/{}/'.format(mainoutpath, method)

    non_optimal_path = '{}/raw_calculation/'.format(outname)
    Utility.make_directory(non_optimal_path)

    #------------ General info--------------#

    original_path = '/work/w2/decha/Data/GPR_speccom_data/lf0/tsc/sd/j/'

    koriyama_gen_path = '/work/w21/decha/Interspeech_2017/GPR_data/450/param_align/lf0/param_mean/'

    # syl_duration_path = '/work/w2/decha/Data/GPR_speccom_data/00_syllable_level_data/mono_syllable_remove_silence/tsc/sd/j/'
    syl_duration_path = '/work/w2/decha/Data/GPR_speccom_data/00_syllable_level_data/full_time_syllable_remove_silence/tsc/sd/j/'
    ph_duration_path = '/work/w2/decha/Data/GPR_speccom_data/mono/tsc/sd/j/'

    phone_in_syllable_object_path = '/work/w2/decha/Data/GPR_speccom_data/phones_in_syllable_duration_object/j/'

    stress_path = '/work/w2/decha/Data/GPR_speccom_data/00_syllable_level_data/stress_list/j/'
        out.append(syl)

        # sys.exit(0)

    Utility.save_obj(out, name_out_path)

    pass


if __name__ == '__main__':

    db_path = '/work/w2/decha/Data/GPR_speccom_data/syllable_database/03_data_with_missing_for_training/'
    out_path = '/work/w2/decha/Data/GPR_speccom_data/syllable_database/04_data_with_intepolate_for_training/'

    Utility.make_directory(out_path)

    for t in xrange(5):
        for f in ['nasal', 'no', 'non-nasal']:
            for v in ['long', 'short']:
                name = '{}_{}_{}'.format(t, v, f)
                db_file = '{}/{}.npy'.format(db_path, name)

                name_out_path = '{}/{}.npy'.format(out_path, name)

                print name

                if Utility.is_file_exist(db_file):
                    gen_data(db_file, name_out_path)

                    # sys.exit()
pattern = re.compile(
    r"""(?P<time>.+\s.+)\s(?P<syllable>.+)/A:.+/S:.+/B:.+\-(?P<tone>.+)\+.+/C:.+\-(?P<index>.+)_.+\+.+/D:.+""",
    re.VERBOSE)

out_p = '/work/w2/decha/Data/GPR_data/label/03_GPR_syllable_level/syllable_with_index/tsc/sd/'

for s in set_list:
    target_path = '{}/{}/'.format(syllable_files_path, s)
    print target_path
    for f in Utility.list_file(target_path):
        if f.startswith('.'): continue

        new_file = []

        Utility.make_directory('{}/{}/'.format(out_p, s))

        out_path = '{}/{}/{}'.format(out_p, s, f)
        print out_path

        for line in Utility.read_file_line_by_line('{}/{}'.format(
                target_path, f)):
            # print line
            match = re.match(pattern, line)
            if match:
                time = match.group('time')
                # print time
                syllable = match.group('syllable')
                # print syllable
                index = match.group('index')
                # print index
    vuv_predicted_path = '/work/w16/decha/decha_w16/spec_com_work_space/Speech_synthesis/05a_GPR/testrun/out/tsc/a-i/infer/a-i/demo/seed-00/M-1024/B-1024/num_iters-5/vuv/predictive_distribution/'

    basename = 'tscsdj'

    for b in np.arange(start, end, increment):

        beta = b

        print 'Beta : ', b

        outbase = '{}/num_dct_cov_{}/'.format(outname, num_coeff)
        outpath = '{}/Beta_{}/lf0/'.format(outbase, beta)
        figure_path = '{}/Beta_{}/fig/'.format(outbase, beta)

        Utility.make_directory(outpath)
        Utility.make_directory(figure_path)

        for num in range(1, 51):

            name = '{}{}'.format(basename, Utility.fill_zero(num, 2))

            print name

            outfile = '{}/{}.npy'.format(outpath, name)
            # Utility.make_directory(outfilepath)

            base_path = '{}/{}/'.format(frame_predicted_lf0_path, name)
            label_path = '{}/{}.lab'.format(syl_duration_path, name)

            var_path = '{}/inv_dimension_cov.npy'.format(
Exemple #28
0
    stress_type = str(args.stress_type)

    print args

    data_dict = {250: 'e', 450: 'i', 950: 't'}

    now = datetime.datetime.now()

    method = '/{}_{}_{}/Syllable_training_size_{}_block_size_{}_num_coeff_{}/tone_{}/'.format(
        method_name, phone_type, now.strftime("%Y-%m-%d"), training_size,
        block_size, num_coeff, tone)

    outname = '{}/{}/'.format(mainoutpath, method)

    non_optimal_path = '{}/raw_calculation/'.format(outname)
    Utility.make_directory(non_optimal_path)

    #------------ General info--------------#

    original_path = '/work/w2/decha/Data/GPR_speccom_data/lf0/tsc/sd/j/'

    koriyama_gen_path = '/work/w21/decha/Interspeech_2017/GPR_data/450/param_align/lf0/param_mean/'

    # syl_duration_path = '/work/w2/decha/Data/GPR_speccom_data/00_syllable_level_data/mono_syllable_remove_silence/tsc/sd/j/'
    syl_duration_path = '/work/w2/decha/Data/GPR_speccom_data/00_syllable_level_data/full_time_syllable_remove_silence/tsc/sd/j/'
    ph_duration_path = '/work/w2/decha/Data/GPR_speccom_data/mono/tsc/sd/j/'

    phone_in_syllable_object_path = '/work/w2/decha/Data/GPR_speccom_data/phones_in_syllable_duration_object/j/'

    stress_path = '/work/w2/decha/Data/GPR_speccom_data/00_syllable_level_data/stress_list/j/'
Exemple #29
0
    db_path = '/work/w2/decha/Data/GPR_speccom_data/syllable_database/06_normalize_of_04_no_duration/'

    out_path = '/work/w23/decha/decha_w23/Second_Journal/Latent_space_training_result/05_02a_with_no_duration/input_dim_10/'

    print out_path

    for t in [0]:
        for f in ['nasal', 'no', 'non-nasal']:
            for v in ['long', 'short']:
                name = '{}_{}_{}'.format(t, v, f)
                db_file = '{}/{}.npy'.format(db_path, name)

                name_out_path = '{}/{}/'.format(out_path, name)

                Utility.make_directory(name_out_path)

                if Utility.is_file_exist(db_file):
                    run_training(db_file, name_out_path)

    # t = '4'
    # v = 'long'
    # f = 'no'

    # name = '{}_{}_{}'.format(t, v, f)
    # db_file = '{}/{}.npy'.format(db_path, name)

    # name_out_path = '{}/{}/'.format(out_path, name)

    # Utility.make_directory(name_out_path)
import sys

sys.path.append('/home/h1/decha/Dropbox/python_workspace/Utility/')

sys.path.append('../')

from tool_box.util.utility import Utility

Utility.make_directory(
    '/work/w21/decha/Interspeech_2017/Speech_synthesis/04_syllable_level_3_dct/testrun/out/tsc/a-a/hmm/phone_clustering/dur/'
)

Utility.make_directory(
    '/work/w21/decha/Interspeech_2017/Speech_synthesis/04_syllable_level_3_dct/testrun/out/tsc/a-i/hmm/phone_clustering/dur/'
)

Utility.make_directory(
    '/work/w21/decha/Interspeech_2017/Speech_synthesis/04_syllable_level_3_dct/testrun/out/tsc/a-t/hmm/phone_clustering/dur/'
)