<filename>xlsr_finetune/evaluation.py
# AUTOGENERATED! DO NOT EDIT! File to edit: notebooks/04_evaluation.ipynb (unless otherwise specified).

__all__ = ['wer_metric', 'evaluate_xlsr']

# Cell
import torch
from datasets import load_metric

# Cell
wer_metric = load_metric("wer")

# Cell
def evaluate_xlsr(batch, model=None, processor=None):
    inputs = processor(batch["speech"], sampling_rate=16_000, return_tensors="pt", padding=True)

    with torch.no_grad():
        logits = model(inputs.input_values.to("cuda"), attention_mask=inputs.attention_mask.to("cuda")).logits

    pred_ids = torch.argmax(logits, dim=-1)
    batch["pred_strings"] = processor.batch_decode(pred_ids)
    return batch
<filename>xlsr_finetune/evaluation.py
# AUTOGENERATED! DO NOT EDIT! File to edit: notebooks/04_evaluation.ipynb (unless otherwise specified).

__all__ = ['wer_metric', 'evaluate_xlsr']

# Cell
import torch
from datasets import load_metric

# Cell
wer_metric = load_metric("wer")

# Cell
def evaluate_xlsr(batch, model=None, processor=None):
    inputs = processor(batch["speech"], sampling_rate=16_000, return_tensors="pt", padding=True)

    with torch.no_grad():
        logits = model(inputs.input_values.to("cuda"), attention_mask=inputs.attention_mask.to("cuda")).logits

    pred_ids = torch.argmax(logits, dim=-1)
    batch["pred_strings"] = processor.batch_decode(pred_ids)
    return batch
# AUTOGENERATED! DO NOT EDIT! File to edit: notebooks/04_evaluation.ipynb (unless otherwise specified). # Cell # Cell # Cell