
    Sܶi                     \    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
d	S )
z\SubMaker module is used to generate subtitles from WordBoundary and SentenceBoundary events.    )	timedelta)ListOptional   )Subtitlecompose)TTSChunkc                   B    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	dS )
SubMakerza
    SubMaker is used to generate subtitles from WordBoundary and SentenceBoundary messages.
    returnNc                 "    g | _         d | _        d S N)cuestypeselfs    T/root/projects/openclaw-proxy/venv/lib/python3.11/site-packages/edge_tts/submaker.py__init__zSubMaker.__init__   s    $&	#'			    msgc                    |d         dvrt          d          | j        |d         | _        n2| j        |d         k    r!t          d| j         d|d          d          | j                            t	          t          | j                  dz   t          |d	         d
z            t          |d	         |d         z   d
z            |d                              dS )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BV   9FDIIY#f+%%P$)PPVPPP   		$)nnq(S]R-?@@@CMC
O,Kr+QRR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     ty!!!r   c                 *    |                                  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   
   s         ( ( ( (
 
T 
 
 
 
>" " " " "      r   r   N)r.   datetimer   typingr   r   srt_composerr   r   r	   r   r0   r   r   <module>r4      s    b b       ! ! ! ! ! ! ! ! + + + + + + + +      2 2 2 2 2 2 2 2 2 2r   