From f5568569a4f0dde5a579bc30d4e64d18ac30126a Mon Sep 17 00:00:00 2001 From: Jerjou Cheng Date: Fri, 22 Jul 2016 15:21:15 -0700 Subject: [PATCH] Add comments for config options. Some folks were tripping up on this. --- speech/api/speech_rest.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/speech/api/speech_rest.py b/speech/api/speech_rest.py index e6f83fb4a6e4..b74a64cacd30 100644 --- a/speech/api/speech_rest.py +++ b/speech/api/speech_rest.py @@ -44,7 +44,7 @@ def get_speech_service(): # [END authenticating] -def main(speech_file): +def main(speech_file, language_code='en-US'): """Transcribe the given audio file. Args: @@ -60,8 +60,12 @@ def main(speech_file): service_request = service.speech().syncrecognize( body={ 'config': { - 'encoding': 'LINEAR16', - 'sampleRate': 16000 + # There are a bunch of config options you can specify. See + # https://cloud.google.com/speech/reference/rest/Shared.Types/RecognitionConfig # noqa + # for the full list. + 'encoding': 'LINEAR16', # raw 16-bit signed LE samples + 'sampleRate': 16000, # 16 khz + 'languageCode': language_code, # a BCP-47 language tag }, 'audio': { 'content': speech_content.decode('UTF-8')