o
    i                     @   sN   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 dZ
d	S )
z\SubMaker module is used to generate subtitles from WordBoundary and SentenceBoundary events.    )	timedelta)ListOptional   )Subtitlecompose)TTSChunkc                   @   sH   e Zd ZdZdddZdeddfddZdefd	d
ZdefddZ	dS )SubMakerza
    SubMaker is used to generate subtitles from WordBoundary and SentenceBoundary messages.
    returnNc                 C   s   g | _ d | _d S N)cuestypeself r   K/home/kim/smarthome/.venv/lib/python3.10/site-packages/edge_tts/submaker.py__init__   s   
zSubMaker.__init__msgc              	   C   s   |d dvr
t d| jdu r|d | _n| j|d kr*t d| j d|d  d| jtt| jd t|d	 d
 dt|d	 |d  d
 d|d 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   )ZWordBoundaryZ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   r   r   r   feed   s$   

zSubMaker.feedc                 C   s
   t | jS )z
        Get the SRT formatted subtitles from the SubMaker object.

        Returns:
            str: The SRT formatted subtitles.
        )r   r   r   r   r   r   get_srt2   s   
zSubMaker.get_srtc                 C   s   |   S r   )r!   r   r   r   r   __str__;   s   zSubMaker.__str__)r
   N)
__name__
__module____qualname____doc__r   r   r    strr!   r"   r   r   r   r   r	   
   s    
	r	   N)r&   datetimer   typingr   r   Zsrt_composerr   r   r   r	   r   r   r   r   <module>   s    