def voicing_measures(ref_voicing, est_voicing):
    """Compute the voicing recall and false alarm rates given two voicing
    indicator sequences, one as reference (truth) and the other as the estimate
    (prediction).  The sequences must be of the same length.

    Examples
    --------
    >>> ref_time, ref_freq = mir_eval.io.load_time_series('ref.txt')
    >>> est_time, est_freq = mir_eval.io.load_time_series('est.txt')
    >>> (ref_v, ref_c,
    ...  est_v, est_c) = mir_eval.melody.to_cent_voicing(ref_time,
    ...                                                  ref_freq,
    ...                                                  est_time,
    ...                                                  est_freq)
    >>> recall, false_alarm = mir_eval.melody.voicing_measures(ref_v,
    ...                                                        est_v)

    Parameters
    ----------
    ref_voicing : np.ndarray
        Reference boolean voicing array
    est_voicing : np.ndarray
        Estimated boolean voicing array

    Returns
    -------
    vx_recall : float
        Voicing recall rate, the fraction of voiced frames in ref
        indicated as voiced in est
    vx_false_alarm : float
        Voicing false alarm rate, the fraction of unvoiced frames in ref
        indicated as voiced in est

    """
    validate_voicing(ref_voicing, est_voicing)
    ref_voicing = ref_voicing.astype(bool)
    est_voicing = est_voicing.astype(bool)
    # When input arrays are empty, return 0 by special case
    if ref_voicing.size == 0 or est_voicing.size == 0:
        return 0.

    # How voicing is computed
    #        | ref_v | !ref_v |
    # -------|-------|--------|
    # est_v  |  TP   |   FP   |
    # -------|-------|------- |
    # !est_v |  FN   |   TN   |
    # -------------------------

    TP = (ref_voicing*est_voicing).sum()
    FP = ((ref_voicing == 0)*est_voicing).sum()
    FN = (ref_voicing*(est_voicing == 0)).sum()
    TN = ((ref_voicing == 0)*(est_voicing == 0)).sum()

    # Voicing recall = fraction of voiced frames according the reference that
    # are declared as voiced by the estimate
    if TP + FN == 0:
        vx_recall = 0.
    else:
        vx_recall = TP/float(TP + FN)

    # Voicing false alarm = fraction of unvoiced frames according to the
    # reference that are declared as voiced by the estimate
    if FP + TN == 0:
        vx_false_alm = 0.
    else:
        vx_false_alm = FP/float(FP + TN)

    return vx_recall, vx_false_alm