KeenASR Unity Plugin v2.2
Unity plugin for KeenASR offline speech recognition SDK (iOS & Android)
Loading...
Searching...
No Matches
KeenResearch.TextAligner Class Reference

Aligns recognized speech text against a reference text using dynamic programming edit distance. Useful for oral-reading scoring and word-error-rate (WER) computation. More...

Inherits IDisposable.

Public Member Functions

 TextAligner (string reference, string langCode)
 Creates a text aligner with the given reference text and language code.
 
 TextAligner (string reference)
 Creates a text aligner using the language from the currently initialized recognizer.
 
AlignmentResult AlignText (string recognized)
 Aligns recognized text against the reference using default configuration. This method is thread-safe and can be called concurrently.
 
AlignmentResult AlignText (string recognized, AlignmentConfig config)
 Aligns recognized text against the reference with custom configuration. This method is thread-safe and can be called concurrently.
 
AlignmentResult IncrementalAlignText (string recognized)
 Incrementally aligns recognized text, reusing state from prior calls. Useful for aligning partial recognition results during streaming. NOT thread-safe - do not call concurrently on the same aligner.
 
AlignmentResult IncrementalAlignText (string recognized, AlignmentConfig config)
 Incrementally aligns recognized text with custom configuration. NOT thread-safe - do not call concurrently on the same aligner.
 
void Reset ()
 Resets incremental alignment state. Call between utterances when using IncrementalAlignText for multiple separate recognition sessions.
 
void Dispose ()
 Releases the native aligner resources. Safe to call multiple times.
 

Properties

string langCode [get]
 Language code of the ASR bundle used for normalization.
 
string[] referenceTokens [get]
 Normalized reference tokens.
 

Detailed Description

Aligns recognized speech text against a reference text using dynamic programming edit distance. Useful for oral-reading scoring and word-error-rate (WER) computation.

Supports both stateless alignment (thread-safe) and incremental alignment for streaming partial results (not thread-safe per instance).

using (var aligner = new TextAligner("THE CAT SAT ON THE MAT")) {
var result = aligner.AlignText("THE CAT SAT ON A MAT");
Debug.Log($"WER: {result.wordErrorRate}, Matches: {result.matches}");
}
Aligns recognized speech text against a reference text using dynamic programming edit distance....
Definition KeenASRTextAligner.cs:166
@ Debug
Verbose output including internal processing details.

Constructor & Destructor Documentation

◆ TextAligner() [1/2]

KeenResearch.TextAligner.TextAligner ( string  reference,
string  langCode 
)
inline

Creates a text aligner with the given reference text and language code.

Parameters
referenceReference text to align against.
langCodeASR bundle language code (e.g., "en-us").
Exceptions
InvalidOperationExceptionIf aligner creation fails.

◆ TextAligner() [2/2]

KeenResearch.TextAligner.TextAligner ( string  reference)
inline

Creates a text aligner using the language from the currently initialized recognizer.

Parameters
referenceReference text to align against.
Exceptions
InvalidOperationExceptionIf SDK not initialized or aligner creation fails.

Member Function Documentation

◆ AlignText() [1/2]

AlignmentResult KeenResearch.TextAligner.AlignText ( string  recognized)
inline

Aligns recognized text against the reference using default configuration. This method is thread-safe and can be called concurrently.

Parameters
recognizedRecognized text to align.
Returns
Alignment result with metrics and trace.
Exceptions
ObjectDisposedExceptionIf aligner has been disposed.

◆ AlignText() [2/2]

AlignmentResult KeenResearch.TextAligner.AlignText ( string  recognized,
AlignmentConfig  config 
)
inline

Aligns recognized text against the reference with custom configuration. This method is thread-safe and can be called concurrently.

Parameters
recognizedRecognized text to align.
configAlignment configuration.
Returns
Alignment result with metrics and trace.
Exceptions
ObjectDisposedExceptionIf aligner has been disposed.

◆ Dispose()

void KeenResearch.TextAligner.Dispose ( )
inline

Releases the native aligner resources. Safe to call multiple times.

◆ IncrementalAlignText() [1/2]

AlignmentResult KeenResearch.TextAligner.IncrementalAlignText ( string  recognized)
inline

Incrementally aligns recognized text, reusing state from prior calls. Useful for aligning partial recognition results during streaming. NOT thread-safe - do not call concurrently on the same aligner.

Parameters
recognizedCurrent recognized text (may be partial).
Returns
Alignment result with metrics and trace.
Exceptions
ObjectDisposedExceptionIf aligner has been disposed.

◆ IncrementalAlignText() [2/2]

AlignmentResult KeenResearch.TextAligner.IncrementalAlignText ( string  recognized,
AlignmentConfig  config 
)
inline

Incrementally aligns recognized text with custom configuration. NOT thread-safe - do not call concurrently on the same aligner.

Parameters
recognizedCurrent recognized text (may be partial).
configAlignment configuration.
Returns
Alignment result with metrics and trace.
Exceptions
ObjectDisposedExceptionIf aligner has been disposed.

◆ Reset()

void KeenResearch.TextAligner.Reset ( )
inline

Resets incremental alignment state. Call between utterances when using IncrementalAlignText for multiple separate recognition sessions.

Exceptions
ObjectDisposedExceptionIf aligner has been disposed.

Property Documentation

◆ langCode

string KeenResearch.TextAligner.langCode
get

Language code of the ASR bundle used for normalization.

◆ referenceTokens

string [] KeenResearch.TextAligner.referenceTokens
get

Normalized reference tokens.