
    Xi                     T    d Z ddlmZ ddlmZmZ ddlmZmZ ddlm	Z	  G d d      Z
y	)
z\SubMaker module is used to generate subtitles from WordBoundary and SentenceBoundary events.    )	timedelta)ListOptional   )Subtitlecompose)TTSChunkc                   @    e Zd ZdZd	dZdeddfdZdefdZdefdZ	y)
SubMakerza
    SubMaker is used to generate subtitles from WordBoundary and SentenceBoundary messages.
    returnNc                      g | _         d | _        y N)cuestypeselfs    [/home/obispo/Crisostomo_bridge/mision_env/lib/python3.12/site-packages/edge_tts/submaker.py__init__zSubMaker.__init__   s    $&	#'	    msgc                    |d   dvrt        d      | j                  |d   | _        n1| j                  |d   k7  rt        d| j                   d|d    d      | j                  j                  t	        t        | j                        dz   t        |d	   d
z        t        |d	   |d   z   d
z        |d                y)z
        Feed a WordBoundary or SentenceBoundary message to the SubMaker object.

        Args:
            msg (dict): The WordBoundary or SentenceBoundary message.

        Returns:
            None
        r   )WordBoundarySentenceBoundaryzDInvalid message type, expected 'WordBoundary' or 'SentenceBoundary'.NzExpected message type 'z', but got 'z'.r   offset
   )microsecondsdurationtext)indexstartendcontent)
ValueErrorr   r   appendr   lenr   )r   r   s     r   feedzSubMaker.feed   s     v;BBV  99FDIYY#f+%)$))LVRP  			$))nq(S]R-?@CMC
O,Kr+QRF		
r   c                 ,    t        | j                        S )z
        Get the SRT formatted subtitles from the SubMaker object.

        Returns:
            str: The SRT formatted subtitles.
        )r   r   r   s    r   get_srtzSubMaker.get_srt2   s     tyy!!r   c                 "    | j                         S r   )r(   r   s    r   __str__zSubMaker.__str__;   s    ||~r   )r   N)
__name__
__module____qualname____doc__r   r	   r&   strr(   r*    r   r   r   r   
   s7    (
 
T 
>" " r   r   N)r.   datetimer   typingr   r   srt_composerr   r   r	   r   r0   r   r   <module>r4      s    b  ! + 2 2r   