pocket-tts
Live Pocket TTS. WebSocket only. $0.00333 / min plus the $0.05 request fee.
Native stream: PCM16 mono 24 kHz on wss://api.pascalai.co/v1/text-to-speech/realtime.. Live price and availability are on GET /v1/models/pocket-tts.
- Open wss://api.pascalai.co/v1/text-to-speech/realtime.
- Send {"type":"session.update","session":{"voice":"alba"}} before the first speak.
- The charge follows the audio, in minutes.
- voice is Pocket only. Default alba.
- A browser sends the API key as api_key on the query string.
Parameters
| Field | Type | Description |
|---|---|---|
speak.textRequired | string | The words to speak. Same field on every live TTS model. |
session.voiceDefault alba | string | Pocket TTS Realtime only. One of 26 speakers. Default alba. Omit on Piper and Matcha. |
Example
const socket = new WebSocket(
'wss://api.pascalai.co/v1/text-to-speech/realtime?model=pocket-tts&api_key=' + key
);
socket.binaryType = 'arraybuffer';
socket.onmessage = (event) => {
if (typeof event.data !== 'string') return;
const payload = JSON.parse(event.data);
if (payload.type === 'session.created') {
socket.send(JSON.stringify({ type: 'session.update', session: { voice: 'alba' } }));
socket.send(JSON.stringify({
type: 'speak',
text: 'Keep walking toward the river.',
}));
}
};
// binary Int16 PCM16 frames, then response.done