def trainCURRENNT(model_dir):

    os.chdir(model_dir)
    display.self_print('******** train config ******\n', 'highlight')
    os.system("cat ./%s" % (cfg.nnModelCfgname))
    display.self_print('****************************\n', 'highlight')

    runCmd = '%s --options_file %s --verbose 1' % (cfg.path_currennt,
                                                   cfg.nnModelCfgname)
    runCmd = runCmd + ' >%s 2>%s' % (cfg.tmp_network_trn_log,
                                     cfg.tmp_network_trn_err)

    display.self_print("GPU job submitted. Please wait until terminated.",
                       'ok')
    display.self_print("Please open another terminal to check nvidia-smi",
                       'ok')

    display.self_print(
        "Also check %s" % (os.path.join(model_dir, cfg.tmp_network_trn_log)),
        'ok')
    display.self_print(
        "Also check %s" % (os.path.join(model_dir, cfg.tmp_network_trn_err)),
        'ok')
    exe_cmd(runCmd, cfg.debug)
    display.self_print_with_date(
        'Processed terminated. Please check %s %s' %
        (os.path.join(model_dir, cfg.tmp_network_trn_log),
         os.path.join(model_dir, cfg.tmp_network_trn_err)), 'ok')
Exemplo n.º 2
0
    print("Error: cannot load library: ", sys.argv[1])
    quit()
sys.path.append(cfg.path_pyTools)
from pyTools import display
from ioTools import readwrite


def exe_cmd(cmd, debug=False):

    display.self_print(cmd + '\n', 'highlight')
    if not debug:
        os.system(cmd)


if cfg.step3:
    display.self_print_with_date('Step3. Generating', 'h')

    if os.path.dirname(cfg.tmp_test_data_dir):
        tmp_test_data_dir = cfg.tmp_test_data_dir
    else:
        tmp_test_data_dir = os.getcwd() + os.path.sep + cfg.tmp_test_data_dir
    tmp_data_scp_dir = tmp_test_data_dir + os.path.sep + cfg.tmp_scp_name
    tmp_test_lst = tmp_data_scp_dir + os.path.sep + 'test.lst'
    tmp_idx_dir = tmp_test_data_dir + os.path.sep + cfg.tmp_idx_dir

    tmp_nc_dir = tmp_test_data_dir + os.path.sep + cfg.tmp_nc_dir
    tmp_sub_nc_dir = tmp_nc_dir + os.path.sep + cfg.tmp_nc_dir_test
    tmp_test_nc_scp = tmp_sub_nc_dir + os.path.sep + 'data.scp'

    # mean and std should have been written into the model, no need to read again
    # tmp_mv_data = os.getcwd() + os.path.sep + cfg.tmp_name_mean_file
Exemplo n.º 3
0
    quit()
sys.path.append(cfg.path_pyTools)

from pyTools import display
from ioTools import readwrite


def exe_cmd(cmd, debug=False):

    display.self_print(cmd + '\n', 'highlight')
    if not debug:
        os.system(cmd)


if cfg.step2:
    display.self_print_with_date('Step2. model training', 'h')

    tmp_network_dir = cfg.model_dir
    tmp_network_file = tmp_network_dir + os.path.sep + cfg.network_name
    tmp_trn_config_template = os.getcwd(
    ) + os.path.sep + cfg.network_trn_config

    tmp_data_dir = os.getcwd() + os.path.sep + cfg.tmp_data_dir
    tmp_nc_dir = tmp_data_dir + os.path.sep + cfg.tmp_nc_dir
    tmp_trn_nc_dir = tmp_nc_dir + os.path.sep + cfg.tmp_nc_dir_train
    tmp_trn_nc_scp = tmp_trn_nc_dir + os.path.sep + 'data.scp'
    tmp_val_nc_dir = tmp_nc_dir + os.path.sep + cfg.tmp_nc_dir_val
    tmp_val_nc_scp = tmp_val_nc_dir + os.path.sep + 'data.scp'

    tmp_mv_data = os.getcwd() + os.path.sep + cfg.tmp_name_mean_file
Exemplo n.º 4
0
            uvCmd = 'python %s %s %s %s %s %s' % (
                uvScript, testDataDir, cfg.lf0UVExternalThre, cfg.lf0ext,
                cfg.lf0UVExternalExt, cfg.lf0UVExternalDir)
        exe_cmd(uvCmd, cfg.debug)

    if cfg.lf02f0:
        f0Script = os.path.join(cfg.path_pyTools, 'speechTools/f0convert.py')
        f0Cmd = 'python %s %s %s %s' % (f0Script, testDataDir, cfg.lf0ext,
                                        cfg.f0ext)
        exe_cmd(f0Cmd, cfg.debug)


if __name__ == "__main__":
    # prepare test data
    if cfg.step03:
        display.self_print_with_date('Step3. Generating from networks', 'h')

        if cfg.step03Prepare_DATA is True:
            testDataDirs = prepareData(cfg.nnDataDirNameTest)
        else:
            testDataDirs = []
            display.self_print('Skip packaing data', 'highlight')

        # for each test data dir
        for testDataDir in testDataDirs:
            display.self_print(testDataDir, 'highlight')
            if cfg.step03NNGen is True:
                # generate output data (HTK format) from CURRENNT
                genSynCfg(testDataDir)
                # extract the output features from the HTK genreated by CURRENNT
                genSplit(cfg.outputDir)
Exemplo n.º 5
0
                                                cfg.outputExt):
            outputScpList.append(dataSaveDir + os.path.sep + featName + '.scp')

        # calculate mean and std
        if dataPart == cfg.computMeanStdOn and cfg.step01Prepare_MV is True:
            display.self_print('Calculating mean and std', 'highlight')

            meanStdTool.meanStdNormMask(
                inputScpList, cfg.inputDim, cfg.inputNormMask,
                dataSaveDir + os.path.sep + cfg.nnDataInputMV)
            display.self_print(
                "\nSave input mean-std as %s" %
                (os.path.join(dataSaveDir, cfg.nnDataInputMV)), 'highlight')

            meanStdTool.meanStdNormMask(
                outputScpList, cfg.outputDim, cfg.outputNormMask,
                dataSaveDir + os.path.sep + cfg.nnDataOutputMV)
            display.self_print(
                "\nSave output mean-std as %s" %
                (os.path.join(dataSaveDir, cfg.nnDataOutputMV)), 'highlight')
        else:
            display.self_print('skip calculating mean and std', 'highlight')


if __name__ == "__main__":
    if cfg.step01:
        display.self_print_with_date('Step1. preparing data', 'h')
        prepareData()
    else:
        display.self_print_with_date('skip step1(preparing data)', 'h')
                       'ok')

    display.self_print(
        "Also check %s" % (os.path.join(model_dir, cfg.tmp_network_trn_log)),
        'ok')
    display.self_print(
        "Also check %s" % (os.path.join(model_dir, cfg.tmp_network_trn_err)),
        'ok')
    exe_cmd(runCmd, cfg.debug)
    display.self_print_with_date(
        'Processed terminated. Please check %s %s' %
        (os.path.join(model_dir, cfg.tmp_network_trn_log),
         os.path.join(model_dir, cfg.tmp_network_trn_err)), 'ok')


if __name__ == '__main__':

    if cfg.step02:
        display.self_print_with_date('Step2. network training', 'h')

        if not os.path.isdir(cfg.model_dir):
            raise Exception("Error: cannot find %s" % (cfg.model_dir))

        if cfg.step02train_CFG:
            prepareCURRENNT(cfg.model_dir)

        if cfg.step02train_TRAIN:
            trainCURRENNT(cfg.model_dir)
    else:
        display.self_print_with_date('skip step2(network training)', 'h')
except ImportError:
    print("Error: cannot load library: ", sys.argv[1])
    quit()
sys.path.append(cfg.path_pyTools)
from pyTools import display


def exe_cmd(cmd, debug=False):

    display.self_print(cmd + '\n', 'highlight')
    if not debug:
        os.system(cmd)


if cfg.step1:
    display.self_print_with_date('Step1. preparing data', 'h')

    assert len(cfg.step1s) == 5, 'len(step1s) should be 5 %s' % (sys.argv[1])

    if os.path.dirname(cfg.tmp_data_dir):
        tmp_data_dir = cfg.tmp_data_dir
    else:
        tmp_data_dir = os.getcwd() + os.path.sep + cfg.tmp_data_dir
    tmp_data_scp_dir = tmp_data_dir + os.path.sep + cfg.tmp_scp_name
    tmp_train_lst = tmp_data_scp_dir + os.path.sep + cfg.tmp_scp_train_name
    tmp_val_lst = tmp_data_scp_dir + os.path.sep + cfg.tmp_scp_val_name
    tmp_idx_dir = tmp_data_dir + os.path.sep + cfg.tmp_idx_dir
    tmp_wav_mu_dir = tmp_data_dir + os.path.sep + cfg.tmp_wav_mu_law_dir
    tmp_wav_float_dir = tmp_data_dir + os.path.sep + cfg.tmp_wav_float_dir

    try: