o
    ±ƒðja  ã                   @   s`   d Z ddl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 e d¡ZG d	d
„ d
ƒZdS )aÁ  Hebrew phonemization: Nakdimon (niqqud) + rule-based Hebrew->IPA G2P.

Hebrew is written without vowel points, and espeak-ng's Hebrew voice is not
robust to fully-pointed text (it falls back to spelling out letter names on many
common words). Instead we restore niqqud with Nakdimon and convert to IPA with a
rule-based G2P. The output uses Piper's default IPA phoneme id map, so Hebrew
voices stay compatible with the IPA-based (espeak) warmstart.
é    N)ÚPath)ÚListÚUnioné   )ÚDEFAULT_MODEL_PATHÚNakdimonDiacritizer)Úhebrew_to_ipau   [Ö°-Ö¼Ö¿×�×‚×‡]c                   @   sH   e Zd ZdZefdeeef ddfdd„Zdede	e	e  fdd	„Z
dS )
ÚHebrewPhonemizerz?Diacritize (if needed) and convert Hebrew text to IPA phonemes.Ú
model_pathÚreturnNc                 C   s   t |ƒ| _d S )N)r   Údiacritizer)Úselfr
   © r   ú˜/tmp/claude-1000/-var-www-html-academy/3f42efd1-c2b7-4d08-9b05-30d86bb35479/scratchpad/piper/venv/lib/python3.10/site-packages/piper/phonemize_hebrew.pyÚ__init__   s   zHebrewPhonemizer.__init__Útextc                 C   s.   t  |¡s
|  |¡}t|ƒ}|sg S t|ƒgS )z<Return IPA phonemes grouped by sentence (one sentence here).)Ú_NIQQUD_PATTERNÚsearchr   r   Úlist)r   r   Úipar   r   r   Ú	phonemize   s   


zHebrewPhonemizer.phonemize)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ústrr   r   r   r   r   r   r   r   r	      s    r	   )r   ÚreÚpathlibr   Útypingr   r   Úhebrewr   r   Úhebrew.hebrew_ipar   Úcompiler   r	   r   r   r   r   Ú<module>   s    	
