Skip to content

API Reference parrot.clients.amazon.nova.audio

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.clients.amazon.nova.audio

View source

NovaAudio — bidirectional voice streaming mixin for NovaClient (FEAT-315).

Ports the bidirectional speech-to-speech implementation from the deleted FEAT-302 voice-only client module (removed in FEAT-315 — see wiki/migration/feat-315-novaclient.md) into a plain capability mixin, composed into :class:~parrot.clients.nova.client.NovaClient alongside BedrockConverseBase (spec novaclient-amazon-aws §2/§3 Module 3), mirroring how :class:~parrot.clients.google.generation.GoogleGeneration is composed into :class:~parrot.clients.google.client.GoogleGenAIClient.

.. warning:: EXPERIMENTAL. aws_sdk_bedrock_runtime[awscrt]==0.11.0 is Pre-Alpha and its API may change before GA — every raw SDK call is isolated behind four thin wrappers (:meth:NovaAudio._open_stream, :meth:NovaAudio._send_event, :meth:NovaAudio._iter_events, :meth:NovaAudio._close_stream, mirroring :class:~parrot.clients.bedrock.BedrockConverseBase's _sdk_create/_sdk_stream pattern) so only those need updating if the SDK's shape changes. The Pre-Alpha SDK is imported lazily — only at first :meth:stream_voice call, via :func:_require_voice_sdk — so text/generation-only usage of NovaClient never requires it.

The wrappers were verified against the real package on
``aws_sdk_bedrock_runtime[awscrt]==0.11.0`` / Python 3.12. The SDK renames its
client class across minor releases (``BedrockRuntimeClient`` in 0.3.0
and 0.7.0, ``AsyncBedrockRuntimeClient`` in 0.8.0), so
:func:`_resolve_voice_client_class` looks the name up tolerantly rather
than importing a fixed symbol.

.. note:: Voice auth cannot use a Bedrock API key. The text path (BedrockConverseBase) accepts a bearer token via aws_bearer_token/AWS_NOVA_API_KEY, exported as AWS_BEARER_TOKEN_BEDROCK for botocore. This Pre-Alpha SDK is smithy-based, not botocore-based, and its Config exposes only aws_access_key_id/aws_secret_access_key/aws_session_token (or a credentials resolver) — there is no bearer-auth scheme. A bearer-token-only configuration therefore cannot open a voice stream; :meth:_open_stream warns and falls through to the SDK's default credential chain.

See sdd/specs/novaclient-amazon-aws.spec.md (§3 Module 3) for the full design.

Alias LiveCompletionUsage

Re-exported from parrot.models.voice.LiveCompletionUsage.

Alias LiveToolCall

Re-exported from parrot.models.voice.LiveToolCall.

Alias LiveVoiceResponse

Re-exported from parrot.models.voice.LiveVoiceResponse.

Attribute NOVA_VOICE_CATALOG

Type: frozenset

Class NovaAudio

Bidirectional voice-streaming mixin (Nova Sonic / Nova 2 Sonic).

Plain mixin — defines NO __init__ (MRO constraint, spec §7) and reads the following attributes from the composed client (set by :class:~parrot.clients.nova.client.NovaClient / inherited from BedrockConverseBase): self.voice_id, self._region, self.model, self.default_model, self.logger, self.tool_manager, self._tool_param_names(name) (FEAT-536 TASK-2939 — tool execution goes through self.tool_manager.execute_tool(..., return_tool_result=True) via :meth:_execute_tool_full, NOT the reducing self._execute_tool(name, input) route used elsewhere/by default), self.apply_guardrail_text(text, source), plus the credentials BedrockConverseBase resolved — self._aws_access_key, self._aws_secret_key, self._aws_session_token and self._aws_bearer_token (all read defensively via getattr, since a mixin cannot assume its host ran that resolution). Deliberately does NOT read self._region_prefix for model resolution — Nova Sonic has no cross-region inference profiles (see :meth:stream_voice).

Attributes:

Attribute Type Description
INPUT_SAMPLE_RATE_HZ int
OUTPUT_SAMPLE_RATE_HZ int

Method NovaAudio.stream_voice

Stream bidirectional voice interaction via Nova Sonic.

Follows :meth:~parrot.clients.google.live.GeminiLiveClient.stream_voice's sender/receiver task pattern: a background sender task reads PCM 16kHz chunks from audio_iterator and forwards them as audioInput event frames, while this coroutine iterates the stream's output events and yields :class:LiveVoiceResponse objects (PCM 24kHz audio and/or text).

stream_voice(audio_iterator: AsyncIterator[bytes], system_prompt: Optional[str] = None, session_id: Optional[str] = None, user_id: Optional[str] = None, stt_only: bool = False, options: Optional[VoiceStreamOptions] = None, **kwargs) -> AsyncIterator[LiveVoiceResponse]

Parameter Type Default Description
audio_iterator AsyncIterator[bytes] Async iterator yielding PCM 16-bit, 16kHz mono audio chunks. A None sentinel marks end-of-turn (mirrors GeminiLiveClient's multi-turn convention).
system_prompt Optional[str] None Optional system instructions for the session.
session_id Optional[str] None Session identifier for tracking.
user_id Optional[str] None User identifier.
stt_only bool False Requests speech-to-text-only behavior (FEAT-418). Nova Sonic has NO native STT-only mode — accepted without raising, logged once (not per frame), and the model response is still generated and still billed (resolved decision, spec §8; see :attr:~parrot.models.voice.VoiceCapabilities.native_stt_only = False on this client's descriptor). This is honest, not equivalent — do NOT filter the response to fake STT-only.
options Optional[VoiceStreamOptions] None Optional VoiceStreamOptions projection (FEAT-418). temperature/max_tokens/top_p/voice/ parallel_tool_execution are derived from it when not explicitly present in **kwargs — an explicit kwarg always wins over options.
**kwargs {} voice_id (per-call synthesis voice override, e.g. "matthew", "tiffany", "amy" — falls back to the voice_id passed to the client's constructor; spec §8 resolved: expose voice_id per-call too), temperature/max_tokens/top_p/ parallel_tool_execution (take precedence over options, FEAT-418) plus reserved slots for future configuration (tool overrides, etc.).

Returns: AsyncIterator[LiveVoiceResponse]

Alias PermissionContext

Re-exported from parrot.auth.permission.PermissionContext.

Alias ToolResult

Re-exported from parrot.tools.abstract.ToolResult.

Alias VoiceStreamOptions

Re-exported from parrot.models.voice.VoiceStreamOptions.

Alias VoiceTurnMetadata

Re-exported from parrot.models.voice.VoiceTurnMetadata.

Alias translate_bedrock_model

Re-exported from parrot.clients.amazon.models.translate.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally