o
    ¡¿¯i
  ã                   @   sZ   d Z ddlmZ zddlZW n ey   dZY n
w G dd„ dejƒZG dd„ deƒZdS )zTTS Interface realted modules.é    ©Ú
torch_loadNc                   @   s   e Zd ZdZdd„ ZdS )ÚReporterzReporter module.c                 C   s   |D ]	}t j || ¡ qdS )z Report values from a given dict.N)ÚchainerÚreporterÚreport)ÚselfÚdictsÚd© r   úM/home/ubuntu/.local/lib/python3.10/site-packages/espnet/nets/tts_interface.pyr      s   ÿzReporter.reportN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r      s    r   c                   @   s\   e Zd ZdZedd„ ƒZdd„ Zdd„ Zdd	„ Zd
d„ Z	dd„ Z
edd„ ƒZedd„ ƒZdS )ÚTTSInterfacez.TTS Interface for ESPnet model implementation.c                 C   s   | S )z&Add model specific argments to parser.r   )Úparserr   r   r   Úadd_arguments   s   zTTSInterface.add_argumentsc                 C   s   t ƒ | _dS )zInitilize TTS module.N)r   r   ©r   r   r   r   Ú__init__!   s   zTTSInterface.__init__c                 O   ó   t dƒ‚)z^Calculate TTS forward propagation.

        Returns:
            Tensor: Loss value.

        z!forward method is not implemented©ÚNotImplementedError©r   ÚargsÚkwargsr   r   r   Úforward%   ó   zTTSInterface.forwardc                 O   r   )a  Generate the sequence of features given the sequences of characters.

        Returns:
            Tensor: The sequence of generated features (L, odim).
            Tensor: The sequence of stop probabilities (L,).
            Tensor: The sequence of attention weights (L, T).

        z#inference method is not implementedr   r   r   r   r   Ú	inference.   s   	zTTSInterface.inferencec                 O   r   )zyCalculate TTS attention weights.

        Args:
            Tensor: Batch of attention weights (B, Lmax, Tmax).

        z2calculate_all_attentions method is not implementedr   r   r   r   r   Úcalculate_all_attentions9   r   z%TTSInterface.calculate_all_attentionsc                 C   s   t || ƒ dS )z!Load pretrained model parameters.Nr   )r   Ú
model_pathr   r   r   Úload_pretrained_modelB   s   z"TTSInterface.load_pretrained_modelc                 C   s   ddl m} |S )zPlot attention weights.r   )ÚPlotAttentionReport)Úespnet.asr.asr_utilsr"   )r   r"   r   r   r   Úattention_plot_classF   s   z!TTSInterface.attention_plot_classc                 C   s   dgS )a®  Return base key names to plot during training.

        The keys should match what `chainer.reporter` reports.
        if you add the key `loss`,
        the reporter will report `main/loss` and `validation/main/loss` values.
        also `loss.png` will be created as a figure visulizing `main/loss`
        and `validation/main/loss` values.

        Returns:
            list[str]:  Base keys to plot during training.

        Úlossr   r   r   r   r   Úbase_plot_keysM   s   zTTSInterface.base_plot_keysN)r   r   r   r   Ústaticmethodr   r   r   r   r   r!   Úpropertyr$   r&   r   r   r   r   r      s    
		
r   )	r   r#   r   r   ÚImportErrorr   ÚChainÚobjectr   r   r   r   r   Ú<module>   s   ÿ	