Create a TextAligner using the language from an initialized recognizer.
The reference text to align against.
An initialized KeenASR recognizer instance.
Get the reference tokens after normalization.
Array of normalized reference tokens.
Check if the TextAligner has been closed.
Perform stateless alignment of the recognized text against the reference.
Use this method when you have the complete recognized text and don't need to track incremental progress.
The recognized text to align.
Optionalconfig: Partial<AlignmentConfig>Optional alignment configuration.
An immutable AlignmentResult snapshot.
Perform incremental alignment for streaming partial results.
This method maintains state between calls for better performance when processing streaming ASR results. The alignment builds on previous results, making it efficient for real-time updates.
The recognized text (typically a partial result).
Optionalconfig: Partial<AlignmentConfig>Optional alignment configuration.
An immutable AlignmentResult snapshot.
Reset the incremental alignment state.
Call this when starting a new recognition session to clear any cached state from previous incremental alignments.
Release native resources.
Always call this method when done with the TextAligner to prevent memory leaks. After calling close(), the TextAligner cannot be used.
Support for using statement (Symbol.dispose).
Enables usage with the using keyword:
using aligner = new TextAligner(reference, 'en-us', core);
const result = aligner.align(recognized);
// aligner.close() is called automatically
TextAligner provides language-aware text alignment between a reference text and recognized (hypothesis) text from ASR.
Features:
Example