def merge_all_segments(
            self,
            record: bool = True
    ) -> "WhisperResult":
        """
        Merge all segments into one segment.

        Parameters
        ----------
        record : bool , default True
            Whether to record this operation in ``regroup_history``.

        Returns
        -------
        stable_whisper.result.WhisperResult
            The current instance after the changes.
        """
        if not self.segments:
            return self
        if self.has_words:
            new_seg = self.segments[0].copy(self.all_words(), keep_result=True, copy_words=False)
        else:
            new_seg = self.segments[0]
            new_seg._default_text = ''.join(s.text for s in self.segments)
            if all(s.tokens is not None for s in self.segments):
                new_seg._default_tokens = list(chain.from_iterable(s.tokens for s in self.segments))
            new_seg.end = self.segments[-1].end
        self.segments = [new_seg]
        self.reassign_ids()
        if record:
            self._update_history('ms')
        return self

        Merge all segments into one segment.

        Parameters
        ----------
        record : bool , default True
            Whether to record this operation in ``regroup_history``.

        Returns
        -------
        stable_whisper.result.WhisperResult
            The current instance after the changes.
        
stable_whisper/result.py