Skip to content

Commit 78fa2ab

Browse files
committed
Update default voice ID, fix MARS naming, and clean up example
1 parent 56da2ca commit 78fa2ab

3 files changed

Lines changed: 19 additions & 26 deletions

File tree

examples/foundational/07zb-interruptible-camb-local.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
# SPDX-License-Identifier: BSD 2-Clause License
55
#
66

7-
"""Camb.ai MARS-8 TTS example with local audio (microphone/speakers).
7+
"""Camb.ai MARS TTS example with local audio (microphone/speakers).
88
99
This example demonstrates:
10-
- Basic TTS synthesis with Camb.ai MARS-8
10+
- Basic TTS synthesis with Camb.ai MARS
1111
- Local audio input/output (no WebRTC or Daily needed)
1212
- Handling interruptions
1313
@@ -83,7 +83,7 @@ async def main(voice_id: int):
8383
messages = [
8484
{
8585
"role": "system",
86-
"content": """You are a helpful voice assistant powered by Camb.ai's MARS-8
86+
"content": """You are a helpful voice assistant powered by Camb.ai's MARS
8787
text-to-speech technology. Keep your responses concise and conversational since
8888
they will be spoken aloud. Avoid special characters, emojis, or bullet points.""",
8989
},
@@ -117,14 +117,9 @@ async def main(voice_id: int):
117117
),
118118
)
119119

120-
# Run the pipeline
121-
runner = PipelineRunner()
122-
logger.info("Starting Camb.ai TTS bot with local audio...")
123-
logger.info("Speak into your microphone to interact with the bot.")
124-
125-
# Start the conversation with a greeting after a short delay
126-
async def start_greeting():
127-
await asyncio.sleep(1) # Wait for pipeline to start
120+
# Start the conversation when the pipeline is ready
121+
@task.event_handler("on_pipeline_started")
122+
async def on_pipeline_started(task, frame):
128123
messages.append(
129124
{
130125
"role": "system",
@@ -133,20 +128,20 @@ async def start_greeting():
133128
)
134129
await task.queue_frames([LLMRunFrame()])
135130

136-
# Run greeting and pipeline concurrently
137-
await asyncio.gather(
138-
runner.run(task),
139-
start_greeting(),
140-
)
131+
# Run the pipeline
132+
runner = PipelineRunner()
133+
logger.info("Starting Camb.ai TTS bot with local audio...")
134+
logger.info("Speak into your microphone to interact with the bot.")
135+
await runner.run(task)
141136

142137

143138
if __name__ == "__main__":
144139
parser = argparse.ArgumentParser(description="Camb.ai TTS example with local audio")
145140
parser.add_argument(
146141
"--voice-id",
147142
type=int,
148-
default=2681,
149-
help="Camb.ai voice ID to use (default: 2681 - Attic voice)",
143+
default=147320,
144+
help="Camb.ai voice ID to use (default: 147320)",
150145
)
151146
args = parser.parse_args()
152147
asyncio.run(main(args.voice_id))

src/pipecat/services/camb/tts.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939

4040
# Default configuration
41-
DEFAULT_VOICE_ID = 2681 # Attic voice (publicly available)
41+
DEFAULT_VOICE_ID = 147320
4242
DEFAULT_LANGUAGE = "en-us"
4343
DEFAULT_MODEL = "mars-flash" # Faster inference
4444
DEFAULT_BASE_URL = "https://client.camb.ai/apis"
@@ -135,7 +135,7 @@ class CambTTSService(TTSService):
135135
136136
tts = CambTTSService(
137137
api_key="your-api-key",
138-
voice_id=2681,
138+
voice_id=147320,
139139
model="mars-flash",
140140
aiohttp_session=session,
141141
params=CambTTSService.InputParams(
@@ -146,7 +146,7 @@ class CambTTSService(TTSService):
146146
# For mars-instruct with custom instructions:
147147
tts_instruct = CambTTSService(
148148
api_key="your-api-key",
149-
voice_id=2681,
149+
voice_id=147320,
150150
model="mars-instruct",
151151
aiohttp_session=session,
152152
params=CambTTSService.InputParams(
@@ -190,7 +190,7 @@ def __init__(
190190
Args:
191191
api_key: Camb.ai API key for authentication.
192192
aiohttp_session: Shared aiohttp session for making HTTP requests.
193-
voice_id: Voice ID to use (e.g., 2681 for Attic). Defaults to 2681.
193+
voice_id: Voice ID to use. Defaults to 147320.
194194
model: TTS model to use. Options: "mars-flash", "mars-pro", "mars-instruct".
195195
Defaults to "mars-flash" (fastest).
196196
base_url: Camb.ai API base URL. Defaults to production URL.
@@ -338,10 +338,8 @@ async def run_tts(self, text: str) -> AsyncGenerator[Frame, None]:
338338
await self.start_tts_usage_metrics(text)
339339
yield TTSStartedFrame()
340340

341-
CHUNK_SIZE = self.chunk_size
342-
343341
async for frame in self._stream_audio_frames_from_iterator(
344-
response.content.iter_chunked(CHUNK_SIZE), strip_wav_header=False
342+
response.content.iter_chunked(self.chunk_size), strip_wav_header=False
345343
):
346344
await self.stop_ttfb_metrics()
347345
yield frame

tests/test_camb_tts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ async def test_language_mapping():
363363

364364

365365
@pytest.mark.asyncio
366-
async def test_mars8_instruct_model(aiohttp_client):
366+
async def test_mars_instruct_model(aiohttp_client):
367367
"""Test that user_instructions are included for mars-instruct model."""
368368

369369
received_payload = {}

0 commit comments

Comments
 (0)