LexRuntimeV2Client.recognize_utterance
rboto-lex-runtime-v2==0.4.0 · Service index · Types
Model summary (excerpt): Sends user input to Amazon Lex V2. You can send text or speech. Clients use this API to send text and audio requests to Amazon Lex V2 at runtime. Amazon Lex V2 interprets the user input using the machine learning model built for the bot. The following request fields must be compressed with gzip and then base64 encoded before you send them to Amazon Lex V2. requestAttributes sessionState The...
Install and imports
from rboto import LexRuntimeV2Client
from collections.abc import AsyncIterator
from rboto_lex_runtime_v2.types import (
RecognizeUtteranceOutput,
)
Signature
async def recognize_utterance(
*,
bot_id: str,
bot_alias_id: str,
locale_id: str,
session_id: str,
request_content_type: str,
session_state: str | None = None,
request_attributes: str | None = None,
response_content_type: str | None = None,
input_stream: bytes | _FileBody | AsyncIterator[bytes] | None = None,
) -> RecognizeUtteranceOutput: ...
Arguments without defaults are required. None omits an optional request argument. Static types do not validate resource existence, permissions, lengths, ranges, or conditional service requirements.
Arguments
| Argument | Required | Model notes (excerpt) |
|---|---|---|
bot_id |
Yes | The identifier of the bot that should receive the request. |
bot_alias_id |
Yes | The alias identifier in use for the bot that should receive the request. |
locale_id |
Yes | The locale where the session is in use. |
session_id |
Yes | The identifier of the session in use. |
request_content_type |
Yes | Indicates the format for audio input or that the content is text. The header must start with one of the following prefixes: PCM format, audio data must be in little-endian byte order. audio/l16; rate=16000; channels=1 audio/x-l16; sample-rate=16000; channel-count=1 audio/lpcm; sample-rate=8000; sample-size-bits=16; channel-count=1; is-big-endian=false Opus format... |
session_state |
No | Sets the state of the session with the user. You can use this to set the current intent, attributes, context, and dialog action. Use the dialog action to determine the next step that Amazon Lex V2 should use in the conversation with the user. The sessionState field must be compressed using gzip and then base64 encoded before sending to Amazon Lex V2. |
request_attributes |
No | Request-specific information passed between the client application and Amazon Lex V2 The namespace x-amz-lex: is reserved for special attributes. Don't create any request attributes for prefix x-amz-lex: . The requestAttributes field must be compressed using gzip and then base64 encoded before sending to Amazon Lex V2. |
response_content_type |
No | The message that Amazon Lex V2 returns in the response can be either text or speech based on the responseContentType value. If the value is text/plain;charset=utf-8 , Amazon Lex V2 returns text in the response. If the value begins with audio/ , Amazon Lex V2 returns speech in the response. Amazon Lex V2 uses Amazon Polly to generate the speech using the configuration that you specified in the... |
input_stream |
No | User input in PCM or Opus audio format or text format as described in the requestContentType parameter. |
Output
RecognizeUtteranceOutput.
Read-only native attributes, accessed as response.field. Collection getters materialize Python values; to_dict() recursively materializes a mapping. Streams are consumed once.
| Field | Type | Presence | References |
|---|---|---|---|
input_mode |
str | None |
Always present | — |
content_type |
str | None |
Always present | — |
messages |
str | None |
Always present | — |
interpretations |
str | None |
Always present | — |
session_state |
str | None |
Always present | — |
request_attributes |
str | None |
Always present | — |
session_id |
str | None |
Always present | — |
input_transcript |
str | None |
Always present | — |
audio_stream |
ByteStream |
Always present | ByteStream |
recognized_bot_member |
str | None |
Always present | — |
| None means a value can be absent. Output mappings include every declared key; optional input keys may be omitted. Unknown output enum/union variants are not automatically valid inputs.
Related types
Follow these links for nested inputs and outputs; recursive types link back to the same type page.
Pagination and streaming
No generated paginator for this operation.
Output streams: ByteStream.
Consume with async for. Do not reuse a consumed stream.
ByteStream.read() buffers the complete body.
Input event streams accept the declared AsyncIterator of typed events.
Request byte bodies use bytes; they do not accept file objects or iterators.
Errors
Import from rboto_lex_runtime_v2.exceptions:
AccessDeniedError, BadGatewayError, ConflictError, DependencyFailedError, InternalServerError, ResourceNotFoundError, ThrottlingError, ValidationError.
Other service failures use the service base error; credential, transport and timeout failures use shared errors.