KeenASR React Native Plugin (v2.2)
    Preparing search index...

    Aligns recognized speech against a reference text using the native SDK's DP edit-distance aligner.

    Typical use is oral-reading scoring: a user reads a known passage, the recognizer produces a hypothesis, and the aligner reports which reference words were read, which were skipped, and how far the reader got. The same primitive supports word-error-rate reporting for batch ASR evaluation.

    align recomputes alignment from scratch on each call. incrementalAlign caches DP rows from the previous call and reuses them up to the longest common prefix of consecutive recognized inputs — useful when consuming a stream of partial ASR results against the same reference. Call reset() between distinct utterances.

    Always call close() when done to release the underlying native object promptly.

    const aligner = await TextAligner.create(
    'Alice was beginning to get very tired',
    'en-us'
    );

    const result = await aligner.align('ALICE WAS TIRED');
    console.log(result.matchedRefIndices); // [0, 1, 6]
    console.log(result.furthestMatchedIndex); // 6

    await aligner.close();
    Index

    Accessors

    • get referenceTokens(): readonly string[]

      Normalized reference tokens, in order. Indices in alignment results refer to positions in this array.

      Returns readonly string[]

    • get langCode(): string

      Language code this aligner was constructed with.

      Returns string

    • get isClosed(): boolean

      Whether the aligner has been closed.

      Returns boolean

    Methods

    • Create an aligner bound to the given reference and language code.

      The reference is normalized and tokenized in native code at construction; the cached token vector is exposed via referenceTokens.

      Parameters

      • reference: string

        Reference text to align against.

      • langCode: string

        ASR bundle language code (e.g. "en-us", "fr-fr"). Must match the ASR bundle that produced or will produce the recognized text — normalization differs subtly between languages and a mismatch silently degrades accuracy.

      Returns Promise<TextAligner>

      if the native aligner could not be constructed.

    • Convenience factory that sources the language code from the currently initialized recognizer's ASR bundle. The recognizer must be initialized before calling this.

      Parameters

      • reference: string

      Returns Promise<TextAligner>

      if the recognizer is not initialized or the aligner could not be constructed.

    • Aligns recognized text against the reference. Stateless — safe to call concurrently with itself.

      Parameters

      • recognized: string

        Recognized text from the ASR engine. null/empty is treated as an empty string.

      • Optionalconfig: AlignmentConfig

        Optional per-call configuration. Defaults reproduce classic Levenshtein word edit distance with noise-token filtering on.

      Returns Promise<AlignmentResult>

    • Aligns recognized text incrementally, reusing DP state from the previous call. Not thread-safe per aligner instance. Call reset between distinct utterances.

      Parameters

      Returns Promise<AlignmentResult>

    • Drops cached DP state.

      Returns Promise<void>

    • Release the native aligner. Subsequent calls on this instance throw. Safe to call more than once; later calls are no-ops.

      Returns Promise<void>