o
    *j                     @   s   d dl mZmZ d dlZd dlmZ d dlmZ d dl	m
Z
 d dlmZmZmZ d dlmZ d dlmZ d	gZejejejd
G dd	 d	eZdS )    )AnyDictN)	Pipelines)SambertHifigan)
OutputKeys)Input
InputModelPipeline)	PIPELINES)Tasks"TextToSpeechSambertHifiganPipeline)module_namec                       s   e Zd Zdef fddZdedeeef fddZdeee	f deee	f fd	d
Z
dedeee	f fddZdd Z  ZS )r   modelc                    s   t  jdd|i| dS )zuse `model` to create a text-to-speech pipeline for prediction

        Args:
            model (SambertHifigan or str): a model instance or valid official model id
        r   N )super__init__)selfr   kwargs	__class__r   s/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/modelscope/pipelines/audio/text_to_speech_pipeline.pyr      s   z+TextToSpeechSambertHifiganPipeline.__init__inputreturnc                 K   s   | j ||d}tj|iS )a$  synthesis text from inputs with pipeline
        Args:
            input (str): text to synthesis
            forward_params: valid param is 'voice' used to setting speaker vocie
        Returns:
            Dict[str, np.ndarray]: {OutputKeys.OUTPUT_PCM : np.ndarray(16bit pcm data)}
        Zvoice)r   forwardgetr   Z
OUTPUT_WAV)r   r   Zforward_paramsZ
output_wavr   r   r   r      s   
z*TextToSpeechSambertHifiganPipeline.forwardinputsc                 K      |S Nr   )r   r   Zpostprocess_paramsr   r   r   postprocess(   s   z.TextToSpeechSambertHifiganPipeline.postprocessc                 K   r   r   r   )r   r   Zpreprocess_paramsr   r   r   
preprocess,   s   z-TextToSpeechSambertHifiganPipeline.preprocessc                 K   s
   i |i fS r   r   )r   Zpipeline_parametersr   r   r   _sanitize_parameters/   s   
z7TextToSpeechSambertHifiganPipeline._sanitize_parameters)__name__
__module____qualname__r   r   strr   bytesr   r   r   r   r   r    __classcell__r   r   r   r   r      s    

)typingr   r   numpynpZmodelscope.metainfor   Zmodelscope.models.audio.ttsr   Zmodelscope.outputsr   Zmodelscope.pipelines.baser   r   r	   Zmodelscope.pipelines.builderr
   Zmodelscope.utils.constantr   __all__Zregister_moduleZtext_to_speechZsambert_hifigan_ttsr   r   r   r   r   <module>   s   