what type should i pass to pipe? import datasets from transformers import pipeline from…
- User
what type should i pass to pipe?
import datasets from transformers import pipeline from transformers.pipelines.pt_utils import KeyDataset from tqdm.auto import tqdm
pipe = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-base-960h", device=0) dataset = datasets.load_dataset("superb", name="asr", split="test")
KeyDataset (only pt) will simply return the item in the dict returned by the dataset item
as we're not interested in the target part of the dataset. For sentence pair use KeyPairDataset
for out in tqdm(pipe(KeyDataset(dataset, "file"))): print(out) # {"text": "NUMBER TEN FRESH NELLY IS WAITING ON YOU GOOD NIGHT HUSBAND"} # {"text": ....} # ....
- Assistant
In the context of the code you provided, it looks like you're leveraging the
KeyDatasetfrom thetransformerslibrary to only extract the audio file path or identifier (which is key "file" in your dataset) from the dataset. This is then passed to thepipelinefor automatic speech recognition (ASR).Here's a more detailed look at the relevant parts:
-
Dataset Loading:
dataset = datasets.load_dataset("superb", name="asr", split="test")
-