WebSocketwss://api.speakprecisely.com/subtitles
Real-time Subtitles
Establishes a WebSocket connection for real-time audio transcription and translation. Once connected, the server will stream transcriptions and translations as they become available.
URL Parameters
Parameter | Type | Required | Description |
---|---|---|---|
publicKey | string | Yes | Your public API key |
spokenLanguage | string | Yes | Two-letter language code of the spoken audio (e.g., 'en', 'es', 'fr') |
targetLanguages | string | Yes | Comma-separated list of target language codes (e.g., 'es,fr,de') |
provider | string | No | (Coming Soon...) Authentication provider ('google' or 'facebook') if using social auth |
token | string | No | (Coming Soon...) Social provider access token if using authentication |
Example Request
// Connect to SpeakPrecisely subtitles endpoint
const ws = new WebSocket(
'wss://api.speakprecisely.com/subtitles?' +
'publicKey=your_public_key&' +
'spokenLanguage=en&' +
'targetLanguages=es,fr,de'
);
Response Format
The server sends messages in JSON format with the following structure:
{
"type": "Results",
"spokenLanguage": "Hello, how are you today?",
"targetLanguages": {
"es": "Hola, ¿cómo estás hoy?",
"fr": "Bonjour, comment allez-vous aujourd'hui?",
"de": "Hallo, wie geht es dir heute?"
}
}
Field | Type | Description |
---|---|---|
type | string | Always "subtitles" for subtitle messages |
spokenLanguage | string | Transcription in the original spoken language |
targetLanguages | object | Object with language codes as keys and translated text as values |
Important Notes
- • Always URL encode the token parameter to handle special characters
- • Language codes follow the ISO 639-1 two-letter format
- • The WebSocket connection will remain open until explicitly closed by the client
- • Each message contains a complete transcription/translation set