TDTDecoder<T>
Models & Types · AiDotNet.SpeechRecognition.Streaming
Token-and-Duration Transducer (Xu et al. 2023): a Conformer transducer whose joint network also predicts frame durations.
Inheritance: NeuralNetworkBase<T> → AudioNeuralNetworkBase<T> → TDTDecoder<T>
Implements: ISpeechRecognizer<T>
For Beginners
TDT turns 16 kHz audio into an 80-band log-mel spectrogram, shortens it 4x with two convolutions, and encodes it with Conformer blocks, each mixing self-attention (long-range context) with a convolution (local patterns). A small LSTM remembers the words written so far and a joint network combines it with each audio frame to pick the next token or “nothing yet”.
How It Works
The paper trains Conformer TDT models in NeMo; the encoder here is a Conformer-Large (17 blocks, width 512, 8 heads, 31-wide depthwise kernel) and the decoder a 640-unit LSTM prediction network with a 640-wide joint network that predicts the token and, independently, how many frames the emission advances among 0 to 4 (the paper’s best configuration, section 5). Training uses the TDT loss (Equations 3 to 5) and greedy decoding skips the predicted frames (Algorithm 1). SpecAugment masks the features in training (section 3.1). The decoder trains with the token-and-duration transducer loss and 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 TDTDecoder<float>(architecture);
var text = model.Transcribe(waveform).Text;
Constructors
| Constructor | Summary |
|---|---|
TDTDecoder(NeuralNetworkArchitecture<T> architecture, TDTDecoderOptions options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer) |
|
TDTDecoder(NeuralNetworkArchitecture<T> architecture, string modelPath, TDTDecoderOptions 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 transducer with greedy decoding. |
string DetectLanguage(Tensor<T> audio) |