Phoneme to letter mapping
Last updated
Last updated
Some applications may highlight letters in a word where pronunciation errors occurred to help learners visualize their mistakes, especially if they are unfamiliar with phonemes.
For example, if a user mispronounces the /sh/ sound in "shift," the application could display the word with the problematic letters crossed out or color-coded to indicate errors:
Incorrect Example:
**sh**ift
(where "sh" is highlighted to show the pronunciation issue)
The Speechace API does not score individual letters; instead, it decomposes each scored word into its phonemes and scores them at the phoneme level.
To identify which letter(s) in a word correspond to a specific phoneme:
Access Phoneme Data:
Retrieve phoneme-level scores from the word_score_list[].phone_score_list[]
array.
Locate Letter Mapping:
For each phoneme, use the phone_score_list[].word_extent[]
field to find the character indices within the word that this phoneme maps to. This field contains the [begin, end]
character indices.
By checking these indices, the application can map the phoneme to its corresponding letters in the word.
In the above example of the word "shift", the contents of phone_score_list[]
would be:
phone | word_extent | letter(s) |
---|---|---|
The letters column is built using the character indices specified in word_extent
. Notice that a phoneme may correspond to more than one letter. For instance, a phoneme like /sh/ in "shift" covers two letters (e.g., 'sh') as shown above.
There are multiple possibilities of phoneme to letter mapping that the API caller should be prepared for:
Case | word_extent | Example |
---|---|---|
sh
[0,2]
sh
ih
[2,3]
i
f
[3,4]
f
t
[4,5]
t
Phoneme maps to zero letters
[n, n] where the begin and end indices are the same. The value of n depends on the phoneme's position in the word
The word "#" (i.e. hashtag) which is phonetically expanded to ['hh', 'ae', 'sh', 't', 'ae', 'g']
Phoneme maps to 1 letter
[n, n+1]
/f/ in "shift"
Phoneme maps to 2 letters
[n, n+2]
/sh/ in "shift"
2 Phonemes map to 1 letter
Each phoneme will have the same word_extent: [n, n+1] [n, n+1]
letter 'x' in the word "exempt" maps to the phonemes /g/, /z/
2 or more Phonemes map to zero letters
Each phoneme will have the same word_extent: [n, n]
The word "w" which is phonetically expanded to ['d', 'ah', 'b', 'ah', 'l', 'y', 'u', 'w']
No Phoneme to letter mapping available
word_extent field will be missing
Words outside of the Speechace lexicon processed with markup_language or include_unknown_words handling.