Bedrock Nova Sonic
Amazon Nova Sonic provides real-time, conversational interactions through bidirectional audio streaming. Amazon Nova Sonic processes and responds to real-time speech as it occurs, enabling natural, human-like conversational experiences. Key capabilities and features include:
- Adaptive speech response that dynamically adjusts delivery based on the prosody of the input speech.
- Graceful handling of user interruptions without dropping conversational context.
- Function calling and agentic workflow support for building complex AI applications.
- Robustness to background noise for real-world deployment scenarios.
- Multilingual support with expressive voices and speaking styles. Expressive voices are offered, including both masculine-sounding and feminine sounding, in seven languages: English (US, UK, AU, IN), French, Italian, German, Spanish (US), Portuguese (BR), and Hindi.
- Recognition of varied speaking styles across all supported languages.
Installation
Section titled “Installation”Nova Sonic is included in the base bidirectional streaming dependencies for Strands Agents.
To install it, run:
pip install 'strands-agents[bidi,bidi-io,bidi-pyaudio]'Or to install all bidirectional streaming providers at once:
pip install 'strands-agents[bidi-all,bidi-pyaudio]'After installing the Bedrock Nova Sonic and local audio extras, create a voice agent:
import asyncio
from strands.experimental.bidi.agent import BidiAgentfrom strands.experimental.bidi.io import BidiAudioIOfrom strands.experimental.bidi.models import BedrockNovaSonicModelfrom strands.experimental.tools import stopfrom strands.vended_tools import notebook
async def main() -> None: model = BedrockNovaSonicModel( model_id="amazon.nova-2-sonic-v1:0", region="us-east-1", voice="tiffany", ) agent = BidiAgent(model=model, tools=[notebook, stop]) audio_io = BidiAudioIO() await agent.run(inputs=[audio_io.input()], outputs=[audio_io.output()])
if __name__ == "__main__": asyncio.run(main())Cross-Modal Input
Section titled “Cross-Modal Input”Nova Sonic accepts text input at any point during an active voice session, without interrupting or waiting on the audio stream. Send a text content block the same way you would outside of a live conversation:
await agent.send({"text": "What's the weather in Seattle?"})Text and audio input can be interleaved freely. Sending text does not require pausing the microphone or waiting for the model to finish speaking.
Credentials
Section titled “Credentials”Nova Sonic requires AWS credentials for access. BedrockNovaSonicModel uses an experimental Bedrock client, which accepts credentials in the following ways:
Option 1: Environment Variables
export AWS_ACCESS_KEY_ID=your_access_keyexport AWS_SECRET_ACCESS_KEY=your_secret_keyexport AWS_SESSION_TOKEN=your_session_token # If using temporary credentialsexport AWS_REGION=your_region_nameOption 2: Boto3 Session
import boto3from strands.experimental.bidi.models import BedrockNovaSonicModel
boto_session = boto3.Session( aws_access_key_id="your_access_key", aws_secret_access_key="your_secret_key", aws_session_token="your_session_token", # If using temporary credentials region_name="your_region_name", profile_name="your_profile" # Optional: Use a specific profile)model = BedrockNovaSonicModel(boto_session=boto_session)For more details on this approach, please refer to the boto3 session docs.
Configuration
Section titled “Configuration”Client Options
Section titled “Client Options”| Parameter | Description | Default |
|---|---|---|
boto_session | A boto3.Session instance under which AWS credentials are configured. | None |
region | Region under which credentials are configured. Cannot use if providing boto_session. | us-east-1 |
Model Config
Section titled “Model Config”| Parameter | Description | Example | Options |
|---|---|---|---|
model_id | Nova Sonic model identifier. | "amazon.nova-2-sonic-v1:0" | Nova Sonic model IDs |
audio | Input and output stream options. | {"output": {"sample_rate": 24000}} | reference |
voice | Output voice identifier. Defaults to "matthew". | "tiffany" | Nova Sonic voices |
params | Provider-specific session parameters, such as inference and turn detection configuration. | {"inferenceConfiguration": {"temperature": 0.7}} | sessionStart fields |
connection | Reconnect timing overrides. | {"auto_reconnect": false} | reference |
Connection Restart
Section titled “Connection Restart”Nova Sonic keeps a single connection open for about 8 minutes. Before the connection reaches that limit, BidiAgent restarts it and replays the conversation history into the new connection, so the conversation continues without a break. The agent emits a BidiConnectionRestartEvent when this happens; treat it as informational rather than an error.
See Connection Restart for the full lifecycle.
Troubleshooting
Section titled “Troubleshooting”Module Not Found
Section titled “Module Not Found”If you encounter the error ModuleNotFoundError: No module named 'aws_sdk_bedrock_runtime', this means the experimental Bedrock runtime dependency hasn’t been properly installed in your environment. To fix this, run pip install 'strands-agents[bidi]'.
Hanging
Section titled “Hanging”When credentials are misconfigured, the model provider does not throw an exception (a quirk of the underlying experimental Bedrock client). As a result, the provider allows the user to proceed forward with a call to receive, which emits no events and thus presents an indefinite hanging behavior.
As a reminder, Nova Sonic is only available in us-east-1, us-west-2, eu-north-1, and ap-northeast-1.