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

ParameterTypeRequiredDescription
publicKeystringYesYour public API key
spokenLanguagestringYesTwo-letter language code of the spoken audio (e.g., 'en', 'es', 'fr')
targetLanguagesstringYesComma-separated list of target language codes (e.g., 'es,fr,de')
providerstringNo(Coming Soon...) Authentication provider ('google' or 'facebook') if using social auth
tokenstringNo(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?"
  }
}
FieldTypeDescription
typestringAlways "subtitles" for subtitle messages
spokenLanguagestringTranscription in the original spoken language
targetLanguagesobjectObject 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