
    Pi%                     n   d Z ddlmZ ddlZddlZddlmZmZmZ ddl	m
Z
 ddlmZ ddlmZmZ  ej                    dk    Z ej                    d	k    Z ej                    d
k    Zej                            dg d          d             Zej                            ddgddgg dg dg ddgg ddgdgdgdgdgdgdgg          d             Zej                            dd gd!gd"gfd#gd$gerd"gnd%gfd&gd'gerd"gnd(gfg          d)             Zd* Zd+ Zd, Zd- Zej                            d.g d/          d0             Zej                            d1d2d3d4d5gd6d7gfd2d8d9d:gerd;d<gnd=d>gfd2d3d?d@gdAd;gfd2dBd?d@gdCd;gfdDd3d?d@gdAdEgfdDdBd?d@gefdFd3d?d@gdAdGgfdFdBd?d@gdCdGgfg          dH             Zej                            dIdJ ej         dK          dLdMf ej         dN          dLdOfg          dP             Z!dQ Z"dR Z#ej                            dSdTgdUgg dVg dWg          dX             Z$dS )Yz"Test of the punctuation processing    )PathN)EspeakBackendFestivalBackendSegmentsBackend)Punctuation	phonemize)	Separatordefault_separator)   2   )r   1      )      zinp, out))za, b,c.a b c)abc der   )!d.d. dd??  d!zd d dd dc                 T    t                                          |           |k    sJ d S )N)r   remove)inpouts     i/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/test/test_punctuation.pytest_remover   &   s-     ==$$++++++    r   z.a.b.c.a, a?b, b)r   r   !)r   !?r   )r   r   r   za, a, a)r   zaaa bbz.bb, bcr   zTruly replied, "Yes".zhi; ho,"r   !'zIt is ! (I think so)zThis {is} rightz[He] is rightc                     t                      }|                    |           \  }}| |                    ||t          d          k    sJ d S )NTsepstrip)r   preserverestorer   )r   puncttextmarkss       r   test_preserver+   /   sN    $ MME..%%KD%%--e1B$-OOOOOOOOr   z'text, expected_restore, expected_outputzhi; hi,"z	hi; hi," u   haɪ; haɪ, zhi; "hi,z	hi; "hi, u   haɪ;  haɪ, z"hi; hi,z	"hi; hi, u    haɪ; haɪ, c                     d}t          |          }| |j        |                    |           t          ddk    sJ t	          | dd|          }||k    sJ d S )N.!;:,?)r*   Fr#   espeakT)backendpreserve_punctuationpunctuation_marks)r   r'   r&   r   r	   )r)   expected_restoreexpected_outputr*   r(   outputs         r   test_preserve_2r5   F   s     Ee$$$E}u}			#4E C  C  C C C C C h!U< < <F _$$$$$$r   c                     t                      } t          | j                  t          |                                           k    sJ |                     d          dk    sJ t          j        t                    5  ddg| _        d d d            n# 1 swxY w Y   d| _        t          | j                  dk    sJ |                     d          dk    sJ d S )Nza,b.cr   ?.z?.r   za,b c)	r   setr*   default_marksr   pytestraises
ValueErrorlen)r(   s    r   test_customr?   W   s   MMEu{s5#6#6#8#8999999<<  G++++	z	"	" ! !Cj! ! ! ! ! ! ! ! ! ! ! ! ! ! !EKu{q    <<  G++++++s   <
BBBc                     d} d}d}d}d}t          dd                              | gd	
          d         }||k    sJ t          dd	                              | gd	
          d         }||k    sJ t          dd                              | gd
          d         }||k    sJ t          dd	                              | gd
          d         }||k    sJ d S )Nhello, world!u   həloʊ wɜːldu   həloʊ, wɜːld!u   həloʊ wɜːld u   həloʊ, wɜːld! en-usFr0   Tr%   r   )r   r	   	r)   	expected1	expected2	expected3	expected4out1out2out3out4s	            r   test_espeakrN   c   sA   D!I#I"I$Iu===GG	d H  D9t<<<FF	d G  D9u===GG	e H   D9t<<<FF	e G   D9r   c                     d} d}d}d}d}t          dd                              | gd	
          d         }||k    sJ t          dd	                              | gd	
          d         }||k    sJ t          dd                              | gd
          d         }||k    sJ t          dd	                              | gd
          d         }||k    sJ d S )NrA   zhhaxlow werldzhhaxlow, werld!zhhaxlow werld zhhaxlow, werld! rB   FrC   TrD   r   )r   r	   rE   s	            r   test_festivalrP   {   sA   DI!I I"I7???II	d J  D97>>>HH	d I  D97???II	e J   D97>>>HH	e I   D9r   c                     d} d}d}d}d}t          dd                              | gd	
          d         }||k    sJ t          dd	                              | gd	
          d         }||k    sJ t          dd                              | gd
          d         }||k    sJ t          dd	                              | gd
          d         }||k    sJ d S )Nzachi, acho!u   ʌtʃɪ ʌtʃʊu   ʌtʃɪ, ʌtʃʊ!u   ʌtʃɪ ʌtʃʊ u   ʌtʃɪ, ʌtʃʊ! creeFrC   TrD   r   )r   r	   rE   s	            r   test_segmentsrS      sA   D!I#I"I$I6>>>HH	d I  D96===GG	d H  D96>>>HH	e I   D96===GG	e H   D9r   ztext, expected))r!   ! )z'!rT   )z!'!z!! )z'!'rT   c                 J    t          | gddd          d         }||k    sJ d S )NrB   r.   T)languager/   r0   r   r   )r)   expectedr4   s      r   test_issue_54rX      sE     	(!# # ##$&F vr   zbackend, marks, text, expectedr.   defaultz"Hey! "z"hey,"u	   "heɪ! " u   "heɪ," r-   z"Hey! " z"hey," u   heɪ! u   heɪ, u    heɪ! u    heɪ, z! ?zhey!z! ? r   rT   segmentsu   heːj! festivalzhhey! c           	      `   |dk    rt          j                    }| dk    rdnd}	 t          j        |          5  t	          ||| d|           d d d            d S # 1 swxY w Y   d S # t
          $ r; 	 |t	          ||| d|          k    sJ Y d S # t          $ r | dk    rY Y d S Y Y d S w xY ww xY w)NrY   rZ   rR   rB   T)rV   r/   r0   r1   r[   )r   r:   r;   r<   r	   	TypeErrorRuntimeError)r/   r*   r)   rW   rV   s        r   test_issue55r_      s    	)++ J..vvGH]8$$ 	D 	Dx%)UD D D D	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D  
 
 
		yx%)U D  D  D D D D D D D D  	 	 	*$$ 	 %$$$	
sR   A( AA( AA( "A#A( (
B-3BB) B-$B-(B))B-z!punctuation_marks, text, expected)u   ;:,.!?¡—…"«»“”+   hello, ,world? ‡ 3,000, or 2.50. ¿hello?uV   həloʊ, ,wɜːld? θɹiː,ziəɹoʊziəɹoʊ ziəɹoʊ, ɔːɹ tuː.fɪfti. həloʊ? u'   [^a-zA-ZÀ-ÖØ-öø-ÿ0-9'$@&+%\-=/\\]r`   u\   həloʊ, ,wɜːld? ‡ θɹiː,ziəɹoʊziəɹoʊ ziəɹoʊ, ɔːɹ tuː.fɪfti. ¿həloʊ? u4   [^a-zA-ZÀ-ÖØ-öø-ÿ0-9',.$@&+%\-=/\\]|[,.](?!\d)u[   həloʊ, ,wɜːld? ‡ θɹiː θaʊzənd, ɔːɹ tuː pɔɪnt faɪv ziəɹoʊ. ¿həloʊ? c                 6    |t          |d|           k    sJ d S )NT)r0   r1   r   )r1   r)   rW   s      r   test_punctuation_marks_regexrb      sG     y4;LN N N N N N N N Nr   c                      t          j        d          } t          |           }t          j        t
                    5  |j        | k     d d d            d S # 1 swxY w Y   d S )Nz[^a-zA-Z0-9])recompiler   r;   r<   r=   r*   )marks_rer(   s     r   test_marks_getter_with_regexrg      s    z/**H!!E	z	"	"    x                                   s   AAAc                     t          t                    j        dz  } t          | dz            5 }t	          |                                                    d          dd           d d d            d S # 1 swxY w Y   d S )Ndatazpg67147.txt
r.   T)r/   r0   )r   __file__parentopenr	   readsplit)DATA_FOLDERtxt_files     r   test_long_documentrr      s    x..'&0K	kM)	*	* \h(--//''--xVZ[[[[\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \s   8A44A8;A8r)   =worked david ford i started in deloitte and i was immediately>worked david ford i started in deloitte, and i was immediately)rs   7an offer of price waterhouse cooper and here i take may2we are now as maximum plan for a customer time andz.they're going to meet all the xvin so great it)rt   ru   rv   z/they're going to meet all the xvin so great it.c                 l    t          | d          }t          |           t          |          k    sJ d S )NTrC   )r	   r>   )r)   
phonemizeds     r   test_multiline_punctuationry      s9    4 4d;;;Jt99J''''''r   )%__doc__pathlibr   r;   rd   phonemizer.backendr   r   r   phonemizer.punctuationr   phonemizer.phonemizer	   phonemizer.separatorr
   r   version
ESPEAK_150
ESPEAK_149FESTIVAL_25markparametrizer   r+   r5   r?   rN   rP   rS   rX   r=   r_   re   rb   rg   rr   ry    r   r   <module>r      s   ) (        				 N N N N N N N N N N . . . . . . * * * * * * = = = = = = = = $m#%%0
 $m#%%3
 '&((F2  ( ( () )
, ,) )
, 			&	<<<	 !				 		 "P P# "P -
}~&67
}*&[~&6&6?J[\
}*&[~&6&6?J[\0^_ _
	% 	%_ _
	%	, 	, 	,  0  0  2 QQQS S S S $	9y(3k:5NO	8j)4!+	G(H		)Y1G	I	9ufo/AB	3$)9:	Y&)1DE	S5&/:6	Y&(1CD	S5&/D(+;<	'>
? 
? 
? 
?. '	c 
>	?	?	6	g	i 
K	L	L	6	f	h
* N N N
     \ \ \ 
K

 M

 
 

 
 
! 2( (3 2( ( (r   