Skip to main content

pipecat-mirai

Mirai text-to-speech for Pipecat voice agents: natural Hindi, Hinglish and Gujarati voices, streamed with about 100 ms to first audio.

  • MiraiTTSService: a Pipecat TTS service for Mirai's streaming API. Audio is resampled to your pipeline's rate (8 kHz for phone calls), with no voice registration or sample-rate workarounds.
  • apply_output_lead(): stops audio breaking up on phone calls when your server is busy (see Phone calls). This works with any TTS service.

Installation

uv add pipecat-mirai     # or: pip install pipecat-mirai

Prerequisites

  • A Mirai API key (sk_live_…) from the Mirai console. Set it as MIRAI_API_KEY, or pass api_key=.
  • Pipecat 1.8.1 or newer and Python 3.11+.

Usage

from pipecat_mirai import MiraiTTSService

tts = MiraiTTSService(settings=MiraiTTSService.Settings(voice="shruti"))

pipeline = Pipeline([transport.input(), stt, user_aggregator, llm, tts, transport.output(), assistant_aggregator])
Voice
ashu male
neha female (default)
shruti female
sameer male

Write Hindi in Devanagari and English words in Latin script, as people actually type Hinglish: आपका order कल deliver होगा।

Change the voice mid-call with Pipecat's standard settings frame:

await task.queue_frame(TTSUpdateSettingsFrame(delta=MiraiTTSService.Settings(voice="sameer")))

Parameters

Argument Default
api_key $MIRAI_API_KEY Your Mirai API key
settings voice="neha", model="mira-tts" MiraiTTSService.Settings(...)
voice, model Shortcuts for the same settings
sample_rate pipeline audio_out_sample_rate Output rate; Mirai's 48 kHz audio is resampled to it
base_url https://sandbox.voice.miraiminds.co/v1 API base URL
http_client own client An httpx.AsyncClient you manage

The service reports time-to-first-byte and character usage metrics and supports Pipecat tracing. Interrupting the bot closes the HTTP stream at once.

Phone calls

Pipecat's websocket transports (FastAPIWebsocketTransport with Twilio, Plivo, Exotel or Telnyx serializers, WebsocketServerTransport, WebsocketClientTransport) send audio at exactly real time. The phone provider then never holds more than about 40 ms of audio. If your server's event loop stalls for longer (a blocking call, a heavy parse, many calls on one CPU), the provider runs out and the caller hears the voice break up. This happens with every TTS vendor, and it gets worse as you add concurrent calls.

apply_output_lead() lets the transport send up to 0.4 s ahead, so short stalls go unnoticed:

from pipecat_mirai import MiraiTTSService, apply_output_lead

transport = FastAPIWebsocketTransport(websocket, FastAPIWebsocketParams(
    audio_out_enabled=True, add_wav_header=False, serializer=serializer, ...))
apply_output_lead(transport)              # default 0.4 s; apply_output_lead(transport, 0.6) for more

We measured this on 8 kHz Twilio-protocol calls, with Pipecat 1.8.1, real Mirai audio and 50–250 ms event-loop stalls every ~3 s per call (benchmarks/phone-breaks):

Concurrent calls Stock Pipecat: speech stretched by breaks With apply_output_lead
3 6.6% (3.5 breaks per sentence) 0.08%
10 29.1% (14.5 breaks per sentence) 0.01%

When the caller interrupts, Pipecat still tells the provider to clear its queue, so at most the lead (0.4 s) of already-sent audio is discarded. One side effect: Pipecat's "bot stopped speaking" event fires up to the lead earlier than the caller actually stops hearing the bot.

Examples

Compatibility

Tested with Pipecat 1.8.1 and 1.12.0 on Python 3.11–3.12. apply_output_lead changes how Pipecat's websocket output transports time their writes. A test in this repo fails if a new Pipecat release changes that, and the function logs a warning and does nothing for transports it doesn't support.

License

BSD-2-Clause. Maintained by Mirai (Sona Labs Pvt Ltd). This is a community integration, not maintained by the Pipecat team.

Metadata

Release files for pipecat-mirai 0.1.0

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-mirai 0.1.0
File Size Uploaded
pipecat_mirai-0.1.0.tar.gz 19.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pipecat-mirai 0.1.0
File Interpreter ABI Platform
pipecat_mirai-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.7 kB

Release files / pipecat_mirai-0.1.0.tar.gz

Download URL pipecat_mirai-0.1.0.tar.gz
Size 19.7 kB
Tags Source
SHA-256 checksum
How to use checksums
355298a3430bf7ff1b906034a90833c4f6edd987c503c2cf944af487c6776071
BLAKE2b-256 checksum
How to use checksums
f91dc52bd1d7932636e0534c11f4fc336eea15773fbbe0a4d81163a9f8066f06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 2, 2026.

Transparency log

Release files / pipecat_mirai-0.1.0-py3-none-any.whl

Download URL pipecat_mirai-0.1.0-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db968298688a42112d820dc2ec2c74352966dc4502309a1f1abb2d9320aad8a4
BLAKE2b-256 checksum
How to use checksums
2900951881e3d9df10dcd612f2852dd6eca0666c9d5a8dc7b93beda805d80d88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 2, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

This release

0.1.0 This release

2 release files

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