matcha-en-ljspeech
Live Matcha LJSpeech. WebSocket only. $0.00333 / min plus the $0.05 request fee.
Native stream: PCM16 mono 22.05 kHz on wss://api.pascalai.co/v1/text-to-speech/realtime.. Live price and availability are on GET /v1/models/matcha-en-ljspeech.
- Open wss://api.pascalai.co/v1/text-to-speech/realtime.
- Send session.update before the first speak, then {"type":"speak","text":"…"}. Binary PCM16 follows.
- The charge follows the audio, in minutes.
- 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.speedDefault 1 | number | Piper and Matcha only. 0.5 to 2. Default 1. Omit on Pocket. |
Example
const socket = new WebSocket(
'wss://api.pascalai.co/v1/text-to-speech/realtime?model=matcha-en-ljspeech&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: { speed: 1 } }));
socket.send(JSON.stringify({
type: 'speak',
text: 'Keep walking toward the river.',
}));
}
};
// binary Int16 PCM16 frames, then response.done