0
Fork 0
mirror of https://github.com/mastra-ai/mastra.git synced 2026-11-17 08:44:46 +00:00
mastra/voice/aws-nova-sonic
History 2026-10-28 13:15:52 +00:00
..
src refactor(lint): remove redundant returns while preserving exits (#28448) 2026-10-26 21:03:00 +01:00
CHANGELOG.md chore: version - exit prerelease mode 2026-10-28 13:15:52 +00:00
lint-staged.config.js refactor(lint): replace ESLint with type-aware oxlint (#27476) 2026-10-18 10:38:35 -07:00
package.json chore: version - exit prerelease mode 2026-10-28 13:15:52 +00:00
README.md chore(*): Update/unify/add READMEs (#22858) 2026-09-02 14:36:59 +02:00
tsconfig.build.json feat(sonic): add support for nova sonic (#13232) 2026-04-30 20:24:21 -07:00
tsconfig.json chore: migrate package builds to tsdown (#19829) 2026-07-28 12:32:21 +02:00
tsdown.config.ts chore: migrate package builds to tsdown (#19829) 2026-07-28 12:32:21 +02:00
vitest.config.ts feat(sonic): add support for nova sonic (#13232) 2026-04-30 20:24:21 -07:00
vitest.e2e.config.ts feat(sonic): add support for nova sonic (#13232) 2026-04-30 20:24:21 -07:00

@mastra/voice-aws-nova-sonic

Mastra integration for AWS Nova 2 Sonic, providing real-time bidirectional speech-to-speech capabilities using Amazon Bedrock's bidirectional streaming API.

Installation

npm install @mastra/voice-aws-nova-sonic

Usage

Basic Example

import { Agent } from '@mastra/core/agent';
import { NovaSonicVoice } from '@mastra/voice-aws-nova-sonic';

const agent = new Agent({
  name: 'Nova Sonic Agent',
  instructions: 'You are a helpful assistant with real-time voice capabilities.',
  model: 'openai/gpt-4o',
  voice: new NovaSonicVoice({
    region: 'us-east-1',
    speaker: 'tiffany',
  }),
});

// Connect to the voice service
await agent.voice.connect();

// Listen for agent audio responses (stream of audio data)
agent.voice.on('speaker', audioStream => {
  // Pipe to your audio output (e.g., speaker, WebSocket, file)
  audioStream.pipe(yourAudioOutput);
});

// Listen for text transcriptions
agent.voice.on('writing', ({ text, role, generationStage }) => {
  // generationStage is 'SPECULATIVE' (preview) or 'FINAL' (actual transcript)
  console.log(`[${role}] ${text}`);
});

// Send continuous audio from the microphone (NodeJS.ReadableStream of PCM16 audio)
await agent.voice.send(microphoneStream);

Documentation

Changelog

See the package changelog for version history and release notes.

Support

We have an open community Discord. Come and say hello and let us know if you have any questions or need any help getting things running.