MCPcopy Index your code
hub / github.com/Standard-Intelligence/hertz-dev / tokenize

Method tokenize

model.py:261–274  ·  view source on GitHub ↗
(self, audio_data)

Source from the content-addressed store, hash-verified

259
260 @T.no_grad()
261 def tokenize(self, audio_data):
262 orig_audio_shape = audio_data.shape
263 if exists(self.audio_cache):
264 audio_data = T.cat([self.audio_cache, audio_data], dim=-1)
265 self.audio_cache = audio_data[..., -(6*16_000):]
266 elif self.use_audio_cache:
267 self.audio_cache = audio_data[..., -(6*16_000):]
268
269 if audio_data.shape[1] == 2:
270 enc_ch1 = self.audio_tokenizer.latent_from_data(audio_data[:, 0:1])
271 enc_ch2 = self.audio_tokenizer.latent_from_data(audio_data[:, 1:2])
272 return T.cat([enc_ch1, enc_ch2], dim=-1)[:, -(orig_audio_shape[-1]//2000):]
273 else:
274 return self.audio_tokenizer.latent_from_data(audio_data)[:, -(orig_audio_shape[-1]//2000):]
275
276 @T.no_grad()
277 def untokenize(self, token_data):

Callers 1

next_audio_from_audioMethod · 0.95

Calls 2

existsFunction · 0.90
latent_from_dataMethod · 0.80

Tested by

no test coverage detected