
    -cJj                     <    d dl Z d dlmZmZ d Zd Z G d d      Zy)    N)	localtimestrftimec                  *    t        dt                     S )Nz%Y-%m-%d %H:%M:%S)r   r        ]/Users/ahmed/devFolder/claude-voice/.venv/lib/python3.12/site-packages/sherpa_onnx/display.pyget_current_timer	      s    '55r   c                  b    t        j                  t         j                  dk(  rd       y d       y )Nntclsclear)ossystemnamer   r   r   clear_consoler   
   s    IIrww$e4G4r   c                   (    e Zd ZdZd Zd Zd Zd Zy)DisplayzA class for displaying real-time speech recognition results.

    It maintains a history of finalized sentences and the current
    in-progress text, and renders them to the console.
    c                      g | _         d| _        y)z;Initialize the display with empty history and current text. N)	sentencescurrentTextselfs    r   __init__zDisplay.__init__   s    r   c                     || _         y)zUpdate the current in-progress text.

        Args:
          text:
            The new text to display as the current recognition result.
        N)r   )r   texts     r   update_textzDisplay.update_text   s      r   c                     | j                   j                         r/| j                  j                  t	               | j                   f       d| _         y)zFinalize the current sentence and add it to the history.

        If the current text is non-empty (after stripping whitespace), it is
        appended to the sentence history with a timestamp. The current text
        is then cleared.
        r   N)r   stripr   appendr	   r   s    r   finalize_current_sentencez!Display.finalize_current_sentence#   s?     !!#NN!!#3#5t7G7G"HIr   c           	      j   t                t        d       t        dt                      t        d       | j                  rBt	        | j                        D ]  \  }\  }}t        d| d|dz    d|        ! t        d       | j
                  j                         rt        d| j
                         y	y	)
zRender the display to the console.

        Clears the console and prints the header, finalized sentence history,
        and the current in-progress recognition text.
        z.=== Speech Recognition with Next-gen Kaldi ===zTime:z------------------------------[z]    z. zRecognizing:N)r   printr	   r   	enumerater   r   )r   iwhenr   s       r   displayzDisplay.display/   s     	>?g')*h >>#,T^^#<<D$$r!a%4&12 $=(O!!#.$"2"23 $r   N)__name__
__module____qualname____doc__r   r   r!   r)   r   r   r   r   r      s    
 
4r   r   )r   timer   r   r	   r   r   r   r   r   <module>r/      s    	 $6534 34r   