def get_len()

in vizseq/_data/data_sources.py [0:0]


    def get_len(self, idx: int, finer=False) -> int:
        if not 0 <= idx <= len(self):
            raise ValueError(f'Invalid index {idx}')
        if self.is_text:
            return len(self.data[idx]) if finer else len(self.data[idx].split())
        elif self.is_audio:
            if any(self.data[idx].endswith(e) for e in SOUNDFILE_FILE_EXTS):
                sound, sr = sf.read(self.data[idx])
                duration_ms = int(len(sound) / sr * 1000)
                n_frames = int(1 + (duration_ms - 25) / 10)
                return duration_ms if finer else n_frames
        return 0