
    3h	                     <    S r SSKJr  SSKrSSKJr   " S S5      rg)zGSubMaker module is used to generate subtitles from WordBoundary events.    )ListN   )TTSChunkc                   b    \ rS rSrSrSS jrS\SS4S jrS\SS4S	 jr	S\
4S
 jrS\
4S jrSrg)SubMaker
   zD
SubMaker is used to generate subtitles from WordBoundary messages.
returnNc                     / U l         g Ncuesselfs    I/var/www/auris/envauris/lib/python3.13/site-packages/edge_tts/submaker.py__init__SubMaker.__init__   s	    (*	    msgc                 *   US   S:w  a  [        S5      eU R                  R                  [        R                  " [        U R                  5      S-   [        R                  " US   S-  S9[        R                  " US   US   -   S-  S9US	   S
95        g)zy
Feed a WordBoundary message to the SubMaker object.

Args:
    msg (dict): The WordBoundary message.

Returns:
    None
typeWordBoundaryz-Invalid message type, expected 'WordBoundary'r   offsetr   )microsecondsdurationtextindexstartendcontentN)
ValueErrorr   appendsrtSubtitlelen	timedelta)r   r   s     r   feedSubMaker.feed   s     v;.(LMM		LL$))nq(mmX1CDMMHJ0OSU/UVF		
r   wordsc                    US::  a  [        S5      e[        U R                  5      S:X  a  g/ nU R                  S   nU R                  SS  H  n[        UR                  R	                  5       5      U:  aQ  [
        R                  " UR                  UR                  UR                  UR                  S-   UR                  -   S9nM{  UR                  U5        UnM     UR                  U5        X l        g)zs
Merge cues to reduce the number of cues.

Args:
    words (int): The number of words to merge.

Returns:
    None
r   z.Invalid number of words to merge, expected > 0Nr    r   )r!   r%   r   r    splitr#   r$   r   r   r   r"   )r   r)   new_cuescurrent_cuecues        r   
merge_cuesSubMaker.merge_cues(   s     A:MNNtyy>Q')$(IIaL99QR=C;&&,,./%7!ll%++%++'//#5C	 ,! ! 	$	r   c                 B    [         R                  " U R                  5      $ )zk
Get the SRT formatted subtitles from the SubMaker object.

Returns:
    str: The SRT formatted subtitles.
)r#   composer   r   s    r   get_srtSubMaker.get_srtH   s     {{499%%r   c                 "    U R                  5       $ r   )r4   r   s    r   __str__SubMaker.__str__Q   s    ||~r   r   )r	   N)__name__
__module____qualname____firstlineno____doc__r   r   r'   intr0   strr4   r7   __static_attributes__ r   r   r   r   
   sK    +
 
T 
,  @& & r   r   )r=   typingr   r#   r   r   rA   r   r   <module>rC      s    M  
 H Hr   