o
    ॵi                     @   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 offical model id
        r   N )super__init__)selfr   kwargs	__class__r   f/home/ubuntu/.local/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)}
        voice)r   forwardgetr   
OUTPUT_WAV)r   r   forward_params
output_wavr   r   r   r      s   
z*TextToSpeechSambertHifiganPipeline.forwardinputsc                 K      |S Nr   )r   r   postprocess_paramsr   r   r   postprocess(   s   z.TextToSpeechSambertHifiganPipeline.postprocessc                 K   r    r!   r   )r   r   preprocess_paramsr   r   r   
preprocess,   s   z-TextToSpeechSambertHifiganPipeline.preprocessc                 K   s
   i |i fS r!   r   )r   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npmodelscope.metainfor   modelscope.models.audio.ttsr   modelscope.outputsr   modelscope.pipelines.baser   r   r	   modelscope.pipelines.builderr
   modelscope.utils.constantr   __all__register_moduletext_to_speechsambert_hifigan_ttsr   r   r   r   r   <module>   s   