Overview
Neuphonic provides high-quality text-to-speech synthesis with two service implementations:NeuphonicTTSService (WebSocket-based) with real-time streaming and interruption support, and NeuphonicHttpTTSService (HTTP-based) with server-sent events. NeuphonicTTSService is recommended for interactive applications requiring low latency.
Neuphonic TTS API Reference
Pipecat’s API methods for Neuphonic TTS integration
Example Implementation
Complete example with WebSocket streaming
Neuphonic Documentation
Official Neuphonic TTS API documentation
Voice Library
Browse available voices and features
Installation
To use Neuphonic services, install the required dependencies:Prerequisites
Neuphonic Account Setup
Before using Neuphonic TTS services, you need:- Neuphonic Account: Sign up at Neuphonic
- API Key: Generate an API key from your account dashboard
- Voice Selection: Choose from available voice models
Required Environment Variables
NEUPHONIC_API_KEY: Your Neuphonic API key for authentication
Configuration
NeuphonicTTSService
Neuphonic API key for authentication.
ID of the voice to use for synthesis.
WebSocket URL for the Neuphonic API.
Output audio sample rate in Hz.
Audio encoding format.
Buffer text until sentence boundaries before sending to Neuphonic.
Runtime-configurable voice and generation settings. See InputParams below.
NeuphonicHttpTTSService
The HTTP service uses SSE (server-sent events) for streaming audio.Neuphonic API key for authentication.
ID of the voice to use for synthesis.
An aiohttp session for HTTP requests.
Base URL for the Neuphonic HTTP API.
Output audio sample rate in Hz.
Audio encoding format.
Runtime-configurable voice and generation settings. See InputParams below.
InputParams
Both WebSocket and HTTP services share the sameInputParams structure.
| Parameter | Type | Default | Description |
|---|---|---|---|
language | Language | Language.EN | Language for synthesis. |
speed | float | 1.0 | Speech speed multiplier. |
Usage
Basic Setup (WebSocket)
With Customization (WebSocket)
HTTP Service
Notes
- WebSocket vs HTTP: The WebSocket service (
NeuphonicTTSService) supports interruption handling and keepalive connections, making it better for interactive conversations. The HTTP service (NeuphonicHttpTTSService) uses server-sent events and is simpler to integrate. - Keepalive: The WebSocket service automatically sends keepalive messages every 10 seconds to maintain the connection.
- Default sample rate: Both services default to 22050 Hz, which differs from most other TTS services.
Event Handlers
Neuphonic WebSocket TTS supports the standard service connection events:| Event | Description |
|---|---|
on_connected | Connected to Neuphonic WebSocket |
on_disconnected | Disconnected from Neuphonic WebSocket |
on_connection_error | WebSocket connection error occurred |