keenasr-web - v2.1.2
    Preparing search index...

    Class WordPronunciation

    Defines a mapping between a word and its phonetic pronunciation.

    A phonetic pronunciation is a space-separated string of phonemes that define how the word is pronounced. Phoneme names are language-specific and defined in the ASR Bundle. For languages where spelling-to-pronunciation mapping is not deterministic, the ASR Bundle contains a lookup table in lang/lexicon.txt.

    Use cases:

    • Alternative pronunciations - Provide variants for existing words
    • Made-up words - Define pronunciations for words not in the lexicon
    • Common mispronunciations - Model expected errors for language learning and reading instruction

    Tagging mispronunciations:

    You can provide an optional tag when constructing a WordPronunciation. If that pronunciation is recognized, the tag is appended to the word with a # separator. For example, with word "PEAK" and tag "WRONG", the result will contain "PEAK#WRONG".

    // Define a mispronunciation of "PEAK" (saying "B" instead of "P")
    const wp = new WordPronunciation("PEAK", "B IY1 K", "WRONG");
    // If recognized, the word in the result will be "PEAK#WRONG"
    Index

    Constructors

    Properties

    Constructors

    • Creates a new WordPronunciation.

      Note: Both word and pronunciation are stored in uppercase internally.

      Parameters

      • word: string

        The word string (e.g., "CAT")

      • pronunciation: string

        Space-separated phone string (e.g., "K AE1 T")

      • tag: string = ''

        Optional tag suffix for identifying this pronunciation variant

      Returns WordPronunciation

      Error if the SDK is not initialized

    Properties

    word: string

    The word string (e.g., "CAT").

    pronunciation: string

    The phonetic transcription as a space-separated sequence of phones (e.g., "K AE1 T").

    tag: string

    The optional tag value.

    When provided, this tag is appended with a # separator to the word if this pronunciation variant is recognized (e.g., "PEAK#WRONG").

    isValid: boolean

    Whether this WordPronunciation is valid for the current recognizer.

    A WordPronunciation is valid if:

    • word does not contain < or > characters
    • tag is not "INC" (reserved) and does not contain #
    • pronunciation contains only valid phones defined in the ASR Bundle