
                             d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddl	mZ ej                   ej                  ej                  j                         G d	 d
ej                                       Zy)z9Cloud Speech-to-text recognizers run short audio command.    )absolute_import)division)unicode_literals)client)base)flag_validations)flags_v2c                   ,    e Zd ZdZd Zed        Zd Zy)RunBatchzGGet transcripts of long (more than 60 seconds) audio from a gcloud uri.c                 \    t        j                  |       t        j                  |d       y)zValidates run batch flags.T)batchN)r   ValidateDecodingConfigValidateAudioSource)selfargss     .lib/surface/ml/speech/recognizers/run_batch.pyValidateRunBatchFlagszRunBatch.ValidateRunBatchFlags   s     ++D1((T:    c                 2    t        j                  | d       y)z Register flags for this command.T)add_async_flagN)r	    AddRecognizeRequestFlagsToParser)parsers    r   ArgszRunBatch.Args#   s     --fTJr   c                    |j                   j                  j                         }t        j                         }| j                  |       g }|j                  |j                  |j                  |      \  }}|j                  ||d|      \  }}|j                  ||      \  |_        }|j                  s|j                  r|j                  ||      \  |_        }|j!                  ||j"                  ||      }|j$                  r|S |j'                  |j)                         j+                         |j,                  d      S )NT)default_to_auto_decoding_configupdate_mask)r   z%waiting for batch recognize to finish)locationoperation_refmessage)CONCEPTS
recognizerParser   SpeechV2Clientr   InitializeRecognitionConfigmodellanguage_codes InitializeDecodingConfigFromArgsInitializeASRFeaturesFromArgsfeatureshint_phraseshint_phrase_sets"InitializeAdaptationConfigFromArgs
adaptationr   audioasync_WaitForBatchRecognizeOperationParentNamename)r   r   resourcespeech_clientrecognition_config_update_maskrecognition_config	operations          r   RunzRunBatch.Run(   se   }}''--/H))+Mt$%'" 	11JJ++-K	
 76 	66,06	 	7 	
 76 	33< 	4 	
 @!? D11

:
: > ;  D#%C &&

2	 ' I {{77"'')nn7 8  r   N)__name__
__module____qualname____doc__r   staticmethodr   r9    r   r   r   r      s(     P;
 K K2r   r   N)r=   
__future__r   r   r    googlecloudsdk.api_lib.ml.speechr   googlecloudsdk.callioper   $googlecloudsdk.command_lib.ml.speechr   r	   UniverseCompatibleReleaseTracksReleaseTrackALPHACommandr   r?   r   r   <module>rI      sf    @ &  ' 3 ( A 9 D%%++,?t|| ? - ?r   