
                            S r SSKJr  SSKJr  SSKJ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.    )absolute_import)division)unicode_literals)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.MakeRequestD   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.RunI   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.EpilogW   s    T]]+r   )r-   N)__name__
__module____qualname____firstlineno____doc__detailed_helpr   r   RecognizeArgsToRequestMapperr   classmethodr   r'   r1   r7   __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$ )RecognizeBeta[   	v1p1beta1c                 j   > [         [        [        ]  U5        U R                  R	                  U5        g r4   )superrD   r   r   AddBetaRecognizeArgsToParserr   r   	__class__s     r   r   RecognizeBeta.Argsb   s&    	-,V411&9r   c                 x   > [         [        U ]  X5      nU R                  R	                  XR
                  5        U$ r4   )rH   rD   r'   r   !UpdateBetaArgsInRecognitionConfigr    r$   r%   r&   requestrK   s       r   r'   RecognizeBeta.MakeRequestg   s1    M44TDG77nnMNr   rB   )r9   r:   r;   r<   r   r=   r>   copyr   r@   r   r'   rA   __classcell__rK   s   @r   rD   rD   [   sC    '++002-+: : r   rD   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$ )RecognizeAlphas   rF   c                 ~   > [         [        [        ]  U5        U R                  R	                  XR
                  5        g r4   )rH   rV   r   r   AddAlphaRecognizeArgsToParserr   rJ   s     r   r   RecognizeAlpha.Argsy   s*    	...v6226??Kr   c                 x   > [         [        U ]  X5      nU R                  R	                  XR
                  5        U$ r4   )rH   rV   r'   r   "UpdateAlphaArgsInRecognitionConfigr    rO   s       r   r'   RecognizeAlpha.MakeRequest~   s1    ND5dEG88~~NNr   rB   )r9   r:   r;   r<   rD   r=   r   r@   r   r'   rA   rS   rT   s   @r   rV   rV   s   s1    !!'+L L r   rV   N)r=   
__future__r   r   r   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   $googlecloudsdk.command_lib.ml.speechr   r	   ReleaseTracksReleaseTrackGACommandr   BETArD   r>   ALPHArV   rB   r   r   <module>rh      s    * &  ' , ( 6 5 D%%(()<,$,, <, *<,~ D%%**+K  ,"0  O , D%%++,]  -r   