Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

pipecat-sprag

Sprag speech and language models for Pipecat.

This integration is maintained by Sprag.

Service Import Model
SpragSTTService pipecat_sprag.stt Rhythm (speech to text)
SpragLLMService pipecat_sprag.llm Symphony (LLM)
SpragTTSService pipecat_sprag.tts Chorus (text to speech)
SpragTurnDetector, SpragTurnAnalyzer pipecat_sprag.turns Sprag Turns (end of turn)

Installation

uv add pipecat-sprag

Each service reads your API key from the SPRAG_API_KEY environment variable, or takes it as api_key=. You can generate a key from API keys in the Sprag app.

Usage

Each service drops into a Pipecat pipeline in place of any other STT, LLM, or TTS service:

from pipecat_sprag.llm import SpragLLMService
from pipecat_sprag.stt import SpragSTTService
from pipecat_sprag.tts import SpragTTSService

stt = SpragSTTService()
llm = SpragLLMService()
tts = SpragTTSService(settings=SpragTTSService.Settings(voice="wade"))

pipeline = Pipeline(
    [transport.input(), stt, user_aggregator, llm, tts, transport.output(), assistant_aggregator]
)
  • SpragSTTService streams audio to Rhythm over Sprag's streaming transcription socket (wss://api.sprag.ai/v1/audio/transcriptions). By default your pipeline's VAD decides when a turn ends; pass turn_detection={"type": "server_vad"} to let Sprag detect turns instead, or commit_on_turn_end=True to transcribe each turn when SpragTurnDetector ends it.
  • SpragLLMService runs Symphony through Sprag's chat completions API, with function calling and token usage metrics.
  • SpragTTSService streams Chorus speech over Sprag's streaming speech socket (wss://api.sprag.ai/v1/audio/speech), one sentence at a time. It defaults to the chorus model and the wade voice; the available voices are listed in voice presets.

Each service takes settings=<Service>.Settings(...) for its model and other options, and api_key= if you don't use the SPRAG_API_KEY environment variable.

Turn detection

Sprag's turn model reads the caller's audio, plus what your agent last said, and decides when the caller has finished their turn. It streams over Sprag's turns socket (wss://api.sprag.ai/v1/turns). You can use it in either of two ways.

SpragTurnDetector: the model decides the turn. Place the detector after the transport input, and let the user aggregator follow it with Pipecat's external turn strategies. The model's turn.started starts the user's turn and interrupts the bot. Its turn.ended commits the turn's audio to Rhythm, and the turn ends once that transcript arrives. No VAD is needed:

from pipecat.processors.aggregators.llm_response_universal import LLMUserAggregatorParams
from pipecat.turns.user_start import ExternalUserTurnStartStrategy
from pipecat.turns.user_stop import ExternalUserTurnStopStrategy
from pipecat.turns.user_turn_strategies import UserTurnStrategies
from pipecat_sprag.stt import SpragSTTService
from pipecat_sprag.turns import SpragAgentTextObserver, SpragTurnDetector

turns = SpragTurnDetector()
stt = SpragSTTService(commit_on_turn_end=True)
user_params = LLMUserAggregatorParams(
    user_turn_strategies=UserTurnStrategies(
        start=[ExternalUserTurnStartStrategy()],
        stop=[ExternalUserTurnStopStrategy(timeout=0.1)],
    )
)

pipeline = Pipeline(
    [
        transport.input(),
        turns,
        stt,
        user_aggregator,
        llm,
        tts,
        transport.output(),
        assistant_aggregator,
    ]
)
worker = PipelineWorker(pipeline, observers=[SpragAgentTextObserver(turns)])

The stop strategy's timeout is how long it waits for further transcripts after one arrives; Pipecat's default is 0.5 s.

SpragTurnAnalyzer: a drop-in turn analyzer. It takes the place of LocalSmartTurnAnalyzerV3, alongside your VAD. Like other streaming analyzers, it reports the turn complete as soon as the model ends it. Create one analyzer for each pipeline:

from pipecat.turns.user_stop import TurnAnalyzerUserTurnStopStrategy
from pipecat_sprag.turns import SpragAgentTextObserver, SpragTurnAnalyzer

analyzer = SpragTurnAnalyzer()
stop = [TurnAnalyzerUserTurnStopStrategy(turn_analyzer=analyzer)]
worker = PipelineWorker(pipeline, observers=[SpragAgentTextObserver(analyzer)])

SpragAgentTextObserver gives the model the words of the agent's last reply that were played, as context. Without it, the model judges the caller's audio alone. Both classes connect in the background and reconnect if the socket drops. Audio that arrives while they are not connected is not sent. Each turn the model ends is reported as a TurnMetricsData with the model's end-of-turn probability and the time from the VAD's last speech stop. The detector reports it when the pipeline enables metrics. Both take params=SpragTurnParams(...):

  • eot_threshold: the end-of-turn probability that ends the turn. Default 0.6.
  • min_silence_ms: the silence a turn needs before the model can end it. Default 200.
  • eot_timeout_ms: the silence that ends the turn whatever the model scores. Default 3000.

Example

examples/voice_agent.py is a complete voice agent running on Rhythm, Symphony, and Chorus. It uses Pipecat's development runner:

uv sync --group examples
SPRAG_API_KEY=... uv run examples/voice_agent.py

Then open the printed URL in your browser and talk to it.

examples/demo.py runs the same pipeline behind a Sprag-branded browser client that shows the live transcript, which service is working, and each service's time to first byte:

uv sync --group examples
SPRAG_API_KEY=... uv run examples/demo.py

Then open http://localhost:7860.

Compatibility

Requires pipecat-ai>=1.8,<2. Tested with Pipecat v1.12.0.

Development

uv sync
uv run ruff check && uv run ruff format --check
uv run mypy src
uv run pytest

Live tests call api.sprag.ai and are skipped by default: SPRAG_API_KEY=... uv run pytest -m live.

License

BSD 2-Clause. See LICENSE.

Metadata

Release files for pipecat-sprag 0.2.0.dev1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pipecat-sprag 0.2.0.dev1
File Size Uploaded Provenance Actions
pipecat_sprag-0.2.0.dev1.tar.gz 16.2 kB With provenance Details for pipecat_sprag-0.2.0.dev1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pipecat-sprag 0.2.0.dev1
File Interpreter ABI Platform Actions
pipecat_sprag-0.2.0.dev1-py3-none-any.whl Python 3 none any Details for pipecat_sprag-0.2.0.dev1-py3-none-any.whl

Total release size: 38.8 kB

Release files / pipecat_sprag-0.2.0.dev1.tar.gz

Download URL pipecat_sprag-0.2.0.dev1.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6e64878d4dde40422e9a145da77ec885192c33aefe77b3953f3c3657cc45e9df
BLAKE2b-256 checksum
How to use checksums
2d4369d952e27c70b3d13105fe7c11a89f04bf2021a9e715558a6fdc767291cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Release files / pipecat_sprag-0.2.0.dev1-py3-none-any.whl

Download URL pipecat_sprag-0.2.0.dev1-py3-none-any.whl
Size 22.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9956f2d2ce9a8e98190e97b6296dfecacab178e28cef70df0fd4e5551d5c000b
BLAKE2b-256 checksum
How to use checksums
0db8f084150fa42da7af3c57e632d7ad42e9201e5e3c5071deb29234ae107839
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Security for pipecat-sprag 0.2.0.dev1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pipecat_sprag-0.2.0.dev1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page