<s> """<STR_LIT>""" <EOL> import argparse <EOL> import base64 <EOL> import json <EOL> import os <EOL> from googleapiclient import discovery <EOL> import httplib2 <EOL> from oauth2client . client import GoogleCredentials <EOL> API_DISCOVERY_FILE = os . path . join ( <EOL> os . path . dirname ( __file__ ) , '<STR_LIT>' ) <EOL> def get_speech_service ( ) : <EOL> credentials = GoogleCredentials . get_application_default ( ) . create_scoped ( <EOL> [ '<STR_LIT>' ] ) <EOL> with open ( API_DISCOVERY_FILE , '<STR_LIT:r>' ) as f : <EOL> doc = f . read ( ) <EOL> return discovery . build_from_document ( <EOL> doc , credentials = credentials , http = httplib2 . Http ( ) ) <EOL> def main ( speech_file ) : <EOL> """<STR_LIT>""" <EOL> with open ( speech_file , '<STR_LIT:rb>' ) as speech : <EOL> speech_content = base64 . b64encode ( speech . read ( ) ) <EOL> service = get_speech_service ( ) <EOL> service_request = service . speech ( ) . recognize ( <EOL> body = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:content>' : speech_content . decode ( '<STR_LIT>' ) <EOL> } <EOL> } ) <EOL> response = service_request . execute ( ) <EOL> print ( json . dumps ( response ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> parser = argparse . ArgumentParser ( ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> args = parser . parse_args ( ) <EOL> main ( args . speech_file ) </s>
