2020"""
2121
2222import argparse
23+ import time
2324
2425import google .auth
2526import google .auth .transport .grpc
@@ -44,13 +45,15 @@ def make_channel(host, port):
4445 credentials , http_request , target )
4546
4647
47- def main (input_uri , encoding , sample_rate , language_code = 'en-US ' ):
48+ def main (input_uri , encoding , sample_rate , language_code = 'ja-JP ' ):
4849 service = cloud_speech_pb2 .SpeechStub (
50+ #make_channel('jerjou-dev-speech.sandbox.googleapis.com', 443))
4951 make_channel ('speech.googleapis.com' , 443 ))
5052
5153 # The method and parameters can be inferred from the proto from which the
5254 # grpc client lib was generated. See:
5355 # https://github.com/googleapis/googleapis/blob/master/google/cloud/speech/v1beta1/cloud_speech.proto
56+ start = time .time ()
5457 response = service .SyncRecognize (cloud_speech_pb2 .SyncRecognizeRequest (
5558 config = cloud_speech_pb2 .RecognitionConfig (
5659 # There are a bunch of config options you can specify. See
@@ -65,6 +68,7 @@ def main(input_uri, encoding, sample_rate, language_code='en-US'):
6568 uri = input_uri ,
6669 )
6770 ), DEADLINE_SECS )
71+ print ('Time: %s' % (time .time () - start ))
6872
6973 # Print the recognition result alternatives and confidence scores.
7074 for result in response .results :
@@ -90,9 +94,10 @@ def _gcs_uri(text):
9094 parser .add_argument ('input_uri' , type = _gcs_uri )
9195 parser .add_argument (
9296 '--encoding' , default = 'LINEAR16' , choices = [
93- 'LINEAR16' , 'FLAC' , 'MULAW' , 'AMR' , 'AMR_WB' ],
97+ 'LINEAR16' , 'FLAC' , 'MULAW' , 'AMR' , 'AMR_WB' , 'SPEEX_WITH_HEADER_BYTE' ],
9498 help = 'How the audio file is encoded. See {}#L67' .format (PROTO_URL ))
9599 parser .add_argument ('--sample_rate' , type = int , default = 16000 )
100+ parser .add_argument ('--lang' , default = 'en-US' )
96101
97102 args = parser .parse_args ()
98- main (args .input_uri , args .encoding , args .sample_rate )
103+ main (args .input_uri , args .encoding , args .sample_rate , args . lang )
0 commit comments