INNER CODE UNIT · Python

preprocess

sanchit-gandhi/whisper-jax · benchmarks/run_pipeline_dataloader.py:40

    def preprocess(self, inputs, chunk_length_s=0, stride_length_s=None):
        array = inputs.get("array")
        in_sampling_rate = inputs.get("sampling_rate")
        stride = inputs.get("stride", None)

        if in_sampling_rate != self.feature_extractor.sampling_rate:
            ratio = self.feature_extractor.sampling_rate / in_sampling_rate
        else:
            ratio = 1

        if stride is not None:
            if stride[0] + stride[1] > inputs.shape[0]:
                raise ValueError("Stride is too large for input")

            # Stride needs to get the chunk length here, it's going to get
            # swallowed by the `feature_extractor` later, and then batching
            # can add extra data in the inputs, so we need to keep track
            # of the original length in the stride so we can cut properly.

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…