Table of Contents

Class LanguageIdentifierOptions

Namespace
AiDotNet.Audio.LanguageIdentification
Assembly
AiDotNet.dll

Configuration options for language identification models.

public class LanguageIdentifierOptions
Inheritance
LanguageIdentifierOptions
Derived
Inherited Members

Remarks

These options configure how language identification models process audio and return predictions.

For Beginners: Language identification (LID) determines which language is being spoken in an audio recording.

Key settings:

  • SampleRate: Must match your audio (16000 Hz is common for speech)
  • MinConfidence: Minimum confidence to report a detection
  • TopK: Number of top language predictions to return

Example:

var options = new LanguageIdentifierOptions
{
    SampleRate = 16000,
    MinConfidence = 0.7,
    TopK = 3
};
var model = new ECAPATDNNLanguageIdentifier<float>(options);
var result = model.IdentifyLanguage(audio);
Console.WriteLine($"Language: {result.LanguageCode} ({result.Confidence:P0})");

Properties

EmbeddingDimension

Gets or sets the embedding dimension.

public int EmbeddingDimension { get; set; }

Property Value

int

Default is 192 (ECAPA-TDNN standard).

FftSize

Gets or sets the FFT size for spectrogram computation.

public int FftSize { get; set; }

Property Value

int

Default is 512.

HopLength

Gets or sets the hop length between frames.

public int HopLength { get; set; }

Property Value

int

Default is 160 (10ms at 16kHz).

MinConfidence

Gets or sets the minimum confidence threshold for valid detection.

public double MinConfidence { get; set; }

Property Value

double

Default is 0.5.

MinDurationSeconds

Gets or sets the minimum audio duration in seconds required for reliable detection.

public double MinDurationSeconds { get; set; }

Property Value

double

Default is 1.0 second.

ModelPath

Gets or sets the path to the ONNX model file.

public string? ModelPath { get; set; }

Property Value

string

Null for native training mode, or path to pre-trained ONNX model.

NumMels

Gets or sets the number of mel filterbank channels.

public int NumMels { get; set; }

Property Value

int

Default is 80.

OnnxOptions

Gets or sets the ONNX model options.

public OnnxModelOptions? OnnxOptions { get; set; }

Property Value

OnnxModelOptions

SampleRate

Gets or sets the sample rate of input audio in Hz.

public int SampleRate { get; set; }

Property Value

int

Default is 16000 Hz.

SegmentWindowMs

Gets or sets the window size in milliseconds for segmented language detection.

public int SegmentWindowMs { get; set; }

Property Value

int

Default is 2000ms.

TopK

Gets or sets the number of top language predictions to return.

public int TopK { get; set; }

Property Value

int

Default is 5.

UseVoiceActivityDetection

Gets or sets whether to apply voice activity detection before language identification.

public bool UseVoiceActivityDetection { get; set; }

Property Value

bool

Default is true.