Speech
Service that implements Vertex AI Speech API.
Recognize | |
---|---|
Performs synchronous speech recognition: receive results after all audio has been sent and processed. |
StreamingRecognize | |
---|---|
Performs bidirectional streaming speech recognition: receive results while sending audio. This method is only available via the gRPC API (not REST). |
RecognitionAudio
Contains audio data in the encoding specified in the RecognitionConfig
. See content limits (https://cloud.google.com/speech-to-text/quotas#content).
Fields | ||
---|---|---|
Union field audio_source . The audio source is inline content. |
||
content |
The audio data bytes encoded as specified in |
RecognitionConfig
Provides information to the recognizer that specifies how to process the request.
Fields | |||||
---|---|---|---|---|---|
encoding |
Encoding of audio data sent in all |
||||
sample_rate_hertz |
Sample rate in Hertz of the audio data sent in all |
||||
audio_channel_count |
The number of channels in the input audio data. ONLY set this for MULTI-CHANNEL recognition. Valid values for LINEAR16 and FLAC are |
||||
enable_separate_recognition_per_channel |
This needs to be set to |
||||
language_code |
Required. The language of the supplied audio as a BCP-47 (https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag. Example: "en-US". See Language Support (https://cloud.google.com/speech-to-text/docs/languages) for a list of the currently supported language codes. |
||||
enable_automatic_punctuation |
If 'true', adds punctuation to recognition result hypotheses. This feature is only available in select languages. Setting this for requests in other languages has no effect at all. The default 'false' value does not add punctuation to result hypotheses. |
||||
model |
Which model to select for the given request. Select the model best suited to your domain to get best results. If a model is not explicitly specified, then we auto-select a model based on the parameters in the RecognitionConfig.
|
AudioEncoding
The encoding of the audio data sent in the request.
All encodings support only 1 channel (mono) audio, unless the audio_channel_count
and enable_separate_recognition_per_channel
fields are set.
For best results, the audio source should be captured and transmitted using a lossless encoding (FLAC
or LINEAR16
). The accuracy of the speech recognition can be reduced if lossy codecs are used to capture or transmit audio, particularly if background noise is present. Lossy codecs include MULAW
, AMR
, AMR_WB
, and OGG_OPUS
.
The FLAC
and WAV
audio file formats include a header that describes the included audio content. You can request recognition for WAV
files that contain either LINEAR16
or MULAW
encoded audio. If you send FLAC
or WAV
audio file format in your request, you do not need to specify an AudioEncoding
; the audio encoding format is determined from the file header. If you specify an AudioEncoding
when you send send FLAC
or WAV
audio, the encoding configuration must match the encoding described in the audio header; otherwise the request returns an google.rpc.Code.INVALID_ARGUMENT
error code.
Enums | |
---|---|
ENCODING_UNSPECIFIED |
Not specified. |
LINEAR16 |
Uncompressed 16-bit signed little-endian samples (Linear PCM). |
FLAC |
FLAC (Free Lossless Audio Codec) is the recommended encoding because it is lossless--therefore recognition is not compromised--and requires only about half the bandwidth of LINEAR16 . FLAC stream encoding supports 16-bit and 24-bit samples, however, not all fields in STREAMINFO are supported. |
MULAW |
8-bit samples that compand 14-bit audio samples using G.711 PCMU/mu-law. |
OGG_OPUS |
Opus encoded audio frames in Ogg container OggOpus (https://wiki.xiph.org/OggOpus). sample_rate_hertz must be one of 8000, 12000, 16000, 24000, or 48000. |
RecognizeRequest
The top-level message sent by the client for the Recognize
method.
Fields | |
---|---|
config |
Required. Provides information to the recognizer that specifies how to process the request. |
audio |
Required. The audio data to be recognized. |
RecognizeResponse
The only message returned to the client by the Recognize
method. It contains the result as zero or more sequential SpeechRecognitionResult
messages.
Fields | |
---|---|
results[] |
Sequential list of transcription results corresponding to sequential portions of audio. |
SpeechRecognitionAlternative
Alternative hypotheses (a.k.a. n-best list).
Fields | |
---|---|
transcript |
Transcript text representing the words that the user spoke. |
words[] |
A list of word-specific information for each recognized word. |
SpeechRecognitionResult
A speech recognition result corresponding to a portion of the audio.
Fields | |
---|---|
alternatives[] |
May contain one or more recognition hypotheses (up to the maximum specified in |
channel_tag |
For multi-channel audio, this is the channel number corresponding to the recognized result for the audio from that channel. For audio_channel_count = N, its output values can range from '1' to 'N'. |
StreamingRecognitionConfig
Provides information to the recognizer that specifies how to process the request.
Fields | |
---|---|
config |
Required. Provides information to the recognizer that specifies how to process the request. |
StreamingRecognitionResult
A streaming speech recognition result corresponding to a portion of the audio that is currently being processed.
Fields | |
---|---|
alternatives[] |
May contain one or more recognition hypotheses (up to the maximum specified in |
is_final |
If |
result_end_time |
Time offset of the end of this result relative to the beginning of the audio. |
channel_tag |
For multi-channel audio, this is the channel number corresponding to the recognized result for the audio from that channel. For audio_channel_count = N, its output values can range from '1' to 'N'. |
StreamingRecognizeRequest
The top-level message sent by the client for the StreamingRecognize
method. Multiple StreamingRecognizeRequest
messages are sent. The first message must contain a streaming_config
message and must not contain audio_content
. All subsequent messages must contain audio_content
and must not contain a streaming_config
message.
Fields | ||
---|---|---|
Union field streaming_request . The streaming request, which is either a streaming config or audio content. streaming_request can be only one of the following: |
||
streaming_config |
Provides information to the recognizer that specifies how to process the request. The first |
|
audio_content |
The audio data to be recognized. Sequential chunks of audio data are sent in sequential |
StreamingRecognizeResponse
StreamingRecognizeResponse
is the only message returned to the client by StreamingRecognize
. A series of zero or more StreamingRecognizeResponse
messages are streamed back to the client.
Here's an example of a series of StreamingRecognizeResponse
messages that might be returned while processing audio:
results
{ alternatives { transcript: "tube" } }results
{ alternatives { transcript: "to be a" } }results
{ alternatives { transcript: "to be" } }results
{ alternatives { transcript: " or not to be" } }results
{ alternatives { transcript: "to be or not to be" } alternatives { transcript: "to bee or not to bee" } is_final: true }results
{ alternatives { transcript: " that's" } }results
{ alternatives { transcript: " that is" } }results
{ alternatives { transcript: " the question" } }results
{ alternatives { transcript: " that is the question" } alternatives { transcript: " that was the question" } is_final: true }
Notes:
Responses #4 and #7 contain final results, which are indicated by
is_final: true
. Concatenating these messages together generates the full transcript: "to be or not to be that is the question."The other responses contain interim
results
. Responses #3 and #6 contain two interimresults
.
Fields | |
---|---|
error |
If set, returns a |
results[] |
This repeated list contains zero or more results that correspond to consecutive portions of the audio currently being processed. It contains zero or one |
speech_event_type |
Indicates the type of speech event. |
SpeechEventType
Indicates the type of speech event.
Enums | |
---|---|
SPEECH_EVENT_UNSPECIFIED |
No speech event specified. |
WordInfo
Word-specific information for recognized words.
Fields | |
---|---|
start_time |
Time offset relative to the beginning of the audio, and corresponding to the start of the spoken word. This field is only set if |
end_time |
Time offset relative to the beginning of the audio, and corresponding to the end of the spoken word. This field is only set if |
word |
The word corresponding to this set of information. |