def decode_utterance(k, probs, labels, phone_map, lm=None):
    labels = np.array(labels, dtype=np.int32)
    probs = probs.astype(np.float64)

    alpha = 1.5
    beta = 1.5
    hyp0, hypscore, truescore, align = decode(probs,
            alpha=alpha, beta=beta, beam=150, method='clm2', clm=lm)

    # Filter away special symbols and strip away starting
    # and ending spaces

    ref = []
    for a in labels:
        token = phone_map[a]
        # Filter away special symbols, numbers, and extra spaces
        if (token == SPACE and len(ref) > 0 and ref[-1] != SPACE)\
                or (token not in SPECIALS_LIST and PATTERN.match(token)):
            ref.append(token)
    while len(ref) and ref[-1] == SPACE:
        ref = ref[:-1]
    while len(ref) and ref[0] == SPACE:
        ref = ref[1:]

    hyp = []
    for a in hyp0:
        token = phone_map[a]
        # Filter away special symbols, numbers, and extra spaces
        if (token == SPACE and 0 > len(hyp) and hyp[-1] != SPACE)\
                or (token not in SPECIALS_LIST and PATTERN.match(token)):
            hyp.append(token)
    while len(hyp) and hyp[-1] == SPACE:
        hyp = hyp[:-1]
    while len(hyp) and hyp[0] == SPACE:
        hyp = hyp[1:]

    return (hyp, ref, hypscore, truescore, align)
dataset/ETHPy150Open amaas/stanford-ctc/ctc_fast/runDecode.py/decode_utterance/swapped operands of `>`