Neuphonic
Text-to-speech with Neuphonic: NeuphonicTTSService over WebSocket and NeuphonicHttpTTSService over server-sent events.
Overview
NeuphonicTTSService: keeps one WebSocket open, sends each sentence followed by<STOP>, and pushes the audio as it arrives. When the bot is interrupted while speaking, it reconnects (the service is anInterruptibleTTSService).NeuphonicHttpTTSService: one HTTP request per sentence, read as server-sent events.
Upstream page
Pipecat's documentation for the same service.
Source
packages/neuphonic/src/tts.ts.
Neuphonic docs
The Neuphonic documentation.
Installation
bun add @pipedog/neuphonicimport { NeuphonicHttpTTSService, NeuphonicTTSService } from "@pipedog/neuphonic/tts";Prerequisites
- A Neuphonic account and an API key.
- Pass the key as
apiKey. The examples read it fromNEUPHONIC_API_KEY.
NeuphonicTTSService
Connects to wss://api.neuphonic.com/speak/<language>.
Configuration
Prop
Type
Settings
Runtime-updatable settings, passed as settings: new NeuphonicTTSService.Settings({...})
(NeuphonicTTSSettings). Any setting you leave out keeps the default below. A change reconnects the WebSocket, because the settings are query parameters of the connection.
| Setting | Type | Default | Description |
|---|---|---|---|
voice | string | null | null | Voice id. |
language | Language | null | Language.EN | Language, part of the connection's path. |
speed | number | 1.0 | Speed multiplier. |
temperature | number | null | null | Randomness, 0.0 to 1.0. null leaves Neuphonic's default. |
ipaKey | string | null | null | Regional variant for <phoneme:...> tags: es-castilian or pt-br. |
Usage
import { TTSUpdateSettingsFrame } from "@pipedog/core/frames/frames";
import { Language } from "@pipedog/core/transcriptions/language";
import { NeuphonicHttpTTSService, NeuphonicTTSService } from "@pipedog/neuphonic/tts";
const tts = new NeuphonicTTSService({
apiKey: process.env.NEUPHONIC_API_KEY ?? "",
settings: new NeuphonicTTSService.Settings({
voice: "your-voice-id",
language: Language.EN,
speed: 1.0,
}),
});Change settings mid-call with a TTSUpdateSettingsFrame:
// Reconnects the WebSocket with the new settings.
const update = new TTSUpdateSettingsFrame({
delta: new NeuphonicTTSService.Settings({ speed: 1.2 }),
});Event handlers
| Event | Description |
|---|---|
on_connected | The WebSocket connected. |
on_disconnected | The WebSocket closed. |
on_connection_error | The connection failed. |
NeuphonicHttpTTSService
Posts each sentence to https://api.neuphonic.com/sse/speak/<language>.
Configuration
Prop
Type
It takes the same settings as the WebSocket service.
Usage
const httpTts = new NeuphonicHttpTTSService({
apiKey: process.env.NEUPHONIC_API_KEY ?? "",
settings: new NeuphonicHttpTTSService.Settings({ voice: "your-voice-id" }),
});Notes
- The sample rate defaults to 22050 Hz and the encoding to
pcm_linear. - The WebSocket sends a keepalive (
{"text": ""}) every 10 seconds. - An SSE event that carries
errorsis reported as an error frame, and the stream keeps going.
Runtime notes
- The WebSocket opens through the core
websocketConnect, with the key in anx-api-keyheader (throughfetchon Cloudflare Workers). The HTTP service uses the globalfetch; passfetchto use another one (upstream takes an aiohttp session). Both work on Bun, Node, Deno and Cloudflare Workers. - Upstream talks to Neuphonic's API directly rather than through the
pyneuphonicSDK, and so does this port. - The deprecated
params(InputParams),voiceIdandaggregateSentencesoptions are not ported. - Upstream has no Neuphonic tests. Ours run against local fake servers, not against Neuphonic itself.
| Runtime | Works | What it needs |
|---|---|---|
| Bun | ✅ yes | Nothing. |
| Node.js | ✅ yes | Nothing. |
| Deno | ✅ yes | Nothing. |
| Cloudflare Workers | ✅ yes | Nothing. |
Generated from pipecat.runtimes and pipecat.compat in packages/neuphonic/package.json: ✅ means the compat smoke test passes on that runtime.
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).