in ultravox/data/data_sample.py [0:0]
def __post_init__(self):
"""Ensure audio is float32 PCM."""
if self.audio is not None:
if self.audio.dtype == np.float64:
self.audio = self.audio.astype(np.float32)
elif self.audio.dtype == np.int16:
self.audio = self.audio.astype(np.float32) / np.float32(32768.0)
elif self.audio.dtype == np.int32:
self.audio = self.audio.astype(np.float32) / np.float32(2147483648.0)
assert (
self.audio.dtype == np.float32
), f"Unexpected audio dtype: {self.audio.dtype}"
assert self.audio.ndim == 1, f"Unexpected audio shape: {self.audio.shape}"