Skip to content

Commit f893e80

Browse files
author
recipes-bot
committed
feat(python): voice-agents v1 — custom-tts
1 parent e69e99d commit f893e80

3 files changed

Lines changed: 123 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Configure TTS Voice (Voice Agents v1)
2+
3+
Choose a specific aura-2 voice model for your voice agent's spoken responses.
4+
5+
## What it does
6+
7+
Configures the speak (TTS) component of the voice agent pipeline to use a specific voice model. Different aura-2 voices have distinct vocal characteristics — pitch, tone, and pacing. By changing the `speak.provider.model`, you can match the agent's voice to your brand or use case.
8+
9+
## Key parameters
10+
11+
| Parameter | Value | Description |
12+
|-----------|-------|-------------|
13+
| `speak.provider.type` | `"deepgram"` | TTS provider |
14+
| `speak.provider.model` | `"aura-2-arcas-en"` | Voice model for agent speech |
15+
16+
Available aura-2 English voices:
17+
- `aura-2-thalia-en` (default), `aura-2-arcas-en`, `aura-2-luna-en`
18+
- `aura-2-asteria-en`, `aura-2-orion-en`, and more
19+
20+
## Example output
21+
22+
```
23+
Custom TTS settings sent (aura-2-arcas-en)
24+
Event: SettingsApplied
25+
```
26+
27+
## Prerequisites
28+
29+
- Python 3.10+
30+
- Set `DEEPGRAM_API_KEY` environment variable
31+
- Install: `pip install -r recipes/python/requirements.txt`
32+
33+
## Run
34+
35+
```bash
36+
python example.py
37+
```
38+
39+
## Test
40+
41+
```bash
42+
pytest example_test.py -v
43+
```
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
"""
2+
Recipe: Configure TTS Voice (Voice Agents v1)
3+
===============================================
4+
Demonstrates selecting a specific aura-2 voice model for the agent's
5+
speech output in the speak stage of the pipeline.
6+
7+
The `speak` component controls which TTS model synthesises the agent's
8+
responses. This recipe uses aura-2-arcas-en — a different voice from
9+
the default — to demonstrate voice customisation.
10+
"""
11+
12+
from deepgram import DeepgramClient
13+
from deepgram.agent.v1.types import (
14+
AgentV1Settings, AgentV1SettingsAgent,
15+
AgentV1SettingsAgentListen, AgentV1SettingsAgentListenProvider_V1,
16+
AgentV1SettingsAudio, AgentV1SettingsAudioInput,
17+
)
18+
from deepgram.core.events import EventType
19+
from deepgram.types.speak_settings_v1 import SpeakSettingsV1
20+
from deepgram.types.speak_settings_v1provider import SpeakSettingsV1Provider_Deepgram
21+
from deepgram.types.think_settings_v1 import ThinkSettingsV1
22+
from deepgram.types.think_settings_v1provider import ThinkSettingsV1Provider_OpenAi
23+
24+
25+
def main():
26+
client = DeepgramClient() # reads DEEPGRAM_API_KEY from environment
27+
28+
with client.agent.v1.connect() as agent:
29+
settings = AgentV1Settings(
30+
audio=AgentV1SettingsAudio(
31+
input=AgentV1SettingsAudioInput(encoding="linear16", sample_rate=24000)
32+
),
33+
agent=AgentV1SettingsAgent(
34+
listen=AgentV1SettingsAgentListen(
35+
provider=AgentV1SettingsAgentListenProvider_V1(type="deepgram", model="nova-3")
36+
),
37+
think=ThinkSettingsV1(
38+
provider=ThinkSettingsV1Provider_OpenAi(type="open_ai", model="gpt-4o-mini"),
39+
prompt="You are a helpful AI assistant.",
40+
),
41+
speak=SpeakSettingsV1(
42+
provider=SpeakSettingsV1Provider_Deepgram(
43+
type="deepgram",
44+
model="aura-2-arcas-en", # <-- THIS is the feature: selecting the TTS voice
45+
)
46+
),
47+
),
48+
)
49+
50+
agent.send_settings(settings)
51+
print("Custom TTS settings sent (aura-2-arcas-en)")
52+
53+
def on_message(message):
54+
if not isinstance(message, bytes):
55+
msg_type = getattr(message, "type", type(message).__name__)
56+
print(f"Event: {msg_type}")
57+
58+
agent.on(EventType.MESSAGE, on_message)
59+
agent.on(EventType.ERROR, lambda e: print(f"Error: {e}"))
60+
agent.start_listening()
61+
62+
63+
if __name__ == "__main__":
64+
main()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import subprocess
2+
from pathlib import Path
3+
4+
def test_example_runs():
5+
"""Runs the custom-tts voice agent example and verifies it produces output."""
6+
example = Path(__file__).parent / "example.py"
7+
result = subprocess.run(
8+
["python", str(example)],
9+
capture_output=True,
10+
text=True,
11+
timeout=90,
12+
)
13+
assert result.returncode == 0, (
14+
f"Example failed\nSTDOUT: {result.stdout}\nSTDERR: {result.stderr}"
15+
)
16+
assert result.stdout.strip(), "Example produced no output"

0 commit comments

Comments
 (0)