Text-to-speech service implementation using Neuphonic’s API
Neuphonic provides high-quality text-to-speech synthesis through two service implementations:
NeuphonicTTSService
: WebSocket-based implementation with interruption supportNeuphonicHttpTTSService
: HTTP-based implementation for simpler use casesBoth services support various voices, languages, and customization options.
To use Neuphonic TTS services, install the required dependencies:
You’ll also need to set up your Neuphonic API key as an environment variable: NEUPHONIC_API_KEY
Your Neuphonic API key
Voice identifier to use for synthesis
Neuphonic WebSocket API endpoint
Output audio sample rate in Hz
Audio encoding format
Additional configuration parameters
The language for TTS generation
Speech speed multiplier (0.5-2.0)
Your Neuphonic API key
Voice identifier to use for synthesis
Neuphonic HTTP API endpoint
Output audio sample rate in Hz
Audio encoding format
Additional configuration parameters (same as WebSocket implementation)
Both services accept text input through their TTS pipeline.
Signals the start of audio generation.
Contains generated audio data:
Raw audio data chunk
Audio sample rate (22050Hz default)
Number of audio channels (1 for mono)
Signals the completion of audio generation.
Sent when an error occurs during TTS generation:
Error message describing what went wrong
The WebSocket implementation (NeuphonicTTSService
) inherits from InterruptibleTTSService
and provides:
The HTTP implementation (NeuphonicHttpTTSService
) inherits from TTSService
and provides:
Neuphonic TTS supports the following languages:
Language Code | Description | Service Codes |
---|---|---|
Language.EN | English | en |
Language.ES | Spanish | es |
Language.DE | German | de |
Language.NL | Dutch | nl |
Language.AR | Arabic | ar |
Language.FR | French | fr |
Language.PT | Portuguese | pt |
Language.RU | Russian | ru |
Language.HI | Hindi | hi |
Language.ZH | Chinese | zh |
Regional variants (e.g., EN_US
, ES_ES
) are automatically mapped to their base language.
Both services support metrics collection:
Text-to-speech service implementation using Neuphonic’s API
Neuphonic provides high-quality text-to-speech synthesis through two service implementations:
NeuphonicTTSService
: WebSocket-based implementation with interruption supportNeuphonicHttpTTSService
: HTTP-based implementation for simpler use casesBoth services support various voices, languages, and customization options.
To use Neuphonic TTS services, install the required dependencies:
You’ll also need to set up your Neuphonic API key as an environment variable: NEUPHONIC_API_KEY
Your Neuphonic API key
Voice identifier to use for synthesis
Neuphonic WebSocket API endpoint
Output audio sample rate in Hz
Audio encoding format
Additional configuration parameters
The language for TTS generation
Speech speed multiplier (0.5-2.0)
Your Neuphonic API key
Voice identifier to use for synthesis
Neuphonic HTTP API endpoint
Output audio sample rate in Hz
Audio encoding format
Additional configuration parameters (same as WebSocket implementation)
Both services accept text input through their TTS pipeline.
Signals the start of audio generation.
Contains generated audio data:
Raw audio data chunk
Audio sample rate (22050Hz default)
Number of audio channels (1 for mono)
Signals the completion of audio generation.
Sent when an error occurs during TTS generation:
Error message describing what went wrong
The WebSocket implementation (NeuphonicTTSService
) inherits from InterruptibleTTSService
and provides:
The HTTP implementation (NeuphonicHttpTTSService
) inherits from TTSService
and provides:
Neuphonic TTS supports the following languages:
Language Code | Description | Service Codes |
---|---|---|
Language.EN | English | en |
Language.ES | Spanish | es |
Language.DE | German | de |
Language.NL | Dutch | nl |
Language.AR | Arabic | ar |
Language.FR | French | fr |
Language.PT | Portuguese | pt |
Language.RU | Russian | ru |
Language.HI | Hindi | hi |
Language.ZH | Chinese | zh |
Regional variants (e.g., EN_US
, ES_ES
) are automatically mapped to their base language.
Both services support metrics collection: