Error loading and preprocessing librispeech

When I try to read librispeech, I get an error,

RuntimeError: stack expects each tensor to be equal size, but got [248560] at entry 0 and [32000] at entry 1

However, this happens because the length of each data is different and it cannot be summarized as a batch.
So I used padding in, batched=True) to adjust the length, but an unexpected error popped up
This error is newAI2022y08y23d\lib\site-packages\datasets\" Some problem has occurred in the library I would like to know the cause of this please

  0%|                                                                                                                               | 0/29 [00:00<?, ?ba/s]
Traceback (most recent call last):
  File "", line 25, in <module>
    train_dataset =, batched=True)#学習用
  File "C:\Users\PC_User\newAI2022y08y23d\newAI2022y08y23d\lib\site-packages\datasets\", line 2405, in map
  File "C:\Users\PC_User\newAI2022y08y23d\newAI2022y08y23d\lib\site-packages\datasets\", line 557, in wrapper
    out: Union["Dataset", "DatasetDict"] = func(self, *args, **kwargs)
  File "C:\Users\PC_User\newAI2022y08y23d\newAI2022y08y23d\lib\site-packages\datasets\", line 524, in wrapper
    out: Union["Dataset", "DatasetDict"] = func(self, *args, **kwargs)
  File "C:\Users\PC_User\newAI2022y08y23d\newAI2022y08y23d\lib\site-packages\datasets\", line 480, in wrapper
    out = func(self, *args, **kwargs)
  File "C:\Users\PC_User\newAI2022y08y23d\newAI2022y08y23d\lib\site-packages\datasets\", line 2779, in _map_single
  File "C:\Users\PC_User\newAI2022y08y23d\newAI2022y08y23d\lib\site-packages\datasets\", line 2655, in apply_function_on_filtered_inputs
    processed_inputs = function(*fn_args, *additional_args, **fn_kwargs)
  File "C:\Users\PC_User\newAI2022y08y23d\newAI2022y08y23d\lib\site-packages\datasets\", line 2347, in decorated
    result = f(decorated_item, *args, **kwargs)
TypeError: 'Dataset' object is not callable

this is all code

from datasets import load_dataset
import torch
import numpy as np
from import DataLoader
from torchvision import datasets, transforms
from transformers import Wav2Vec2Processor, Wav2Vec2ConformerForCTC

tokenizer = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-conformer-rope-large-960h-ft")

def tokenize_function(examples):
    return tokenizer(examples["audio"], padding="max_length", truncation=True)

train_dataset = load_dataset(dataset_URL,"clean", split="train.100")#学習用
test_dataset = load_dataset(dataset_URL,"clean", split="test")#試験用

#train_dataset =load_dataset("text", data_files="datasets/Librispeech/.txt")
#test_dataset =load_dataset("text", data_files="my_file.txt")
sampling_rate = train_dataset.features["audio"].sampling_rate#サンプルレート

train_dataset =, batched=True)#学習用
test_dataset =, batched=True)#試験用

train_loader = DataLoader(train_dataset, shuffle=True, batch_size=batch_size)#学習用
test_loader = DataLoader(test_dataset, batch_size=batch_size)#試験用


In the pasted code, you are using dataset objects as transforms in map, but they are not callables, hence the error. I guess you meant to use tokenize_function instead.