Cartesia plugin for GetStream
Project description
Cartesia Text-to-Speech Plugin
High-quality Text-to-Speech (TTS) plugin for GetStream backed by the Cartesia Sonic model. It lets a Python process speak PCM audio into a Stream call.
Installation
Install from PyPI (installs both getstream and the Cartesia SDK):
pip install "getstream-plugins-cartesia[webrtc]"
If you already have the Stream SDK in your project just add the Cartesia plugin:
pip install cartesia getstream-plugins-cartesia
Usage
from getstream.plugins.cartesia import CartesiaTTS
from getstream.video.rtc.audio_track import AudioStreamTrack
async def speak():
# Option A: read key from env var (CARTESIA_API_KEY)
tts = CartesiaTTS()
# Option B: pass explicitly
# tts = CartesiaTTS(api_key="<your key>")
# Audio MUST be 16-kHz, 16-bit PCM (matches Cartesia Sonic model)
track = AudioStreamTrack(framerate=16000)
tts.set_output_track(track)
# Listen for every raw PCM chunk that gets produced
@tts.on("audio")
def _on_audio(chunk: bytes, user):
print("🔊 got", len(chunk), "bytes of audio")
await tts.send("Hello from Cartesia!")
# Run inside an event-loop, e.g. `asyncio.run(speak())`
Configuration Options
api_key(str, optional) – Cartesia API key (falls back toCARTESIA_API_KEY).model_id(str) – Which model to hit ("sonic-2"by default).voice_id(str | None) – Cartesia voice to use (passNonefor model default).sample_rate(int) – Target sample-rate in Hz. Must match theAudioStreamTrack.framerateyou attach (defaults to16000). If they don't match aTypeErroris raised early so you don't get distorted audio on the call.
Events emitted:
• audio – each raw PCM chunk, arguments: chunk: bytes, user: dict | None
• error – any exception raised during synthesis
Requirements
- Python 3.10+
cartesia>=2.0.5(automatically installed)
Testing
Run the offline unit-tests:
pytest -q getstream/plugins/cartesia/tests
To additionally exercise the live Cartesia API set CARTESIA_API_KEY in your
environment; the integration test will be executed automatically.
💡 See examples/tts_cartesia/ for a fully-working bot that joins a Stream call
and greets participants using this plugin.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file getstream_plugins_cartesia-0.1.0-py3-none-any.whl.
File metadata
- Download URL: getstream_plugins_cartesia-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2475bb3d3b00459900deffb2656e4cfef08ee152c9e39e283d5a36b6b0459bc6
|
|
| MD5 |
3bd07db9f555c4fdc68a63300d04559a
|
|
| BLAKE2b-256 |
01726b8a9776a3c489bcc2f50dd0abcc4f6d68220c0bb6a4a3c31c7dc4e12bbf
|