
    jk                     8   d dl Z d dlZd dlmZ ddlmZ dZ	 d dlZ ej                         5   ej                  de
        ej                  de       d dlZd dlZddd       ddd	ed
edefdZy# 1 sw Y   xY w# e$ r  ej                          ZY 2w xY w)    N)BinaryIO   )MissingDependencyExceptionignore)categorywav)audio_formatfile_streamr	   returnc                6   t         )t        d      t         d   j                  t         d         |dv r| }nl|dv rZt        j                  j                  | |      }t        j                         }|j                  |d       |j                  d       nt        d	|       t        j                         }t        j                  |      5 }|j                  |      }|j                  |      j!                         }|d
k(  rdn|cd d d        S # 1 sw Y   y xY w)NzSpeech transcription requires installing MarkItdown with the [audio-transcription] optional dependencies. E.g., `pip install markitdown[audio-transcription]` or `pip install markitdown[all]`   r   )r   aiffflac)mp3mp4)formatr   r   zUnsupported audio format:  z[No speech detected])_dependency_exc_infor   with_tracebackpydubAudioSegment	from_fileioBytesIOexportseek
ValueErrorsr
Recognizer	AudioFilerecordrecognize_googlestrip)r
   r	   audio_sourceaudio_segment
recognizersourceaudio
transcripts           h/root/aria/tools/markitdown-venv/lib/python3.12/site-packages/markitdown/converters/_transcribe_audio.pytranscribe_audior+      s   '( M
#

. #
		
 .."		'**44[4Vzz|\%8!5l^DEEJ	l	# Jv!!&)007==?
)3r)9%zJ J Js   9DD)r   systypingr   _exceptionsr   r   warningscatch_warningsfilterwarningsDeprecationWarningSyntaxWarningspeech_recognitionr   r   ImportErrorexc_infostrr+        r*   <module>r:      s    	 
  4  *	 	 	 	" 3EF=A'	 DI J( JS JS J 
  *'3<<>*s(   B  1A4B  4A=9B   BB