o
    i                     @   sH   d Z ddlZg dZeeZG dd dZedZdd Zd	d
 Z	dS )z+ from https://github.com/keithito/tacotron     N)TAAAA0AA1AA2AEAE0AE1AE2AHAH0AH1AH2AOAO0AO1AO2AWAW0AW1AW2AYAY0AY1AY2BCHDDHEHEH0EH1EH2ERER0ER1ER2EYEY0EY1EY2FGHHIHIH0IH1IH2IYIY0IY1IY2JHKLMNNGOWOW0OW1OW2OYOY0OY1OY2PRSSHTTHUHUH0UH1UH2UWUW0UW1UW2VWYZZHc                   @   s*   e Zd ZdZd
ddZdd Zdd Zd	S )CMUDictzNThin wrapper around CMUDict data. http://www.speech.cs.cmu.edu/cgi-bin/cmudictTc                 C   sh   t |tr t|dd}t|}W d    n1 sw   Y  nt|}|s/dd | D }|| _d S )Nzlatin-1)encodingc                 S   s"   i | ]\}}t |d kr||qS )   )len).0wordpron r]   L/home/ubuntu/.local/lib/python3.10/site-packages/tacotron_cleaner/cmudict.py
<dictcomp>   s   " z$CMUDict.__init__.<locals>.<dictcomp>)
isinstancestropen_parse_cmudictitems_entries)selffile_or_pathkeep_ambiguousfentriesr]   r]   r^   __init__   s   


zCMUDict.__init__c                 C   s
   t | jS )N)rY   re   )rf   r]   r]   r^   __len__    s   
zCMUDict.__len__c                 C   s   | j | S )z9Returns list of ARPAbet pronunciations of the given word.)re   getupper)rf   r[   r]   r]   r^   lookup$   s   zCMUDict.lookupN)T)__name__
__module____qualname____doc__rk   rl   ro   r]   r]   r]   r^   rV      s
    
rV   z
\([0-9]+\)c                 C   s   i }| D ]?}t |rC|d dkr|d dks|d dkrC|d}ttd|d }t|d }|rC||v r>|| | q|g||< q|S )Nr   ArT   'z   rX   )rY   splitresub_alt_re_get_pronunciationappend)filecmudictlinepartsr[   pronunciationr]   r]   r^   rc   -   s   ,

rc   c                 C   s0   |   d}|D ]	}|tvr d S q	d|S )N )striprw   _valid_symbol_setjoin)sr   partr]   r]   r^   r{   <   s   
r{   )
rs   rx   valid_symbolssetr   rV   compilerz   rc   r{   r]   r]   r]   r^   <module>   s    

