MCPcopy Create free account
hub / github.com/pytorch/executorch / PreprocessorWrapper

Class PreprocessorWrapper

examples/models/sortformer/export_sortformer.py:27–43  ·  view source on GitHub ↗

Wraps NeMo's AudioToMelSpectrogramPreprocessor for single-sample export. Input: 1D audio waveform (N,) and length (1,) int64. Output: mel spectrogram (1, 128, T_mel) and mel_len (1,) int64.

Source from the content-addressed store, hash-verified

25
26
27class PreprocessorWrapper(torch.nn.Module):
28 """Wraps NeMo's AudioToMelSpectrogramPreprocessor for single-sample export.
29
30 Input: 1D audio waveform (N,) and length (1,) int64.
31 Output: mel spectrogram (1, 128, T_mel) and mel_len (1,) int64.
32 """
33
34 def __init__(self, preprocessor):
35 super().__init__()
36 self.preprocessor = preprocessor
37
38 def forward(
39 self, audio: torch.Tensor, length: torch.Tensor
40 ) -> tuple[torch.Tensor, torch.Tensor]:
41 audio_signal = audio.unsqueeze(0)
42 mel, mel_len = self.preprocessor(input_signal=audio_signal, length=length)
43 return mel, mel_len
44
45
46class PreEncodeWrapper(torch.nn.Module):

Callers 1

export_allFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected