Types for Google Cloud Mediatranslation v1beta1 API¶
- class google.cloud.mediatranslation_v1beta1.types.StreamingTranslateSpeechConfig(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
Config used for streaming translation.
- audio_config¶
Required. The common config for all the following audio contents.
- single_utterance¶
Optional. If
false
or omitted, the system performs continuous translation (continuing to wait for and process audio even if the user pauses speaking) until the client closes the input stream (gRPC API) or until the maximum time limit has been reached. May return multipleStreamingTranslateSpeechResult
s with theis_final
flag set totrue
.If
true
, the speech translator will detect a single spoken utterance. When it detects that the user has paused or stopped speaking, it will return anEND_OF_SINGLE_UTTERANCE
event and cease translation. When the client receives ‘END_OF_SINGLE_UTTERANCE’ event, the client should stop sending the requests. However, clients should keep receiving remaining responses until the stream is terminated. To construct the complete sentence in a streaming way, one should override (if ‘is_final’ of previous response is false), or append (if ‘is_final’ of previous response is true).- Type
- class google.cloud.mediatranslation_v1beta1.types.StreamingTranslateSpeechRequest(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
The top-level message sent by the client for the
StreamingTranslateSpeech
method. MultipleStreamingTranslateSpeechRequest
messages are sent. The first message must contain astreaming_config
message and must not containaudio_content
data. All subsequent messages must containaudio_content
data and must not contain astreaming_config
message.This message has oneof fields (mutually exclusive fields). For each oneof, at most one member field can be set at the same time. Setting any member of the oneof automatically clears all other members.
- streaming_config¶
Provides information to the recognizer that specifies how to process the request. The first
StreamingTranslateSpeechRequest
message must contain astreaming_config
message.This field is a member of oneof
streaming_request
.
- audio_content¶
The audio data to be translated. Sequential chunks of audio data are sent in sequential
StreamingTranslateSpeechRequest
messages. The firstStreamingTranslateSpeechRequest
message must not containaudio_content
data and all subsequentStreamingTranslateSpeechRequest
messages must containaudio_content
data. The audio bytes must be encoded as specified inStreamingTranslateSpeechConfig
. Note: as with all bytes fields, protobuffers use a pure binary representation (not base64).This field is a member of oneof
streaming_request
.- Type
- class google.cloud.mediatranslation_v1beta1.types.StreamingTranslateSpeechResponse(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
A streaming speech translation response corresponding to a portion of the audio currently processed.
- error¶
Output only. If set, returns a [google.rpc.Status][google.rpc.Status] message that specifies the error for the operation.
- Type
google.rpc.status_pb2.Status
- result¶
Output only. The translation result that is currently being processed (is_final could be true or false).
- speech_event_type¶
Output only. Indicates the type of speech event.
- class SpeechEventType(value)[source]¶
Bases:
proto.enums.Enum
Indicates the type of speech event.
- Values:
- SPEECH_EVENT_TYPE_UNSPECIFIED (0):
No speech event specified.
- END_OF_SINGLE_UTTERANCE (1):
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). When the client receives ‘END_OF_SINGLE_UTTERANCE’ event, the client should stop sending the requests. However, clients should keep receiving remaining responses until the stream is terminated. To construct the complete sentence in a streaming way, one should override (if ‘is_final’ of previous response is false), or append (if ‘is_final’ of previous response is true). This event is only sent if
single_utterance
was set totrue
, and is not used otherwise.
- class google.cloud.mediatranslation_v1beta1.types.StreamingTranslateSpeechResult(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
A streaming speech translation result corresponding to a portion of the audio that is currently being processed.
- class TextTranslationResult(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
Text translation result.
- is_final¶
Output only. If
false
, thisStreamingTranslateSpeechResult
represents an interim result that may change. Iftrue
, this is the final time the translation service will return this particularStreamingTranslateSpeechResult
, the streaming translator will not return any further hypotheses for this portion of the transcript and corresponding audio.- Type
- class google.cloud.mediatranslation_v1beta1.types.TranslateSpeechConfig(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
Provides information to the speech translation that specifies how to process the request.
- audio_encoding¶
Required. Encoding of audio data. Supported formats:
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 oflinear16
.mulaw
8-bit samples that compand 14-bit audio samples using G.711 PCMU/mu-law.
amr
Adaptive Multi-Rate Narrowband codec.
sample_rate_hertz
must be 8000.amr-wb
Adaptive Multi-Rate Wideband codec.
sample_rate_hertz
must be 16000.ogg-opus
Opus encoded audio frames in Ogg container.
sample_rate_hertz
must be one of 8000, 12000, 16000, 24000, or 48000.mp3
MP3 audio. Support all standard MP3 bitrates (which range from 32-320 kbps). When using this encoding,
sample_rate_hertz
has to match the sample rate of the file being used.
- Type
- sample_rate_hertz¶
Optional. Sample rate in Hertz of the audio data. Valid values are: 8000-48000. 16000 is optimal. 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).
- Type