Skip to content

Commit

Permalink
Merge pull request #304 from dcam0050/patch-1
Browse files Browse the repository at this point in the history
Update to speechContext formatting for recognize_google_cloud
  • Loading branch information
Uberi authored Dec 11, 2017
2 parents 376153b + b5b6197 commit c932096
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion speech_recognition/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ def recognize_google_cloud(self, audio_data, credentials_json=None, language="en

speech_config = {"encoding": "FLAC", "sampleRateHertz": audio_data.sample_rate, "languageCode": language}
if preferred_phrases is not None:
speech_config["speechContext"] = {"phrases": preferred_phrases}
speech_config["speechContexts"] = [{"phrases": preferred_phrases}]
if show_all:
speech_config["enableWordTimeOffsets"] = True # some useful extra options for when we want all the output
request = speech_service.speech().recognize(body={"audio": {"content": base64.b64encode(flac_data).decode("utf8")}, "config": speech_config})
Expand Down

0 comments on commit c932096

Please sign in to comment.