CanaryFlash<T>

Models & Types · AiDotNet.SpeechRecognition.NeMo

Canary-1B-Flash: NVIDIA’s Canary (Puvvada et al. 2024) with a deeper encoder and a 4-layer decoder for fast decoding.

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

Implements: ISpeechRecognizer<T>

For Beginners

Canary-1B-Flash turns 16 kHz audio into an 80-band log-mel spectrogram, shortens it 8x with depthwise-separable convolutions, and encodes it with Conformer blocks, each mixing self-attention (long-range context) with a convolution (local patterns). A Transformer decoder writes the transcript token by token while reading the encoded audio.

How It Works

Canary-1B-Flash keeps the Canary architecture (section 3 of Puvvada et al. 2024: Fast Conformer encoder with 8x subsampling, width 1024, 4096 feed-forward units, kernel 9, 8 heads, over 128-dimensional log-mel features, and a Transformer decoder with fixed positional encoding trained with cross-entropy) and moves capacity to the encoder: 32 encoder blocks and 4 decoder layers. The decoder here reads only its start token, not the language, task and punctuation prompt. SpecAugment masks the features in training (section 3.1). Training minimizes the decoder’s cross-entropy and transcription decodes greedily. The paper’s blocks use relative positional encoding; these use rotary position encoding, the relative scheme ConformerBlockLayer provides.

Example

var architecture = new NeuralNetworkArchitecture<float>(
    inputType: InputType.OneDimensional,
    taskType: NeuralNetworkTaskType.SpeechRecognition,
    inputSize: 16000, outputSize: 34);
var model = new CanaryFlash<float>(architecture);
var text = model.Transcribe(waveform).Text;

Constructors

Constructor Summary
CanaryFlash(NeuralNetworkArchitecture<T> architecture, CanaryFlashOptions options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer)
CanaryFlash(NeuralNetworkArchitecture<T> architecture, string modelPath, CanaryFlashOptions 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()
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 and the decoder with greedy decoding.
string DetectLanguage(Tensor<T> audio)