pipedog is an unofficial community port of Pipecat, not affiliated with Daily.
pipedog
Text-to-speech

Sarvam AI

Text-to-speech for Indian languages: SarvamTTSService over WebSocket and SarvamHttpTTSService over HTTP.

Overview

  • SarvamTTSService: streams text over Sarvam's WebSocket and pushes audio as it arrives. Interruptions reconnect the socket.
  • SarvamHttpTTSService: one HTTP request per sentence.

Installation

bun add @pipedog/sarvam
import { SarvamHttpTTSService, SarvamTTSService } from "@pipedog/sarvam/tts";

Prerequisites

  • A Sarvam account and an API key from the Sarvam dashboard.
  • Pass the key as apiKey. The examples read it from SARVAM_API_KEY.

Models

ModelPitch and loudnessTemperaturePaceSample rate
bulbul:v3 (default), bulbul:v3-betaignored0.01 to 1.00.5 to 2.024000 Hz by default
bulbul:v4-flashsupportedignored0.5 to 2.024000 Hz by default

TTS_MODEL_CONFIGS holds each model's speakers and limits, and getSpeakersForModel(model) lists its speakers. Preprocessing is always on for these models. Settings a model doesn't support are dropped or clamped when the service is constructed.

SarvamTTSService

Configuration

Prop

Type

Settings

Runtime-updatable settings, passed as settings: new SarvamTTSService.Settings({...}) (SarvamTTSSettings). Any setting you leave out keeps the default below.

SettingTypeDefaultDescription
modelstring"bulbul:v3"TTS model.
voicestring"shubh"Speaker.
languageLanguage"en-IN"Language of the text.
enablePreprocessingboolean | nullfalseText preprocessing. Always on for v3 and v4-flash.
pacenumber | null1.0Speech pace, 0.5 to 2.0.
pitchnumber | nullnullPitch (bulbul:v4-flash).
loudnessnumber | nullnullVolume multiplier (bulbul:v4-flash).
temperaturenumber | nullnullRandomness, 0.01 to 1.0 (bulbul:v3; the server's default is 0.6).
minBufferSizenumber | null50Characters to buffer before generating audio.
maxChunkLengthnumber | null150Largest chunk, in characters, processed at once.

Usage

tts.ts
import { TTSUpdateSettingsFrame } from "@pipedog/core/frames/frames";
import { Language } from "@pipedog/core/transcriptions/language";
import { SarvamHttpTTSService, SarvamTTSService } from "@pipedog/sarvam/tts";

const tts = new SarvamTTSService({
  apiKey: process.env.SARVAM_API_KEY ?? "",
  settings: new SarvamTTSService.Settings({
    model: "bulbul:v3",
    voice: "shubh",
    language: Language.HI_IN,
  }),
});

Change settings mid-call with a TTSUpdateSettingsFrame:

// Queue it on the worker, or push it from a processor upstream of the service.
const update = new TTSUpdateSettingsFrame({
  delta: new SarvamTTSService.Settings({ pace: 1.2 }),
});

Notes

  • The socket carries config, text, flush and ping messages. The API key and a User-Agent go in the handshake headers.
  • sampleRate can be 8000, 16000, 22050 or 24000; null uses the model's default.

SarvamHttpTTSService

Configuration

Prop

Type

Settings

settings: new SarvamHttpTTSService.Settings({...}) (SarvamHttpTTSSettings) takes the same fields as above except minBufferSize and maxChunkLength, with the same defaults.

Usage

const http = new SarvamHttpTTSService({
  apiKey: process.env.SARVAM_API_KEY ?? "",
  settings: new SarvamHttpTTSService.Settings({ voice: "shubh", pace: 1.1 }),
});

Notes

  • fetch replaces the global fetch (upstream takes an aiohttp session).
  • baseUrl defaults to https://api.sarvam.ai. The WAV header of each reply is stripped before the audio is pushed.
  • sampleRate can also be 32000, 44100 or 48000 for bulbul:v3.
RuntimeWorksWhat it needs
Bun✅ yesNothing.
Node.js✅ yesNothing.
Deno✅ yesNothing.
Cloudflare Workers✅ yesNothing.

Generated from pipecat.runtimes and pipecat.compat in packages/sarvam/package.json: ✅ means the compat smoke test passes on that runtime.

Runtime notes

  • HTTP goes through fetch and the WebSocket through the core websocketConnect. Both work on Bun, Node, Deno and Cloudflare Workers.
  • bulbul:v2, the InputParams class and the model, voice_id, params and aggregate_sentences constructor options are deprecated upstream and not ported.
  • Tested against local servers, not against Sarvam itself.

pipedog is an unofficial community TypeScript port of Pipecat. It is not affiliated with or endorsed by Daily or the Pipecat project.

Portions adapted from the Pipecat documentation, Copyright (c) 2024–2025 Daily, BSD-2-Clause (see apps/docs/LICENSE-pipecat-docs).

On this page