@Mohamed_Nabih I suggest you use something like this:
import os

import torchaudio
from torch.utils.data import Dataset
from torchaudio.datasets.utils import walk_files


def main():
    timit = Timit('../TIMIT/')
    x = timit[0]


def load_timit(file: str):
    data_path = os.path.splitext(file)[0]
    with open(data_path + '.TXT', 'r') as txt_file:
        _, __, transcript = next(iter(txt_file)).strip().split(" ", 2)
    with open(data_path + '.WRD', 'r') as word_file:
        words = [l.strip().split(' ') for l in word_file]
        words = [(int(hd), int(tl), w) for (hd, tl, w) in words]
    with open(data_path + '.PHN', 'r') as phn_file:
        phonemes = [l.strip().split(' ') for l in phn_file]
        phonemes = [(int(hd), int(tl), w) for (hd, tl, w) in phonemes]
    wav, sr = torchaudio.load(data_path + '.WAV')
    return data_path, wav, transcript, words, phonemes


class Timit(Dataset):
    def __init__(self, root: str):
        self.root = root
        self.walker = list(walk_files(root, suffix='.WAV', prefix=True))

    def __getitem__(self, item):
        return load_timit(self.walker[item])

    def __len__(self):
        return len(self.walker)


if __name__ == '__main__':
    main()

It simply loads all files (regardless of train test). You could do the train test split by simply changing root=’…/TIMIT/data/TEST’ or similar thing for train.