
                            S r SSKJr  SSKJr  SSKJr  SSKJr  \R                  " \R                  R                  5       " S S\R                  5      5       r\R                  " \R                  R                  5       " S S	\5      5       rS
\R                  S'   \R                  " \R                  R                   5       " S S\5      5       rg)z#Recognize speech in provided audio.    )apis)base)flags)utilc                   l    \ rS rSrSrSSSS.rSr\R                  " 5       r	\
S 5       rS	 rS
 rS rSrg)RecognizeGA   zIGet transcripts of short (less than 60 seconds) audio from an audio file.a  Get a transcript of an audio file that is less than 60 seconds. You can use
an audio file that is on your local drive or a Google Cloud Storage URL.

If the audio is longer than 60 seconds, you will get an error. Please use
`{parent_command} recognize-long-running` instead.
a  To get a transcript of an audio file 'my-recording.wav':

    $ {command} 'my-recording.wav' --language-code=en-US

To get a transcript of an audio file in bucket 'gs://bucket/myaudio' with a
custom sampling rate and encoding that uses hints and filters profanity:

    $ {command} 'gs://bucket/myaudio' \
        --language-code=es-ES --sample-rate=2200 --hints=Bueno \
        --encoding=OGG_OPUS --filter-profanity
zThis command uses the speech/v1 API. The full documentation for this API
can be found at: https://cloud.google.com/speech-to-text/docs/quickstart-protocol
)DESCRIPTIONEXAMPLESAPI REFERENCEv1c                     UR                   R                  S5        U R                  R                  XR                  5        g )Njson)display_info	AddFormatflags_mapperAddRecognizeArgsToParserAPI_VERSION)clsparsers     "lib/surface/ml/speech/recognize.pyArgsRecognizeGA.Args<   s.    
!!&)--fooF    c                     UR                  [        R                  " UR                  U R                  5      U R
                  R                  X5      S9$ )N)audioconfig)RecognizeRequestr   GetRecognitionAudioFromPathr   r   r   MakeRecognitionConfig)selfargsmessagess      r   MakeRequestRecognizeGA.MakeRequestA   sJ    $$..tzz4;K;KL  66tF % H Hr   c                     [         R                  " [        R                  U R                  5      nU R                  XR                  5      U l        UR                  R                  U R                  5      $ )zRun 'ml speech recognize'.

Args:
  args: argparse.Namespace, The arguments that this command was invoked
    with.

Returns:
  Nothing.
)
r   GetClientInstancer   
SPEECH_APIr   r$   MESSAGES_MODULE_requestspeech	Recognize)r!   r"   clients      r   RunRecognizeGA.RunF   sQ     ##DOOT5E5EFF$$T+A+ABDM==""4==11r   c                 D    [         R                  " U R                  5        g N)r   MaybePrintSttUiLinkr*   )r!   unused_resources_were_displayeds     r   EpilogRecognizeGA.EpilogT   s    T]]+r   )r*   N)__name__
__module____qualname____firstlineno____doc__detailed_helpr   r   RecognizeArgsToRequestMapperr   classmethodr   r$   r.   r4   __static_attributes__ r   r   r   r      sT    Q/-: +335,G GH
2,r   r   c                      ^  \ rS rSr\R
                  r\R                  R                  5       rSr\	U 4S j5       r
U 4S jrSrU =r$ )RecognizeBetaX   	v1p1beta1c                 j   > [         [        [        ]  U5        U R                  R	                  U5        g r1   )superrA   r   r   AddBetaRecognizeArgsToParserr   r   	__class__s     r   r   RecognizeBeta.Args_   s&    	-,V411&9r   c                 x   > [         [        U ]  X5      nU R                  R	                  XR
                  5        U$ r1   )rE   rA   r$   r   !UpdateBetaArgsInRecognitionConfigr   r!   r"   r#   requestrH   s       r   r$   RecognizeBeta.MakeRequestd   s1    M44TDG77nnMNr   r?   )r6   r7   r8   r9   r   r:   r;   copyr   r=   r   r$   r>   __classcell__rH   s   @r   rA   rA   X   sC    '++002-+: : r   rA   zThis command uses the speech/v1p1beta1 API. The full documentation for this API
can be found at: https://cloud.google.com/speech-to-text/docs/quickstart-protocol
r   c                   Z   ^  \ rS rSr\R
                  rSr\U 4S j5       rU 4S jr	Sr
U =r$ )RecognizeAlphap   rC   c                 ~   > [         [        [        ]  U5        U R                  R	                  XR
                  5        g r1   )rE   rS   r   r   AddAlphaRecognizeArgsToParserr   rG   s     r   r   RecognizeAlpha.Argsv   s*    	...v6226??Kr   c                 x   > [         [        U ]  X5      nU R                  R	                  XR
                  5        U$ r1   )rE   rS   r$   r   "UpdateAlphaArgsInRecognitionConfigr   rL   s       r   r$   RecognizeAlpha.MakeRequest{   s1    ND5dEG88~~NNr   r?   )r6   r7   r8   r9   rA   r:   r   r=   r   r$   r>   rP   rQ   s   @r   rS   rS   p   s1    !!'+L L r   rS   N)r:   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   $googlecloudsdk.command_lib.ml.speechr   r   ReleaseTracksReleaseTrackGACommandr   BETArA   r;   ALPHArS   r?   r   r   <module>rd      s    * - ( 6 5 D%%(()<,$,, <, *<,~ D%%**+K  ,"0  O , D%%++,]  -r   