|
KeenASR Framework v2.2 (c662ac9)
Keen Research
|
Aligns recognized speech against a reference text using DP edit distance. More...
#include <KIOSTextAligner.h>
Instance Methods | |
| (nullable instancetype) | - initWithReference:langCode: |
| Designated initializer. Constructs an aligner bound to the given reference text and language code. | |
| (nullable instancetype) | - initWithReference:recognizer: |
| Convenience initializer that sources the language code from a recognizer instance. | |
| (instancetype) | - NS_UNAVAILABLE |
| (KIOSAlignmentResult *) | - align: |
| Align recognized text against the reference using default configuration. | |
| (KIOSAlignmentResult *) | - align:config: |
| Align recognized text against the reference with custom configuration. | |
| (KIOSAlignmentResult *) | - incrementalAlign: |
| Align recognized text incrementally, reusing DP state from the previous call. | |
| (KIOSAlignmentResult *) | - incrementalAlign:config: |
| Incremental align with custom configuration. | |
| (void) | - reset |
| Drop cached DP state. Call between utterances when using incremental alignment. | |
Class Methods | |
| (instancetype) | + NS_UNAVAILABLE |
Aligns recognized speech against a reference text using DP edit distance.
Typical use is oral-reading scoring: a user reads a known passage, the ASR produces a hypothesis, and the aligner reports which reference words were read correctly, which were skipped, and how far the reader got. The same primitive supports word-error-rate reporting for batch ASR evaluation.
The reference text is normalized and tokenized once at construction and cached. Subsequent calls to - align: (KIOSTextAligner) and - incrementalAlign: (KIOSTextAligner) normalize their inputs using the same rules, so reference and recognized sides share a canonical form.
The language code passed at construction must match the ASR bundle that produced (or will produce) the recognized text — normalization differs subtly between languages (accent handling, & expansion, etc.) and a mismatch silently degrades accuracy.
The receiver owns its native counterpart and releases it on dealloc.
| - (KIOSAlignmentResult *) align: | (NSString *) | recognized |
Align recognized text against the reference using default configuration.
Equivalent to calling - align:config: with a default-constructed KIOSAlignmentConfig. Stateless — safe to call concurrently with itself.
| recognized | Recognized text from the ASR engine. |
| - (KIOSAlignmentResult *) align: | (NSString *) | recognized | |
| config: | (nullable KIOSAlignmentConfig *) | config |
Align recognized text against the reference with custom configuration.
Stateless — safe to call concurrently with itself.
| recognized | Recognized text from the ASR engine. |
| config | Alignment configuration. Pass nil to use defaults. |
| - (KIOSAlignmentResult *) incrementalAlign: | (NSString *) | recognized |
Align recognized text incrementally, reusing DP state from the previous call.
Intended for use in partial-result callbacks where the recognized text grows or changes slightly between calls. The aligner detects the longest common prefix between successive inputs and recomputes only the divergent tail.
Call -- reset when starting a new utterance to clear the cache.
Not thread-safe. Do not call concurrently from multiple threads, and do not interleave with -- align: if you depend on the cache surviving.
| recognized | Recognized text from the ASR engine. |
| - (KIOSAlignmentResult *) incrementalAlign: | (NSString *) | recognized | |
| config: | (nullable KIOSAlignmentConfig *) | config |
Incremental align with custom configuration.
Changing cost values between successive calls invalidates the cache and forces a full recompute on the next call.
| recognized | Recognized text from the ASR engine. |
| config | Alignment configuration. Pass nil to use defaults. |
| - (nullable instancetype) initWithReference: | (NSString *) | reference | |
| langCode: | (NSString *) | NS_DESIGNATED_INITIALIZER |
Designated initializer. Constructs an aligner bound to the given reference text and language code.
The reference is normalized and tokenized at construction; the cached token vector is available via referenceTokens.
| reference | Reference text to align against. Required. |
| langCode | ASR bundle language code, e.g. "en-us", "fr-fr", "de-de", "es-es". Required. |
| - (nullable instancetype) initWithReference: | (NSString *) | reference | |
| recognizer: | (KIOSRecognizer *) | recognizer |
Convenience initializer that sources the language code from a recognizer instance.
Equivalent to calling - initWithReference:langCode: with [recognizer asrBundleLang].
| reference | Reference text to align against. Required. |
| recognizer | Initialized recognizer whose ASR bundle defines the language code. Required. |