Class KASRWordPronunciation

java.lang.Object
com.keenresearch.keenasr.KASRWordPronunciation

public class KASRWordPronunciation extends Object

KASRWordPronunciation is a class that 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. The names of the phonemes are defined in ASR Bundle's lang/phones.txt file. For some languages, where this mapping is not deterministic, the ASR Bundle will contain a large lookup table in the lang/lexicon.txt file.

You can use KASRWordPronunciation to provide alternatives to existing pronunciations, or to define pronunciations for words that are not in the ASR Bundle lexicon. Some scenarios where this could be useful is modeling of: a) made-up words, b) common mispronunciations. The latter can be useful in use cases involving language learning and reading instruction. In those scenarios you can also provide an arbitrary tag value when constructing a WordPronunciation. The tag will be appended to the recognized word in the result, if such pronunciation was the most likely hypothesis. For example, given a wordPEAK” and tagWRONG” the word in the result will be “PEAK#WRONG”.

Example: a pronunciation for PEAK that could potentially be tagged as WRONG is

 KASRWordPronunciation wordPronunciation = new KASRWordPronunciation("PEAK", "B IY1 K", "WRONG");
 
  • Constructor Details

    • KASRWordPronunciation

      public KASRWordPronunciation(String word, String pronunciation, String tag)

      Parameterized constructor.

      NOTE: both word and phones will internally be stored in uppercase.

      Parameters:
      word - string specifying the word. For example "CAT".
      pronunciation - a space separated phone string.
      tag - a tag suffix for the word.
    • KASRWordPronunciation

      public KASRWordPronunciation(String word, String pronunciation)

      Parameterized constructor.

      NOTE: both word and phones will internally be stored in uppercase.

      Parameters:
      word - string specifying the word. For example "CAT".
      pronunciation - a space separated phone string.
  • Method Details

    • isValid

      public boolean isValid()

      Verify if this object is valid, for a given KASRRecognizer.

      A word pronunciation is valid if:

      1. word does not contain < or > characters.
      2. tag is not equal to "INC" (a reserved tag) and it does not contain a # character.
      3. pronunciation is composed of valid phones (as defined in the ASR Bundle that was used to initialize the KASRRecognizer).
      Returns:
      true if this word pronunciation is valid; false otherwise.
    • getWord

      public final String getWord()

      Get the string specifying the word.

      Example: "CAT".

      Returns:
      string specifying the word.
    • getPronunciation

      public final String getPronunciation()

      Get the phonetic transcription of a word, provided as a space-separated sequence of phones.

      Returns:
      space separated sequence of phones, provided during object creation. Phones will be in upper case and extra white spaces will be removed during object creation.
    • getTag

      public final String getTag()

      Get the optional tag value.

      When provided during construction, this tag will be appended together with the # symbol to the word if the variation of the word with the provided pronunciation is recognized. For example, PEAK#WRONG.

      Returns:
      string specifying the tag.