RealtimeTranscriber connects to the Streaming Speech-to-Text API and lets you transcribe audio in real-time.

Hierarchy (view full)

Constructors

Methods

  • Close the connection to the server.

    Parameters

    • waitForSessionTermination: boolean = true

      If true, the method will wait for the session to be terminated before closing the connection. While waiting for the session to be terminated, you will receive the final transcript and session information.

    Returns Promise<void>

  • Configure the threshold for how long to wait before ending an utterance. Default is 700ms.

    Parameters

    • threshold: number

      The duration of the end utterance silence threshold in milliseconds. This value must be an integer between 0 and 20_000.

    Returns void

  • Listen for the open event which is emitted when the connection is established and the session begins.

    Parameters

    Returns void

  • Listen for the transcript event which is emitted when a partian or final transcript is received.

    Parameters

    • event: "transcript"

      The transcript event.

    • listener: ((transcript: RealtimeTranscript) => void)

      The function to call when the event is emitted.

    Returns void

  • Listen for the partial transcript event which is emitted when a partial transcript is received.

    Parameters

    • event: "transcript.partial"

      The partial transcript event.

    • listener: ((transcript: PartialTranscript) => void)

      The function to call when the event is emitted.

    Returns void

  • Listen for the final transcript event which is emitted when a final transcript is received.

    Parameters

    • event: "transcript.final"

      The final transcript event.

    • listener: ((transcript: FinalTranscript) => void)

      The function to call when the event is emitted.

    Returns void

  • Listen for the session information event which is emitted when session information is received. The session information is sent right before the session is terminated.

    Parameters

    • event: "session_information"

      The session information event.

    • listener: ((info: SessionInformation) => void)

      The function to call when the event is emitted.

    Returns void

  • Listen for the error event which is emitted when an error occurs.

    Parameters

    • event: "error"

      The error event.

    • listener: ((error: Error) => void)

      The function to call when the event is emitted.

        • (error): void
        • Parameters

          • error: Error

          Returns void

    Returns void

  • Listen for the close event which is emitted when the connection is closed.

    Parameters

    • event: "close"

      The close event.

    • listener: ((code: number, reason: string) => void)

      The function to call when the event is emitted.

        • (code, reason): void
        • Parameters

          • code: number
          • reason: string

          Returns void

    Returns void

  • Send audio data to the server.

    Parameters

    • audio: ArrayBufferLike

      The audio data to send to the server.

    Returns void

  • Create a writable stream that can be used to send audio data to the server.

    Returns WritableStream<ArrayBufferLike>

    A writable stream that can be used to send audio data to the server.