google.cloud.speech. v1
Enumerations
AudioEncoding
number
Audio encoding of the data sent in the audio message. All encodings support only 1 channel (mono) audio. Only FLAC
and WAV
include a header that describes the bytes of audio that follow the header. The other encodings
are raw audio bytes with no header.
For best results, the audio source should be captured and transmitted using a lossless encoding (FLAC
or LINEAR16
). Recognition accuracy may be reduced if lossy codecs, which include the other codecs listed in this
section, are used to capture or transmit the audio, particularly if background noise is present.
Value |
|
---|---|
ENCODING_UNSPECIFIED |
Not specified. Will return result google.rpc.Code.INVALID_ARGUMENT. |
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
Audio encoding of the data sent in the audio message. All encodings support only 1 channel (mono) audio. Only FLAC
and WAV
include a header that describes the bytes of audio that follow the header. The other encodings
are raw audio bytes with no header.
For best results, the audio source should be captured and transmitted using a lossless encoding (FLAC
or LINEAR16
). Recognition accuracy may be reduced if lossy codecs, which include the other codecs listed in this
section, are used to capture or transmit the audio, particularly if background noise is present.
Value |
|
---|---|
ENCODING_UNSPECIFIED |
Not specified. Will return result google.rpc.Code.INVALID_ARGUMENT. |
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
audio 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 Required Encoding of audio data sent in all The number should be among the values of AudioEncoding |
sampleRateHertz |
number Required Sample rate in Hertz of the audio data sent in all
|
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 A means to provide context to assist the speech recognition. This object should have the same structure as SpeechContext |
enableWordTimeOffsets |
boolean Optional 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 typically provided only for the top hypothesis, and
only for |
words |
Array of Object Output-only A list of word-specific information for each recognized word. This object should have the same structure as WordInfo |
SpeechRecognitionResult
A speech recognition result corresponding to a portion of the audio.
Property
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 |
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 ( |
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 more 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. Word information is only included in the response when certain request parameters are set, such as enable_word_time_offsets
.
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. |