
    Pi7                     P    d Z ddlmZmZ  G d d          Z eddd          ZdS )	z2Provides the Separator tuple and its default value    )OptionalUnionc                       e Zd ZdZ	 	 	 ddedee         dee         fdZdd	Zd
 Ze	d             Z
e	d             Ze	d             ZdefdZdeeef         deeef         fdZdS )	Separatorz0Defines phone, syllable and word boundary tokens Nwordsyllablephonec                    t          d |||fD                       }t          d |||fD                       }t          |          t          |          k    r$t          d                    |||                    |rt          |          nd| _        |rt          |          nd| _        |rt          |          nd| _        d S )Nc              3      K   | ]}||V  	d S N .0seps     h/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/phonemizer/separator.py	<genexpr>z%Separator.__init__.<locals>.<genexpr>   s'      BBCcBCBBBBBB    c              3      K   | ]}||V  	d S r   r   r   s     r   r   z%Separator.__init__.<locals>.<genexpr>   s'      AA3SA3AAAAAAr   zcillegal separator with word="{}", syllable="{}" and phone="{}", must be all differents if not empty )	listsetlen
ValueErrorformatstr_phone	_syllable_word)selfr   r	   r
   sep1sep2s         r   __init__zSeparator.__init__   s     BBE8T#:BBBBBAA5(D"9AAAAAt99D		!!BVE8T224 4 4
 %*1c%jjjr*2:X"&.SYYYB


r   otherc                 b    | j         |j         k    o| j        |j        k    o| j        |j        k    S r   r
   r	   r   )r    r$   s     r   __eq__zSeparator.__eq__&   s5    
ek) ,MU^3,I+	-r   c                 8    d| j          d| j         d| j         dS )Nz	(phone: "z", syllable: "z
", word: "z")r&   r    s    r   __str__zSeparator.__str__,   s=    $
 $ $-$ $i$ $ $	%r   c                     | j         S )zPhones separator)r   r)   s    r   r
   zSeparator.phone2   s     {r   c                     | j         S )zSyllables separator)r   r)   s    r   r	   zSeparator.syllable7   s     ~r   c                     | j         S )zWords separator)r   r)   s    r   r   zSeparator.word<   s     zr   valuec                 .    || j         | j        | j        hv S )z=Returns True if the separator has `value` as token separationr&   )r    r.   s     r   __contains__zSeparator.__contains__A   s    T]DI>>>r   field_separatorreturnc                     |sdS t          |t                    r|| v rt          d| d|            |S |du rd}|| v r	|dz  }|| v 	|S t          d|           )a  Returns a suitable input/output separator based on token separator

        The input/output separator split orthographic and phonetic texts when
        using the --prepend-text option from command-line.

        Parameters
        ----------

        field_separator: bool or str
            If str, ensures it's value is not
            already defined as a token separator. If True choose one of "|",
            "||", "|||", "||||" (the first one that is not defined as a token
            separator)

        Returns
        -------
        The input/output separator, or False if ``field_separator`` is False

        Raises
        ------
        RuntimeError
            if ``field_separator`` is a str but is already registered as token separator

        Fzcannot prepend input with "z+" because it is already a token separator: T|z:invalid input/output separator, must be bool or str but is)
isinstancer   RuntimeError)r    r1   s     r   input_output_separatorz Separator.input_output_separatorE   s    4  	5os++ 	#$&&"?/ ? ?8<? ?@ @ @ #"d""!O!T))3& "T))"" !! !" " 	"r   )r   NN)r$   r   )__name__
__module____qualname____doc__r   r   r#   r'   r*   propertyr
   r	   r   r0   r   boolr7   r   r   r   r   r      s       ::#&+/(,/ /S /#C=/ / / / / - - - -% % %   X   X   X?# ? ? ? ?-"eCI6F -"S$Y-" -" -" -" -" -"r   r   r   r   r&   N)r;   typingr   r   r   default_separatorr   r   r   <module>r@      su    9 8 " " " " " " " "_" _" _" _" _" _" _" _"D IB#>>>  I Ir   