Language Identification

Identify the spoken language on device with SpeechBrain ECAPA VoxLingua107. The Swift runtime supports native MLX and compiled Core ML and ranks 107 language labels.

Architecture

Audio is resampled to 16 kHz and converted by an exact 60-bin SpeechBrain log-mel frontend. Temporal mean normalization feeds an ECAPA-TDNN encoder and its 107-class classifier.

CLI

speech language-id recording.wav
speech language-id recording.wav --engine coreml --top 3
speech language-id recording.wav --json

MLX is the default. Use --engine coreml for the compiled model, --top to choose the number of candidates, and --json for machine-readable output.

Swift API

import SpeechLanguageID

let identifier = try await SpeechLanguageIdentifier.fromPretrained(engine: .mlx)
let result = try identifier.identify(
    audio: samples,
    sampleRate: sampleRate,
    topK: 5
)
print(result.best?.label.code ?? "unknown")

Long recordings

Each model call analyzes up to roughly 30 seconds. Longer recordings are split into non-overlapping windows and their probabilities are combined with duration weighting.

Closed-set model

The model always ranks one of its known labels. Its confidence is not an unknown-language detector. Add VAD and a calibrated rejection policy for silence, music, code-switching, and unsupported languages.

Hugging Face

CLI: language-id