Speech to text realtime

pascal-transcribe-live

Live speech-to-text. WebSocket only. $0.22 per audio hour, or $0.25 per audio hour with speaker diarization, plus the $0.05 request fee.

Native stream: PCM16 mono on wss://api.pascalai.co/v1/speech-to-text/realtime. Default 16000 Hz.. Live price and availability are on GET /v1/models/pascal-transcribe-live.

  • Open wss://api.pascalai.co/v1/speech-to-text/realtime?model=pascal-transcribe-live.
  • Wait for session.created. Send one session.update, then binary PCM16 mono at session.sample_rate. Omit sample_rate and the rate is 16000. If the bytes are a different rate, the transcript can come out degraded. session.update is accepted only before the first audio frame.
  • session.close ends the audio and closes the socket. That is the stop.
  • session.commit also finishes the audio and leaves the socket open until session.close. session.clear and session.cancel are accepted and do not change the stream.
  • Each finished turn arrives as transcript.completed. This model does not send transcript.delta.
  • When speaker_diarization is true, transcript.completed includes speaker. When timestamp_granularity is segment, it includes start and end, in seconds.
  • The event does not include language, duration, or an utterance id.
  • The field name is speaker_diarization. diarize is rejected. emotion, accent, deepfake, and PII fields are rejected.
  • A session pays $0.05, then connected time at $0.22 per hour, or $0.25 per hour when speaker diarization is on. A session runs for up to 5 hours.
  • Hosted model. The studio signup credit can spend it.
  • A browser sends the API key as api_key on the query string.

Parameters

FieldTypeDescription
session.sample_rate
Default 16000
integer8000, 11025, 16000, 22050, 32000, 44100, or 48000. Omit it and the rate is 16000 Hz. The bytes have to already be that rate. A live frame has no header, so a mismatch is still accepted and the transcript can come out degraded.
session.language
Default auto
stringauto detects the language. An ISO 639-1 code selects it. ['af', 'am', 'ar', 'as', 'az', 'ba', 'be', 'bg', 'bn', 'bo', 'br', 'bs', 'ca', 'cs', 'cy', 'da', 'de', 'el', 'en', 'es', 'et', 'eu', 'fa', 'fi', 'fo', 'fr', 'gl', 'gu', 'ha', 'haw', 'he', 'hi', 'hr', 'ht', 'hu', 'hy', 'id', 'is', 'it', 'ja', 'jw', 'ka', 'kk', 'km', 'kn', 'ko', 'la', 'lb', 'ln', 'lo', 'lt', 'lv', 'mg', 'mi', 'mk', 'ml', 'mn', 'mr', 'ms', 'mt', 'my', 'ne', 'nl', 'nn', 'no', 'oc', 'pa', 'pl', 'ps', 'pt', 'ro', 'ru', 'sa', 'sd', 'si', 'sk', 'sl', 'sn', 'so', 'sq', 'sr', 'su', 'sv', 'sw', 'ta', 'te', 'tg', 'th', 'tk', 'tl', 'tr', 'tt', 'uk', 'ur', 'uz', 'vi', 'yi', 'yo', 'yue', 'zh']
session.speaker_diarization
Default false
booleanLabel each turn with a speaker number. When true, connected time is billed at $0.25 per hour.
session.custom_termsstring or arrayNames and jargon to bias the transcript. A comma-separated string or a list of strings. At most 1000 terms and 8000 characters.
session.timestamp_granularity
Default none
stringnone returns transcript only. segment also sends start and end, in seconds, on each transcript.completed.

Example

const socket = new WebSocket(
  'wss://api.pascalai.co/v1/speech-to-text/realtime?model=pascal-transcribe-live&api_key=' + key
);
socket.binaryType = 'arraybuffer';
socket.onopen = () => {
  socket.send(JSON.stringify({
    type: 'session.update',
    session: {
      language: 'auto',
      speaker_diarization: false,
      timestamp_granularity: 'none',
    },
  }));
};
// binary Int16 PCM16 mono frames at session.sample_rate (default 16000)
socket.send(JSON.stringify({ type: 'session.close' }));