Basic client for Google Cloud Speech API.
Client(credentials=None, http=None, use_gax=None)#
Client to bundle configuration needed for API requests.
- credentials (
Credentials) – (Optional) The OAuth2 Credentials to use for this client. If not passed (and if no
httpobject is passed), falls back to the default inferred from the environment.
- http (
Http) – (Optional) HTTP object to make requests. Can be any object that defines
request()with the same interface as
request(). If not passed, an
httpobject is created that is bound to the
credentialsfor the current object.
- use_gax (bool) – (Optional) Explicitly specifies whether
to use the gRPC transport (via GAX) or HTTP. If unset,
falls back to the
The scopes required for authenticating as an API consumer.
sample(content=None, source_uri=None, stream=None, encoding=None, sample_rate=None)#
Factory: construct Sample to use when making recognize requests.
- content (bytes) – (Optional) Bytes containing audio data.
- source_uri (str) – (Optional) URI that points to a file that contains
audio data bytes as specified in RecognitionConfig.
Currently, only Google Cloud Storage URIs are
supported, which must be specified in the following
- stream (file) – (Optional) File like object to stream.
- encoding (str) – encoding of audio data sent in all RecognitionAudio
messages, can be one of:
- sample_rate (int) – Sample rate in Hertz of the audio data sent in all requests. Valid values are: 8000-48000. For best results, set the sampling rate of the audio source to 16000 Hz. If that’s not possible, use the native sample rate of the audio source (instead of re-sampling).
Return type: Returns:
Helper for speech-related API calls.
- credentials (