KeenASR Framework v2.1 (8b72cc4)
Keen Research
Loading...
Searching...
No Matches
KIOSWordPronunciation Class Reference

#include <KIOSWordPronunciation.h>

Instance Methods

(instancetype) - initWithWord:pronunciation:tag:
(nonnull NSString *) - getWord
(nonnull NSString *) - getTag
(nonnull NSString *) - getPronunciation
(BOOL) - isValid:

Detailed Description

WordPronunciation is a class that defines mapping beween a word and its phonetic pronunciation. 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 lang/phones.txt file. For some languages for which this mapping is not deterministic, ASR Bundle will contain a large lookup table in lang/lexicon.txt file.

You can use WordPronunciations to provide alternatives to existing pronunciations, to define pronunciations for the words that are not in the lexicon.txt file (including made-up words), or to provide common mispronunciations (which can be useful in some scenarios such as language learning and reading instruction); For the latter, you can also provide a tag when defining WordPronunciation; if such alternative pronunciation is recognized by the recognizer, the # symbol and the provided tag will be appended to the word in the result (e.g. "PEAK#WRONG", if the tag was set to "WRONG").

Example:

KIOSWordPronunciation *myFoo = [[KIOSWordPronunciation alloc] initWithWord:@"TIME" pronunciation:@"L AY1 M" tag:@"WRONG"];
Definition KIOSWordPronunciation.h:26

Method Documentation

◆ getPronunciation

- (nonnull NSString *) 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

- (nonnull NSString *) getTag

Get the optional tag value, which, if provided, 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.

◆ getWord

- (nonnull NSString *) getWord

Get the string specifying the word. For example "CAT".

Returns
string specifying the word.

◆ initWithWord:pronunciation:tag:

- (instancetype) initWithWord: (nonnull NSString *) word
pronunciation: (nonnull NSString *) pronunciation
tag: (nullable NSString *) tag 

Parameterized constructor

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

Parameters
wordstring specifying the word. For example "CAT".
pronunciationa space separated phone string.
taga tag suffix for the word.

◆ isValid:

- (BOOL) isValid: (nonnull KIOSRecognizer *) recognizer

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

A word pronunciation is valid if:

  1. word does not contain < or > characters
  2. tag is not equal to "INC" (reserved tag) and it does not contain # character
  3. pronunciations are composed of valid phones (as defined in the ASR Bundle that was used to initialize the Recognizer)
Parameters
recognizeran instance of KIOSRecognizer object against which the validation should be performed.
Returns
true if this word pronunciation is valid; false otherwise

The documentation for this class was generated from the following file: