
    i                        d dl mZ d dlZd dlmZ d dlmZmZmZm	Z	m
Z
mZ d dlmZ erd dlmZ  G d de      Ze	 	 	 	 	 	 dd	       Ze	 	 	 	 	 	 dd
       Zdd	 	 	 	 	 ddZy)    )annotationsN)Path)TYPE_CHECKINGLiteral	TypedDictUnioncastoverload)
SetupError)	AudioDatac                      e Zd ZU ded<   y)VoskResponsestrtextN)__name__
__module____qualname____annotations__     a/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/speech_recognition/recognizers/vosk.pyr   r      s    
Ir   r   c                    y Nr   _recognizer
audio_dataverboses      r   	recognizer      s     r   c                    y r   r   r   s      r   r   r      s     r   F)r   c                  ddl m}m} t        t              j
                  j
                  dz  dz  }|j                         st        d| d      d} | |t        |            |      }|j                  |j                  |d	             |j                         }t        t        t        j                  |            }	|r|	S |	d
   S )aO  
    Perform speech recognition on ``audio_data`` using Vosk.

    Requires the Vosk model to be downloaded and unpacked in a folder named 'model' (``$PWD/model``).

    If ``verbose`` is ``False`` (default), only the recognized text is returned.
    If ``verbose`` is ``True``, the parsed result dictionary from Vosk is returned.
    r   )KaldiRecognizerModelmodelsvoskzVosk model not found at z?. Please download the model using `sprc download vosk` command.i>     )convert_rateconvert_widthr   )r$   r!   r"   r   __file__parentexistsr   r   AcceptWaveformget_raw_dataFinalResultr	   r   jsonloads)
r   r   r   r!   r"   vosk_model_pathSAMPLE_RATErecfinal_recognitionresults
             r   r   r      s     ,8n++22X=FO!!#&&7 8L L
 	

 K
%O 45{
CC[J !__.,

+< =>F&>r   )r   r   r   zLiteral[False]returnr   )r   r   r   zLiteral[True]r5   r   )r   r   r   boolr5   zUnion[str, VoskResponse])
__future__r   r.   pathlibr   typingr   r   r   r   r	   r
   speech_recognition.exceptionsr   speech_recognition.audior   r   r   r   r   r   <module>r<      s    "   K K 429  
&4B 

 
&4A 
 <A!&!48!!r   