diff --git a/speech_recognition/__init__.py b/speech_recognition/__init__.py index 78765c07..05ab1171 100644 --- a/speech_recognition/__init__.py +++ b/speech_recognition/__init__.py @@ -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})