o
    
j                     @   s   U d Z ddlmZmZ ddlmZ ddlmZmZm	Z	m
Z
mZ dZeed< dZeed< d	Zeed
< dZeed< G dd deeZeG dd dZeG dd dZdS )Piper configuration    )	dataclassfield)Enum)AnyFinalMappingOptionalSequencegMbX?DEFAULT_NOISE_SCALE      ?DEFAULT_LENGTH_SCALEg?DEFAULT_NOISE_W_SCALE   DEFAULT_HOP_LENGTHc                   @   s   e Zd ZdZdZdZdS )PhonemeTypeespeaktextpinyinN)__name__
__module____qualname__ESPEAKTEXTPINYIN r   r   ?/home/kuhnn/.local/lib/python3.10/site-packages/piper/config.pyr      s    r   c                   @   s   e Zd ZU dZeed< 	 eed< 	 eed< 	 eed< 	 eeee f ed< 	 e	ed< 	 e
edZeeef ed	< 	 d
Zee ed< eZeed< eZeed< eZeed< eZeed< edeeef dd fddZdeeef fddZd
S )PiperConfigr   num_symbolsnum_speakerssample_rateespeak_voicephoneme_id_mapphoneme_type)default_factoryspeaker_id_mapNpiper_versionlength_scalenoise_scalenoise_w_scale
hop_lengthconfigreturnc                 C   s   |  di }t| d | d | d d | dt| dt| dt| d	 d
 | d t|  dtj|  di |  d|  dtdS )z%Load configuration from a dictionary.	inferencer   r   audior    r(   r'   noise_wr   voicer"   r#   r%   r&   r*   )r   r   r    r(   r'   r)   r!   r"   r#   r%   r&   r*   )getr   r   r   r   r   r   r   )r+   r-   r   r   r   	from_dict6   s   






zPiperConfig.from_dictc              
   C   sT   d| j id| ji| jj| j| j| j| j| jd| j	| j
| jd	}| jr(| j|d< |S )z&Convert configuration to a dictionary.r    r0   )r(   r'   r/   )	r.   r   r#   r   r   r-   r"   r%   r*   r&   )r    r!   r#   valuer   r   r(   r'   r)   r"   r%   r*   r&   )selfconfig_dictr   r   r   to_dictM   s$   
zPiperConfig.to_dict)r   r   r   __doc__int__annotations__strr   r
   r   r   dictr%   r&   r	   r   r'   floatr   r(   r   r)   r   r*   staticmethodr   r2   r6   r   r   r   r   r      s0   
 r   c                   @   st   e Zd ZU dZdZee ed< 	 dZee	 ed< 	 dZ
ee	 ed< 	 dZee	 ed< 	 dZeed< 	 d	Ze	ed
< dS )SynthesisConfigz"Configuration for Piper synthesis.N
speaker_idr'   r(   r)   Tnormalize_audior   volume)r   r   r   r7   r?   r	   r8   r9   r'   r<   r(   r)   r@   boolrA   r   r   r   r   r>   i   s   
 r>   N)r7   dataclassesr   r   enumr   typingr   r   r   r	   r
   r   r9   r   r   r   r:   r   r   r>   r   r   r   r   <module>   s    T