MCPcopy
hub / github.com/descriptinc/descript-audio-codec / get_delay

Method get_delay

dac/model/base.py:82–106  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

80 self._padding = value
81
82 def get_delay(self):
83 # Any number works here, delay is invariant to input length
84 l_out = self.get_output_length(0)
85 L = l_out
86
87 layers = []
88 for layer in self.modules():
89 if isinstance(layer, (nn.Conv1d, nn.ConvTranspose1d)):
90 layers.append(layer)
91
92 for layer in reversed(layers):
93 d = layer.dilation[0]
94 k = layer.kernel_size[0]
95 s = layer.stride[0]
96
97 if isinstance(layer, nn.ConvTranspose1d):
98 L = ((L - d * (k - 1) - 1) / s) + 1
99 elif isinstance(layer, nn.Conv1d):
100 L = (L - 1) * s + d * (k - 1) + 1
101
102 L = math.ceil(L)
103
104 l_in = L
105
106 return (l_in - l_out) // 2
107
108 def get_output_length(self, input_length):
109 L = input_length

Callers 1

__init__Method · 0.80

Calls 1

get_output_lengthMethod · 0.95

Tested by

no test coverage detected