nemo/collections/asr/helpers.py
def __ctc_decoder_predictions_tensor(tensor, labels):
    """
    Decodes a sequence of labels to words
    """
    blank_id = len(labels)
    hypotheses = []
    labels_map = dict([(i, labels[i]) for i in range(len(labels))])
    prediction_cpu_tensor = tensor.long().cpu()
    # iterate over batch
    for ind in range(prediction_cpu_tensor.shape[0]):
        prediction = prediction_cpu_tensor[ind].numpy().tolist()
        # CTC decoding procedure
        decoded_prediction = []
        previous = len(labels)  # id of a blank symbol
        for p in prediction:
            if (p != previous or previous == blank_id) and p != blank_id:
                decoded_prediction.append(p)
            previous = p
        hypothesis = ''.join([labels_map[c] for c in decoded_prediction])
        hypotheses.append(hypothesis)
    return hypotheses

    Decodes a sequence of labels to words
    
Decodes a sequence of labels to words
Decodes a sequence of labels to words
def __ctc_decoder_predictions_tensor(tensor, labels):
    blank_id = len(labels)
    hypotheses = []
    labels_map = dict([(i, labels[i]) for i in range(len(labels))])
    prediction_cpu_tensor = tensor.long().cpu()
    for ind in range(prediction_cpu_tensor.shape[0]):
        prediction = prediction_cpu_tensor[ind].numpy().tolist()
        decoded_prediction = []
        previous = len(labels)  
        for p in prediction:
            if (p != previous or previous == blank_id) and p != blank_id:
                decoded_prediction.append(p)
            previous = p
        hypothesis = ''.join([labels_map[c] for c in decoded_prediction])
        hypotheses.append(hypothesis)
    return hypotheses
def __ctc_decoder_predictions_tensor ( tensor , labels ) : blank_id = len ( labels ) hypotheses = [ ] labels_map = dict ( [ ( i , labels [ i ] ) for i in range ( len ( labels ) ) ] ) prediction_cpu_tensor = tensor . long ( ) . cpu ( ) for ind in range ( prediction_cpu_tensor . shape [ 0 ] ) : prediction = prediction_cpu_tensor [ ind ] . numpy ( ) . tolist ( ) decoded_prediction = [ ] previous = len ( labels ) for p in prediction : if ( p != previous or previous == blank_id ) and p != blank_id : decoded_prediction . append ( p ) previous = p hypothesis = '' . join ( [ labels_map [ c ] for c in decoded_prediction ] ) hypotheses . append ( hypothesis ) return hypotheses
Decodes a sequence of labels to words
Decodes a sequence of labels to words
"""
    Decodes a sequence of labels to words
    """ # iterate over batch # CTC decoding procedure # id of a blank symbol
tensor
labels