loading librispeech in pytorch for ASR
I'm newly working to train an automatic speech recognition machine using neural network and CTC loss. But the first thing I'm supposed to do is to prepare the data for training the model. Since the Librispeech contains huge amounts of data, initially I am going to use a subset of it called "Mini LibriSpeech ASR corpus". (http://www.openslr.org/31/). Also I am using SeanNaren Pytorch bindings for Warp-ctc (https://github.com/SeanNaren/warp-ctc).   

After reading the audio files and their corresponding transcripts, I'm using Spicy package to calculate the spectrogram of each audio file. The problem arises when I'm going to feed the spectrograms to a convolutional layer for feature extraction. The length of each spectrogram differs from the other ones. After searching more on the issue, I figured out I should probably pass a specific number of frames to the network, but in order to reach this I need to tag each frame of the sound file with the corresponding character(also containing blank symbol).   

Is there a way to do that in python?

Your question is quite broad : are you looking after the transcripts of the audio files ? If so they are in a text file in each directory, each line starting with the filename (without the extension).

You can look here : https://github.com/inikdom/rnn-speech/blob/master/util/dataprocessor.py

Especially this method which give a list of audio files with their transcription for the Librispeech corpus :

def get_data_librispeech(self, raw_data_path):
    text_files = self.find_files(raw_data_path, ".txt")
    result = []
    for text_file in text_files:
        directory = os.path.dirname(text_file)
        with open(text_file, "r") as f:
            lines = f.read().split("\n")
            for line in lines:
                head = line.split(' ')[0]
                if len(head) &lt; 5:
                    # Not a line with a file desc
                    break
                audio_file = directory + "/" + head + ".flac"
                if os.path.exists(audio_file):
                    result.append([audio_file, self.clean_label(line.replace(head, "")), None])
    return result


Note : the third value for each item is always None because it's supposed to be replaced by the audio length in another method.

You do not tag each frame of the audio with the corresponding character, CTC will take care of it by working on a full length audio and the corresponding transcript.
