USM<T>

Models & Types · AiDotNet.SpeechRecognition.Multilingual

Google USM’s CTC recognizer (USM-CTC): a 2B-parameter Conformer pre-trained with BEST-RQ, with a projection and a CTC layer.

Inheritance: NeuralNetworkBase<T> → AudioNeuralNetworkBase<T> → USM<T>

Implements: ISpeechRecognizer<T>

For Beginners

USM listens to 16 kHz audio turned into a 128-band spectrogram, encodes it with a large Conformer, and outputs for every 40 ms frame a probability for each token; collapsing repeats and blanks gives the transcript. The encoder learns first from unlabeled speech by predicting the random codes of hidden audio.

How It Works

References:

  • Paper: “Google USM: Scaling Automatic Speech Recognition Beyond 100 Languages” (Zhang et al., Google, 2023)

The encoder is the paper’s Conformer-2B (Table 2: 32 layers, 1536 wide, 16 heads, kernel 5) over 128-dimensional log-mel features (section 2.7) with BEST-RQ’s 4x convolutional reduction. Pre-training (Pretrain) is BEST-RQ with the paper’s 16-codebook multi-softmax loss (sections 2.2.1 and 2.7), and attention runs within 8-second chunks (section 2.4). The paper’s Conformer uses relative attention; this one uses rotary position encoding, the relative scheme ConformerBlockLayer provides. The MOST speech-text stage and noisy student training are data procedures outside the network.

Example

// Create a USM-CTC recognizer
var architecture = new NeuralNetworkArchitecture<double>(
    inputType: InputType.OneDimensional,
    taskType: NeuralNetworkTaskType.SpeechRecognition,
    inputHeight: 16000, inputWidth: 1, inputDepth: 1, outputSize: 32000);
var model = new USM<double>(architecture);
            
// Or load an exported ONNX model
var onnxModel = new USM<double>(architecture, "usm.onnx");

Constructors

Constructor Summary
USM(NeuralNetworkArchitecture<T> architecture, USMOptions options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer)
USM(NeuralNetworkArchitecture<T> architecture, string modelPath, USMOptions options)

Properties

Property Summary
IReadOnlyList<string> SupportedLanguages { get; }
bool SupportsStreaming { get; }
bool SupportsWordTimestamps { get; }

Methods

Method Summary
IReadOnlyDictionary<string, T> DetectLanguageProbabilities(Tensor<T> audio)
IStreamingTranscriptionSession<T> StartStreamingSession(string language)
ModelMetadata<T> GetModelMetadata()
T Pretrain(Tensor<T> audio) One BEST-RQ pre-training step (section 2.2) on waveforms [S] or [batch, S].
T PretrainingLoss(Tensor<T> audio, Random random) The BEST-RQ pre-training loss of waveforms [S] or [batch, S] with the multi-softmax of Zhang et al.
Task<TranscriptionResult<T>> TranscribeAsync(Tensor<T> audio, string language, bool? includeTimestamps, CancellationToken cancellationToken)
Tensor<T> ForwardForTraining(Tensor<T> input)
TranscriptionResult<T> Transcribe(Tensor<T> audio, string language, bool? includeTimestamps) Transcribes audio: the encoder, projection and CTC layer give per-frame distributions, decoded greedily.
string DetectLanguage(Tensor<T> audio)