
    5j_                     *    d Z ddlZdad ZdedefdZy)u1   Utilitários de transcrição com OpenAI Whisper.    Nc                  p    t         +t        d       t        j                  d      a t        d       t         S )Nz%[whisper] Carregando modelo 'base'...basez[whisper] Modelo carregado.)_modelprintwhisper
load_model     8/opt/mia/workspace/video_editor/backend/whisper_utils.py	get_modelr   	   s.    ~56##F++,Mr
   
video_pathreturnc                    t               }|j                  | dd      }g }|d   D ]  }|j                  d      xs g }g }|D ]u  }|j                  d      xs dj                         }|s)|j	                  |t        |j                  d|d               t        |j                  d	|d	               d
       w |j	                  |d   |d	   |d   j                         |d        |d   |dS )u   
    Transcreve o áudio de um vídeo/áudio e retorna:
    {
        "texto": "texto completo",
        "segmentos": [{"inicio": 0.0, "fim": 2.5, "texto": "Olá pessoal"}, ...]
    }
    ptT)languageword_timestampssegmentswordsword startend)r   r   r   text)iniciofimtextor   )r   	segmentos)r   
transcribegetstripappendfloat)	r   modelresultr   seg	words_rawr   wtxts	            r   transcrever_audior)      s    KEj4NFIj! GGG$*	 	A55=&B--/CLLquuWc'l;<QUU5#e*56 		 	'lu:[&&(	
 	*  r
   )__doc__r   r   r   strdictr)   r	   r
   r   <module>r-      s(    7 	## #$ #r
   