Exemplo n.º 1
0
def compute_distortions(y_static,
                        y_hat_static,
                        Y_data_mean,
                        Y_data_std,
                        lengths=None):
    if hp.name == "acoustic":
        mgc, lf0, vuv, bap = split_streams(y_static, Y_data_mean, Y_data_std)
        mgc_hat, lf0_hat, vuv_hat, bap_hat = split_streams(
            y_hat_static, Y_data_mean, Y_data_std)
        try:
            f0_mse = metrics.lf0_mean_squared_error(lf0,
                                                    vuv,
                                                    lf0_hat,
                                                    vuv_hat,
                                                    lengths=lengths,
                                                    linear_domain=True)
        except ZeroDivisionError:
            f0_mse = np.nan

        distortions = {
            "mcd": metrics.melcd(mgc[:, :, 1:],
                                 mgc_hat[:, :, 1:],
                                 lengths=lengths),
            "bap_mcd": metrics.melcd(bap, bap_hat, lengths=lengths) / 10.0,
            "f0_rmse": np.sqrt(f0_mse),
            "vuv_err": metrics.vuv_error(vuv, vuv_hat, lengths=lengths),
        }
    elif hp.name == "duration":
        y_static_invscale = P.inv_scale(y_static, Y_data_mean, Y_data_std)
        y_hat_static_invscale = P.inv_scale(y_hat_static, Y_data_mean,
                                            Y_data_std)
        distortions = {
            "dur_rmse":
            math.sqrt(
                metrics.mean_squared_error(y_static_invscale,
                                           y_hat_static_invscale,
                                           lengths=lengths))
        }
    elif hp.name == "vc":
        static_dim = hp.order
        y_static_invscale = P.inv_scale(y_static, Y_data_mean[:static_dim],
                                        Y_data_std[:static_dim])
        y_hat_static_invscale = P.inv_scale(y_hat_static,
                                            Y_data_mean[:static_dim],
                                            Y_data_std[:static_dim])
        distortions = {
            "mcd":
            metrics.melcd(y_static_invscale,
                          y_hat_static_invscale,
                          lengths=lengths)
        }
    else:
        assert False

    return distortions
Exemplo n.º 2
0
def compute_distortions(pred_out_feats, out_feats, lengths, out_scaler):
    assert pred_out_feats.shape == out_feats.shape
    out_feats = out_scaler.inverse_transform(out_feats)
    pred_out_feats = out_scaler.inverse_transform(pred_out_feats)

    dist = {}
    try:
        dist["ObjEval_RMSE"] = np.sqrt(
            metrics.mean_squared_error(out_feats,
                                       pred_out_feats,
                                       lengths=lengths))
    except ZeroDivisionError:
        pass

    return dist