o
    h                     @   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.transcriberaudiotextc                 C   s   | j |ddjS )Npt)return_tensors)pre_processorinput_features)selfr    r   W/var/www/html/ai/venv/lib/python3.10/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)skip_special_tokens    )r   batch_decode)r   outputsr   r   r   decode(   s   zSpeechToTextTool.decodeN)__name__
__module____qualname__default_checkpointdescriptionnamer   pre_processor_classr   model_classr   r   r   r   r   r   r   r   r   r      s    r   N)models.whisperr   r   baser   r   r   r   r   r   <module>   s   