o
    3>i                     @  s|   d Z ddlmZ ddlZddlmZmZ ddlmZm	Z	 ddl
mZmZmZ eeZeG dd dZG d	d
 d
eZdS )u   
Abstract base class for Speech-to-Text providers.

Every provider must implement `transcribe(audio_url, callid)` and return an
`STTResult`.  New providers (Deepgram, Whisper, …) just subclass BaseSTT and
register in the factory.
    )annotationsN)ABCabstractmethod)	dataclassfield)AnyDictListc                   @  sN   e Zd ZU dZded< eedZded< dZded	< d
Z	ded< dddZ
dS )	STTResultz@Normalised transcription output shared across all STT providers.str
transcript)default_factoryzList[Dict[str, Any]]speaker_segmentsg        floatduration providerreturnDict[str, Any]c                 C  s   | j | j| j| jdS )Nr   r   r   r   r   self r   3/home/aiteam/pcaa-dev/dashboard-backend/stt/base.pyto_dict   s
   zSTTResult.to_dictN)r   r   )__name__
__module____qualname____doc____annotations__r   listr   r   r   r   r   r   r   r   r
      s   
 r
   c                   @  s0   e Zd ZdZeedddZedd	d
ZdS )BaseSTTz!Abstract speech-to-text provider.r   r   c                 C     dS )z2Short identifier used in `stt_provider` DB column.Nr   r   r   r   r   provider_name'       zBaseSTT.provider_name	audio_urlcallidr
   c                 C  r"   )zDownload audio from *audio_url* and return an STTResult.

        Raises `RuntimeError` on unrecoverable failure so the caller can mark
        the call as failed without swallowing the reason.
        Nr   )r   r%   r&   r   r   r   
transcribe,   r$   zBaseSTT.transcribeN)r   r   )r%   r   r&   r   r   r
   )r   r   r   r   propertyr   r#   r'   r   r   r   r   r!   $   s    r!   )r   
__future__r   loggingabcr   r   dataclassesr   r   typingr   r   r	   	getLoggerr   loggerr
   r!   r   r   r   r   <module>   s    
