U
    9%e                     @   s0   d dl mZmZ ddlmZ G dd deZdS )   )WhisperForConditionalGenerationWhisperProcessor   )PipelineToolc                   @   sD   e Zd ZdZdZdZeZeZ	dgZ
dgZdd Zdd	 Zd
d ZdS )SpeechToTextToolzopenai/whisper-basezuThis is a tool that transcribes an audio into text. It takes an input named `audio` and returns the transcribed text.Ztranscriberaudiotextc                 C   s   | j |ddjS )Npt)Zreturn_tensors)pre_processorZinput_features)selfr    r   `/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/transformers/tools/speech_to_text.pyencode"   s    zSpeechToTextTool.encodec                 C   s   | j j|dS )N)inputs)modelgenerate)r   r   r   r   r   forward%   s    zSpeechToTextTool.forwardc                 C   s   | j j|ddd S )NT)Zskip_special_tokens    )r
   Zbatch_decode)r   outputsr   r   r   decode(   s    zSpeechToTextTool.decodeN)__name__
__module____qualname__Zdefault_checkpointdescriptionnamer   Zpre_processor_classr   Zmodel_classr   r   r   r   r   r   r   r   r   r      s   r   N)Zmodels.whisperr   r   baser   r   r   r   r   r   <module>   s   