google.cloud.speech. v1
Enumerations
AudioEncoding
number
The encoding of the audio data sent in the request.
All encodings support only 1 channel (mono) audio.
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
, OGG_OPUS
, and SPEEX_WITH_HEADER_BYTE
.
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.
Value |
|
---|---|
ENCODING_UNSPECIFIED |
Not specified. |
LINEAR16 |
Uncompressed 16-bit signed little-endian samples (Linear PCM). |
FLAC |
|
MULAW |
8-bit samples that compand 14-bit audio samples using G.711 PCMU/mu-law. |
AMR |
Adaptive Multi-Rate Narrowband codec. |
AMR_WB |
Adaptive Multi-Rate Wideband codec. |
OGG_OPUS |
Opus encoded audio frames in Ogg container (
OggOpus).
|
SPEEX_WITH_HEADER_BYTE |
Although the use of lossy encodings is not recommended, if a very low bitrate encoding is required, |
SpeechEventType
number
Indicates the type of speech event.
Value |
|
---|---|
SPEECH_EVENT_UNSPECIFIED |
No speech event specified. |
END_OF_SINGLE_UTTERANCE |
This event indicates that the server has detected the end of the user's speech utterance and expects no additional speech. Therefore, the server will not process additional audio (although it may subsequently return additional
results). The client should stop sending additional audio data, half-close the gRPC connection, and wait for any additional results until the server closes the gRPC connection. This event is only sent if
|
Properties
AudioEncoding
number
The encoding of the audio data sent in the request.
All encodings support only 1 channel (mono) audio.
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
, OGG_OPUS
, and SPEEX_WITH_HEADER_BYTE
.
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.
Value |
|
---|---|
ENCODING_UNSPECIFIED |
Not specified. |
LINEAR16 |
Uncompressed 16-bit signed little-endian samples (Linear PCM). |
FLAC |
|
MULAW |
8-bit samples that compand 14-bit audio samples using G.711 PCMU/mu-law. |
AMR |
Adaptive Multi-Rate Narrowband codec. |
AMR_WB |
Adaptive Multi-Rate Wideband codec. |
OGG_OPUS |
Opus encoded audio frames in Ogg container (
OggOpus).
|
SPEEX_WITH_HEADER_BYTE |
Although the use of lossy encodings is not recommended, if a very low bitrate encoding is required, |
SpeechEventType
number
Indicates the type of speech event.
Value |
|
---|---|
SPEECH_EVENT_UNSPECIFIED |
No speech event specified. |
END_OF_SINGLE_UTTERANCE |
This event indicates that the server has detected the end of the user's speech utterance and expects no additional speech. Therefore, the server will not process additional audio (although it may subsequently return additional
results). The client should stop sending additional audio data, half-close the gRPC connection, and wait for any additional results until the server closes the gRPC connection. This event is only sent if
|
Abstract types
LongRunningRecognizeMetadata
Describes the progress of a long-running LongRunningRecognize
call. It is included in the metadata
field of the Operation
returned by the
GetOperation
call of the google::longrunning::Operations
service.
Properties
Parameter |
|
---|---|
progressPercent |
number Approximate percentage of audio processed thus far. Guaranteed to be 100 when the audio is fully processed and the results are available. |
startTime |
Object Time when the request was received. This object should have the same structure as Timestamp |
lastUpdateTime |
Object Time of the most recent processing update. This object should have the same structure as Timestamp |
LongRunningRecognizeRequest
The top-level message sent by the client for the LongRunningRecognize
method.
Properties
Parameter |
|
---|---|
config |
Object Required Provides information to the recognizer that specifies how to process the request. This object should have the same structure as RecognitionConfig |
audio |
Object Required The audio data to be recognized. This object should have the same structure as RecognitionAudio |
LongRunningRecognizeResponse
The only message returned to the client by the LongRunningRecognize
method. It contains the result as zero or more sequential SpeechRecognitionResult
messages. It is included in the result.response
field of the Operation
returned by the GetOperation
call of the google::longrunning::Operations
service.
Property
Parameter |
|
---|---|
results |
Array of Object Output only. Sequential list of transcription results corresponding to sequential portions of audio. This object should have the same structure as SpeechRecognitionResult |
RecognitionAudio
Contains audio data in the encoding specified in the RecognitionConfig
. Either content
or uri
must be supplied. Supplying both or neither returns google.rpc.Code.INVALID_ARGUMENT. See
content limits.
Properties
Parameter |
|
---|---|
content |
string The audio data bytes encoded as specified in
|
uri |
string URI that points to a file that contains audio data bytes as specified in
|
RecognitionConfig
Provides information to the recognizer that specifies how to process the request.
Properties
Parameter |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
encoding |
number Encoding of audio data sent in all The number should be among the values of AudioEncoding |
||||||||||
sampleRateHertz |
number Sample rate in Hertz of the audio data sent in all
|
||||||||||
enableSeparateRecognitionPerChannel |
boolean This needs to be set to |
||||||||||
languageCode |
string Required The language of the supplied audio as a BCP-47 language tag. Example: "en-US". See Language Support for a list of the currently supported language codes. |
||||||||||
maxAlternatives |
number Optional Maximum number of recognition hypotheses to be returned. Specifically, the maximum number of |
||||||||||
profanityFilter |
boolean Optional If set to |
||||||||||
speechContexts |
Array of Object Optional array of SpeechContext. A means to provide context to assist the speech recognition. For more information, see Phrase Hints. This object should have the same structure as SpeechContext |
||||||||||
enableWordTimeOffsets |
boolean Optional If |
||||||||||
enableAutomaticPunctuation |
boolean Optional 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. Note: This is currently offered as an experimental service, complimentary to all users. In the future this may be exclusively available as a premium feature. |
||||||||||
model |
string Optional 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.
|
||||||||||
useEnhanced |
boolean
Optional Set to true to use an enhanced model for speech recognition. If
|
RecognizeRequest
The top-level message sent by the client for the Recognize
method.
Properties
Parameter |
|
---|---|
config |
Object Required Provides information to the recognizer that specifies how to process the request. This object should have the same structure as RecognitionConfig |
audio |
Object Required The audio data to be recognized. This object should have the same structure as RecognitionAudio |
RecognizeResponse
The only message returned to the client by the Recognize
method. It contains the result as zero or more sequential SpeechRecognitionResult
messages.
Property
Parameter |
|
---|---|
results |
Array of Object Output only. Sequential list of transcription results corresponding to sequential portions of audio. This object should have the same structure as SpeechRecognitionResult |
SpeechContext
Provides "hints" to the speech recognizer to favor specific words and phrases in the results.
Property
Parameter |
|
---|---|
phrases |
Array of string Optional A list of strings containing words and phrases "hints" so that the speech recognition is more likely to recognize them. This can be used to improve the accuracy for specific words and phrases, for example, if specific commands are typically spoken by the user. This can also be used to add additional words to the vocabulary of the recognizer. See usage limits. |
SpeechRecognitionAlternative
Alternative hypotheses (a.k.a. n-best list).
Properties
Parameter |
|
---|---|
transcript |
string Output only. Transcript text representing the words that the user spoke. |
confidence |
number Output only. The confidence estimate between 0.0 and 1.0. A higher number indicates an estimated greater likelihood that the recognized words are correct. This field is set only for the top alternative of a non-streaming result
or, of a streaming result where |
words |
Array of Object Output only. A list of word-specific information for each recognized word. Note: When This object should have the same structure as WordInfo |
SpeechRecognitionResult
A speech recognition result corresponding to a portion of the audio.
Properties
Parameter |
|
---|---|
alternatives |
Array of Object Output only. May contain one or more recognition hypotheses (up to the maximum specified in This object should have the same structure as SpeechRecognitionAlternative |
channelTag |
number 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.
Properties
Parameter |
|
---|---|
config |
Object Required Provides information to the recognizer that specifies how to process the request. This object should have the same structure as RecognitionConfig |
singleUtterance |
boolean Optional If If |
interimResults |
boolean Optional If |
StreamingRecognitionResult
A streaming speech recognition result corresponding to a portion of the audio that is currently being processed.
Properties
Parameter |
|
---|---|
alternatives |
Array of Object Output only. May contain one or more recognition hypotheses (up to the maximum specified in This object should have the same structure as SpeechRecognitionAlternative |
isFinal |
boolean Output only. If |
stability |
number Output only. An estimate of the likelihood that the recognizer will not change its guess about this interim result. Values range from 0.0 (completely unstable) to 1.0 (completely stable). This field is only provided for interim
results ( |
channelTag |
number 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
data. All subsequent messages must contain audio
data and must not contain a
streaming_config
message.
Properties
Parameter |
|
---|---|
streamingConfig |
Object Provides information to the recognizer that specifies how to process the request. The first This object should have the same structure as StreamingRecognitionConfig |
audioContent |
string 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. If there is no recognizable audio, and single_utterance
is set to false, then no
messages are streamed back to the client.
Here's an example of a series of ten StreamingRecognizeResponse
s that might be returned while processing audio:
-
results { alternatives { transcript: "tube" } stability: 0.01 }
-
results { alternatives { transcript: "to be a" } stability: 0.01 }
-
results { alternatives { transcript: "to be" } stability: 0.9 } results { alternatives { transcript: " or not to be" } stability: 0.01 }
-
results { alternatives { transcript: "to be or not to be"
confidence: 0.92 } alternatives { transcript: "to bee or not to bee" } is_final: true }
-
results { alternatives { transcript: " that's" } stability: 0.01 }
-
results { alternatives { transcript: " that is" } stability: 0.9 } results { alternatives { transcript: " the question" } stability: 0.01 }
-
results { alternatives { transcript: " that is the question"
confidence: 0.98 } alternatives { transcript: " that was the question" } is_final: true }
Notes:
-
Only two of the above responses #4 and #7 contain final results; they are indicated by
is_final: true
. Concatenating these together generates the full transcript: "to be or not to be that is the question". -
The others contain interim
results
. #3 and #6 contain two interimresults
: the first portion has a high stability and is less likely to change; the second portion has a low stability and is very likely to change. A UI designer might choose to show only high stabilityresults
. -
The specific
stability
andconfidence
values shown above are only for illustrative purposes. Actual values may vary. -
In each response, only one of these fields will be set:
error
,speech_event_type
, or one or more (repeated)results
.
Properties
Parameter |
|
---|---|
error |
Object Output only. If set, returns a google.rpc.Status message that specifies the error for the operation. This object should have the same structure as Status |
results |
Array of Object Output only. This repeated list contains zero or more results that correspond to consecutive portions of the audio currently being processed. It contains zero or one This object should have the same structure as StreamingRecognitionResult |
speechEventType |
number Output only. Indicates the type of speech event. The number should be among the values of SpeechEventType |
WordInfo
Word-specific information for recognized words.
Properties
Parameter |
|
---|---|
startTime |
Object Output only. Time offset relative to the beginning of the audio, and corresponding to the start of the spoken word. This field is only set if This object should have the same structure as Duration |
endTime |
Object Output only. Time offset relative to the beginning of the audio, and corresponding to the end of the spoken word. This field is only set if This object should have the same structure as Duration |
word |
string Output only. The word corresponding to this set of information. |