Table of Contents

Method TranscribeAsync

Namespace
LMKit.Speech
Assembly
LM-Kit.NET.dll

TranscribeAsync(WaveFile, string, CancellationToken)

Asynchronously transcribes the provided audio content into text segments.

public Task<SpeechToText.TranscriptionResult> TranscribeAsync(WaveFile audioFile, string language = "auto", CancellationToken cancellationToken = default)

Parameters

audioFile WaveFile

The WAV-format audio content to transcribe.

language string

The language code to transcribe in (e.g., "en"), or "auto" to auto-detect.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<SpeechToText.TranscriptionResult>

A task producing a SpeechToText.TranscriptionResult containing transcription segments.

Examples

var model = LM.LoadFromModelID("whisper-large-turbo3");
var engine = new SpeechToText(model);
var audioFile = new WaveFile("audio.wav");
var result = await engine.TranscribeAsync(audioFile);
foreach (var segment in result.Segments)
    Console.WriteLine(segment.Text);

Exceptions

ArgumentNullException

Thrown if audioFile is null.

NotSupportedException

Thrown if the model does not support speech-to-text.