示例#1
0
def predict_from_textgrid(wav_filename, preds_filename, textgrid_filename, textgrid_tier):

    print wav_filename

    if os.path.exists(preds_filename):
        os.remove(preds_filename)

    textgrid = TextGrid()

    # read TextGrid
    textgrid.read(textgrid_filename)

    # extract tier names
    tier_names = textgrid.tierNames()

    if textgrid_tier in tier_names:
        tier_index = tier_names.index(textgrid_tier)
        # run over all intervals in the tier
        for interval in textgrid[tier_index]:
            if re.search(r'\S', interval.mark()):
                tmp_features_filename = generate_tmp_filename("features")
                tmp_preds = generate_tmp_filename("preds")
                features.create_features(wav_filename, tmp_features_filename, interval.xmin(), interval.xmax())
                easy_call("th load_estimation_model.lua " + tmp_features_filename + ' ' + tmp_preds)
                csv_append_row(tmp_preds, preds_filename)
    else:  # process first tier
        for interval in textgrid[0]:
            if re.search(r'\S', interval.mark()):
                tmp_features_filename = generate_tmp_filename("features")
                tmp_preds = generate_tmp_filename("preds")
                features.create_features(wav_filename, tmp_features_filename, interval.xmin(), interval.xmax())
                easy_call("th load_estimation_model.lua " + tmp_features_filename + ' ' + tmp_preds)
                csv_append_row(tmp_preds, preds_filename)
示例#2
0
def predict_from_times(wav_filename, preds_filename, begin, end):
    tmp_features_filename = tempfile._get_default_tempdir() + "/" + next(tempfile._get_candidate_names()) + ".txt"
    print tmp_features_filename

    if begin > 0.0 or end > 0.0:
        features.create_features(wav_filename, tmp_features_filename, begin, end)
        easy_call("th load_estimation_model.lua " + tmp_features_filename + ' ' + preds_filename)
    else:
        features.create_features(wav_filename, tmp_features_filename)
        easy_call("th load_tracking_model.lua " + tmp_features_filename + ' ' + preds_filename)
示例#3
0
def predict_from_times(wav_filename, preds_filename, begin, end):
    tmp_features_filename = tempfile._get_default_tempdir() + "/" + next(
        tempfile._get_candidate_names()) + ".txt"
    print tmp_features_filename

    if begin > 0.0 or end > 0.0:
        features.create_features(wav_filename, tmp_features_filename, begin,
                                 end)
        easy_call("th load_estimation_model.lua " + tmp_features_filename +
                  ' ' + preds_filename)
    else:
        features.create_features(wav_filename, tmp_features_filename)
        easy_call("th load_tracking_model.lua " + tmp_features_filename + ' ' +
                  preds_filename)
示例#4
0
def predict_from_textgrid(wav_filename, preds_filename, textgrid_filename,
                          textgrid_tier):

    print wav_filename

    if os.path.exists(preds_filename):
        os.remove(preds_filename)

    textgrid = TextGrid()

    # read TextGrid
    textgrid.read(textgrid_filename)

    # extract tier names
    tier_names = textgrid.tierNames()

    if textgrid_tier in tier_names:
        tier_index = tier_names.index(textgrid_tier)
        # run over all intervals in the tier
        for interval in textgrid[tier_index]:
            if re.search(r'\S', interval.mark()):
                print interval.mark()
                tmp_features_filename = generate_tmp_filename("features")
                tmp_preds = generate_tmp_filename("preds")
                features.create_features(wav_filename, tmp_features_filename,
                                         interval.xmin(), interval.xmax())
                easy_call("th load_estimation_model.lua " +
                          tmp_features_filename + ' ' + tmp_preds)
                csv_append_row(tmp_preds, preds_filename)
    else:  # process first tier
        for interval in textgrid[0]:
            if re.search(r'\S', interval.mark()):
                tmp_features_filename = generate_tmp_filename("features")
                tmp_preds = generate_tmp_filename("preds")
                features.create_features(wav_filename, tmp_features_filename,
                                         interval.xmin(), interval.xmax())
                easy_call("th load_estimation_model.lua " +
                          tmp_features_filename + ' ' + tmp_preds)
                csv_append_row(tmp_preds, preds_filename)