def _build_request_data(sample, language_code=None, max_alternatives=None, profanity_filter=None, speech_context=None):
 if (sample.content is not None):
  audio = {'content': _bytes_to_unicode(b64encode(_to_bytes(sample.content)))}
 else:
  audio = {'uri': sample.source_uri}
 config = {'encoding': sample.encoding, 'sampleRate': sample.sample_rate}
 if (language_code is not None):
  config['languageCode'] = language_code
 if (max_alternatives is not None):
  config['maxAlternatives'] = max_alternatives
 if (profanity_filter is not None):
  config['profanityFilter'] = profanity_filter
 if (speech_context is not None):
  config['speechContext'] = {'phrases': speech_context}
 data = {'audio': audio, 'config': config}
 return data

def _build_request_data ( sample , language_code = None , max_alternatives = None , profanity_filter = None , speech_context = None ) : if ( sample . content is not None ) : audio = { 'content' : _bytes_to_unicode ( b64encode ( _to_bytes ( sample . content ) ) ) } else : audio = { 'uri' : sample . source_uri } config = { 'encoding' : sample . encoding , 'sampleRate' : sample . sample_rate } if ( language_code is not None ) : config [ 'languageCode' ] = language_code if ( max_alternatives is not None ) : config [ 'maxAlternatives' ] = max_alternatives if ( profanity_filter is not None ) : config [ 'profanityFilter' ] = profanity_filter if ( speech_context is not None ) : config [ 'speechContext' ] = { 'phrases' : speech_context } data = { 'audio' : audio , 'config' : config } return data
builds the request data before making api request .