Public Member Functions | |
def | recognize_google_cloud (self, audio_data, credentials_json=None, language="en-US", preferred_phrases=None, show_all=False, user_config={}) |
Definition at line 9 of file recognize_google_cloud.py.
def ros_speech_recognition.recognize_google_cloud.RecognizerEx.recognize_google_cloud | ( | self, | |
audio_data, | |||
credentials_json = None , |
|||
language = "en-US" , |
|||
preferred_phrases = None , |
|||
show_all = False , |
|||
user_config = {} |
|||
) |
Performs speech recognition on ``audio_data`` (an ``AudioData`` instance), using the Google Cloud Speech API. This function requires a Google Cloud Platform account; see the `Google Cloud Speech API Quickstart <https://cloud.google.com/speech/docs/getting-started>`__ for details and instructions. Basically, create a project, enable billing for the project, enable the Google Cloud Speech API for the project, and set up Service Account Key credentials for the project. The result is a JSON file containing the API credentials. The text content of this JSON file is specified by ``credentials_json``. If not specified, the library will try to automatically `find the default API credentials JSON file <https://developers.google.com/identity/protocols/application-default-credentials>`__. The recognition language is determined by ``language``, which is a BCP-47 language tag like ``"en-US"`` (US English). A list of supported language tags can be found in the `Google Cloud Speech API documentation <https://cloud.google.com/speech/docs/languages>`__. If ``preferred_phrases`` is an iterable of phrase strings, those given phrases will be more likely to be recognized over similar-sounding alternatives. This is useful for things like keyword/command recognition or adding new phrases that aren't in Google's vocabulary. Note that the API imposes certain `restrictions on the list of phrase strings <https://cloud.google.com/speech/limits#content>`__. Returns the most likely transcription if ``show_all`` is False (the default). Otherwise, returns the raw API response as a JSON dictionary. Raises a ``speech_recognition.UnknownValueError`` exception if the speech is unintelligible. Raises a ``speech_recognition.RequestError`` exception if the speech recognition operation failed, if the credentials aren't valid, or if there is no Internet connection.
Definition at line 10 of file recognize_google_cloud.py.