
    1h                        S SK Jr  S SKrS SKJr  S SKJr  S SKJr  S SK	J
r
Jr  \r\r\r\\\\4   r\r\r\\\4   r    S         S	S jjrg)
    )annotationsN)Sequence)PortableNamedTemporaryFile)	AudioData)RequestErrorUnknownValueErrorc           	     T
   Ub  [        S U 5       5      (       d   S5       e SSKJnJnJn  [        U[        5      (       Ga  [        R                  R                  [        R                  R                  [        R                  R                  [        R                  R                  [        5      5      5      SU5      n	[        R                  R                  U	5      (       d  [        SR                  U	5      5      e[        R                  R                  U	S	5      n
[        R                  R                  U	S
5      n[        R                  R                  U	S5      nOUu  pn[        R                  R                  U
5      (       d  [        SR                  U
5      5      e[        R                  R!                  U5      (       d  [        SR                  U5      5      e[        R                  R!                  U5      (       d  [        SR                  U5      5      eUR#                  5       nUR%                  SU
5        UR%                  SU5        UR%                  SU5        UR%                  S[        R&                  5        UR)                  U5      nUR+                  SSS9nUbk  [-        S5       nUR/                  S U 5       5        UR1                  5         UR3                  SUR4                  5        UR7                  S5        SSS5        GOUGb  [        R                  R9                  U5      (       d  [;        SR                  U5      5      e[        R                  R=                  [        R                  R                  U5      5      n[        R                  R?                  [        R                  RA                  U5      5      S   nSR                  UU5      n[        R                  R9                  U5      (       d[  U" U5      nURC                  SR                  U5      5      nURE                  UURG                  5       S5      nURI                  U5        OU" UURG                  5       S5      nURK                  UU5        URM                  U5        URO                  5         URQ                  USS5        URS                  5         U(       a  U$ URU                  5       nUb  URV                  $ [Y        5       e! [         a    [        S5      ef = f! , (       d  f       N= f)a4  
Performs speech recognition on ``audio_data`` (an ``AudioData`` instance), using CMU Sphinx.

The recognition language is determined by ``language``, an RFC5646 language tag like ``"en-US"`` or ``"en-GB"``, defaulting to US English. Out of the box, only ``en-US`` is supported. See `Notes on using `PocketSphinx <https://github.com/Uberi/speech_recognition/blob/master/reference/pocketsphinx.rst>`__ for information about installing other languages. This document is also included under ``reference/pocketsphinx.rst``. The ``language`` parameter can also be a tuple of filesystem paths, of the form ``(acoustic_parameters_directory, language_model_file, phoneme_dictionary_file)`` - this allows you to load arbitrary Sphinx models.

If specified, the keywords to search for are determined by ``keyword_entries``, an iterable of tuples of the form ``(keyword, sensitivity)``, where ``keyword`` is a phrase, and ``sensitivity`` is how sensitive to this phrase the recognizer should be, on a scale of 0 (very insensitive, more false negatives) to 1 (very sensitive, more false positives) inclusive. If not specified or ``None``, no keywords are used and Sphinx will simply transcribe whatever words it recognizes. Specifying ``keyword_entries`` is more accurate than just looking for those same keywords in non-keyword-based transcriptions, because Sphinx knows specifically what sounds to look for.

Sphinx can also handle FSG or JSGF grammars. The parameter ``grammar`` expects a path to the grammar file. Note that if a JSGF grammar is passed, an FSG grammar will be created at the same location to speed up execution in the next run. If ``keyword_entries`` are passed, content of ``grammar`` will be ignored.

Returns the most likely transcription if ``show_all`` is false (the default). Otherwise, returns the Sphinx ``pocketsphinx.pocketsphinx.Decoder`` object resulting from the recognition.

Raises a ``speech_recognition.UnknownValueError`` exception if the speech is unintelligible. Raises a ``speech_recognition.RequestError`` exception if there are any issues with the Sphinx installation.
Nc              3     #    U  HC  u  p[        U[        S 5      [        S 5      45      =(       a    SUs=:*  =(       a    S:*  Os  v   ME     g7f) r      N)
isinstancetype.0keywordsensitivitys      c/var/www/auris/envauris/lib/python3.13/site-packages/speech_recognition/recognizers/pocketsphinx.py	<genexpr>recognize.<locals>.<genexpr>*   sQ       *\  L[  tHsz*WtBxc>S*T*nYZ^iYnYnmnYn*n  L[s   AAz^``keyword_entries`` must be ``None`` or a list of pairs of strings and numbers between 0 and 1r   )FsgModelJsgfpocketsphinxzJmissing PocketSphinx module: ensure that PocketSphinx is set up correctly.zpocketsphinx-dataz2missing PocketSphinx language data directory: "{}"zacoustic-modelzlanguage-model.lm.binzpronounciation-dictionary.dictz>missing PocketSphinx language model parameters directory: "{}"z.missing PocketSphinx language model file: "{}"z2missing PocketSphinx phoneme dictionary file: "{}"z-hmmz-lmz-dictz-logfni>     )convert_rateconvert_widthwc              3  V   #    U  H  u  pS R                  USU-  S-
  5      v   M!     g7f)z
{} /1e{}/
d   n   N)formatr   s      r   r   r   P   s0     |l{ThT[--gs[7H37NOOl{s   ')keywordszGrammar '{0}' does not exist.z{0}/{1}.fsgz{0}.{0}g      @FT)-allr   r   r   ImportErrorr   r   strospathjoindirnamerealpath__file__isdirr    isfileConfig
set_stringdevnullDecoderget_raw_datar   
writelinesflushadd_kwsnameactivate_searchexists
ValueErrorabspathsplitextbasenameget_rule	build_fsgget_logmath	writefileset_fsg
set_search	start_uttprocess_rawend_utthyphypstrr   )
recognizer
audio_datalanguagekeyword_entriesgrammarshow_allr   r   r   language_directoryacoustic_parameters_directorylanguage_model_filephoneme_dictionary_fileconfigdecoderraw_datafgrammar_pathgrammar_namefsg_pathjsgfrulefsg
hypothesiss                           r   	recognizer\      s'   , "c  *\  L[  *\  '\  '\  ~  ^~  ~  \i== (C  WW\\"''//"''//"''JZJZ[cJd:e*fh{  ~F  Gww}}/00U\\]opqq(*5GIY(Z% ggll+=?VW"$'',,/ACc"dV^S%<S77==677]dd  fC  D  E  	E77>>-..MTTUhijj77>>122QXXYpqrr   "F
f;<
e01
g67
h

+""6*G &&E&KH "',LL|l{||GGI OOJ/##J/ -, 
	ww~~g&&<CCGLMMwwrwww'?@ww''(8(8(AB1E ''lCww~~h''=D==!1!1,!?@D..w':':'<cBCMM(#8W%8%8%:C@Cc*<(%.OO Jj&7&77

C  ighhi@ -,s   
T  2AT T
T')zen-USNNF)
rH   r   rI   zstr | SphinxDataFilePathsrJ   zSequence[KeywordEntry] | NonerK   z
str | NonerL   bool)
__future__r   r%   collections.abcr   speech_recognitionr   speech_recognition.audior   speech_recognition.exceptionsr   r   r$   AcousticParametersDirectoryPathLanguageModelFilePathPhonemeDictionaryFilePathtupleSphinxDataFilePathsKeywordfloatSensitivityKeywordEntryr\        r   <module>rn      s    " 	 $ 9 . I"%   ;=RTmmn 
Wk)* +259[[ ([ 3	[
 [ [rm   