Table of Contents

Class RealtimeTranscriber

Namespace
AssemblyAI.Realtime
Assembly
AssemblyAI.dll

Transcribes audio in real-time using AssemblyAI's real-time transcription service.

public sealed class RealtimeTranscriber : IAsyncDisposable, IDisposable, INotifyPropertyChanged
Inheritance
RealtimeTranscriber
Implements
Inherited Members

Constructors

RealtimeTranscriber()

Create a new instance of the real-time transcriber.

public RealtimeTranscriber()

RealtimeTranscriber(RealtimeTranscriberOptions)

Create a new instance of the real-time transcriber.

public RealtimeTranscriber(RealtimeTranscriberOptions options)

Parameters

options RealtimeTranscriberOptions

The options for the real-time transcription service.

Fields

Closed

The event raised when the connection with the real-time service is closed.

public readonly Event<ClosedEventArgs> Closed

Field Value

Event<ClosedEventArgs>

ErrorReceived

The event raised when an error message is received.

public readonly Event<RealtimeError> ErrorReceived

Field Value

Event<RealtimeError>

ExceptionOccurred

The event raised when an exception occurs while listening for WebSocket messages.

public readonly Event<Exception> ExceptionOccurred

Field Value

Event<Exception>

FinalTranscriptReceived

The event raised when a final transcript is received.

public readonly Event<FinalTranscript> FinalTranscriptReceived

Field Value

Event<FinalTranscript>

PartialTranscriptReceived

The event raised when a partial transcript is received.

public readonly Event<PartialTranscript> PartialTranscriptReceived

Field Value

Event<PartialTranscript>

SessionBegins

The event raised when the real-time transcription session begins.

public readonly Event<SessionBegins> SessionBegins

Field Value

Event<SessionBegins>

SessionInformationReceived

The event raised when session information is received, right before the session is terminated.

public readonly Event<SessionInformation> SessionInformationReceived

Field Value

Event<SessionInformation>

TranscriptReceived

The event raised when a partial or final transcript is received.

public readonly Event<RealtimeTranscript> TranscriptReceived

Field Value

Event<RealtimeTranscript>

Properties

ApiKey

Use your AssemblyAI API key to authenticate with the AssemblyAI real-time transcriber.

public string? ApiKey { set; }

Property Value

string

DisablePartialTranscripts

Disable partial transcripts. Set to true to not receive partial transcripts. Defaults to false.

public bool DisablePartialTranscripts { get; set; }

Property Value

bool

Encoding

The encoding of the audio data

public AudioEncoding? Encoding { get; set; }

Property Value

AudioEncoding?

RealtimeUrl

The Streaming STT endpoint to connect to.

public string RealtimeUrl { get; set; }

Property Value

string

SampleRate

The sample rate of the streamed audio. Defaults to 16000.

public uint SampleRate { get; set; }

Property Value

uint

Status

The status of the real-time transcriber.

public RealtimeTranscriberStatus Status { get; }

Property Value

RealtimeTranscriberStatus

Token

Use a temporary auth token to authenticate with the AssemblyAI real-time transcriber. Learn how to generate a temporary token here.

public string? Token { set; }

Property Value

string

WordBoost

Add up to 2500 characters of custom vocabulary

public IEnumerable<string> WordBoost { get; set; }

Property Value

IEnumerable<string>

Methods

CloseAsync()

Terminate the real-time transcription session and close the connection.

public Task CloseAsync()

Returns

Task

CloseAsync(bool)

Terminate the real-time transcription session and close the connection.

public Task CloseAsync(bool waitForSessionTerminated)

Parameters

waitForSessionTerminated bool

Wait to receive pending transcripts and session terminated message.

Returns

Task

ConfigureEndUtteranceThresholdAsync(uint)

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

public Task ConfigureEndUtteranceThresholdAsync(uint threshold)

Parameters

threshold uint

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

Returns

Task

ConnectAsync()

Connect to AssemblyAI's real-time transcription service, and start listening for messages.

public Task<SessionBegins> ConnectAsync()

Returns

Task<SessionBegins>

The session begins message

Dispose()

Terminates the real-time transcription session, closes the connection, and disposes the real-time transcriber.

public void Dispose()

Remarks

Any remaining partial or final transcripts will not be received. To receive remaining partial or final transcripts, call CloseAsync() before disposing.

DisposeAsync()

Terminates the real-time transcription session, closes the connection, and disposes the real-time transcriber.

public ValueTask DisposeAsync()

Returns

ValueTask

Remarks

Any remaining partial or final transcripts will not be received. To receive remaining partial or final transcripts, call CloseAsync() before disposing.

ForceEndUtteranceAsync()

Manually end an utterance

public Task ForceEndUtteranceAsync()

Returns

Task

SendAudioAsync(ArraySegment<byte>)

Send audio to the real-time service.

public Task SendAudioAsync(ArraySegment<byte> audio)

Parameters

audio ArraySegment<byte>

Audio to transcribe

Returns

Task

SendAudioAsync(byte[])

Send audio to the real-time service.

public Task SendAudioAsync(byte[] audio)

Parameters

audio byte[]

Audio to transcribe

Returns

Task

SendAudioAsync(Memory<byte>)

Send audio to the real-time service.

public Task SendAudioAsync(Memory<byte> audio)

Parameters

audio Memory<byte>

Audio to transcribe

Returns

Task

Events

PropertyChanged

PropertyChanged event is called when a property is changed.

public event PropertyChangedEventHandler? PropertyChanged

Event Type

PropertyChangedEventHandler