Search code examples
speech-recognitiontext-to-speech

Graphene to phoneme heuristic for OOV words


I need to do Graphene to phoneme (g2p) conversion in c++, however, most g2p libraries are in python or rust (pocketsphinx might work but seems like a headache).

G2P is done by:

  • Dictionary lookup for non-homophones.
  • calculates POS for homophones
  • deep learning for OOV (out of vocabulary) words

However, for now it doesn't matter if there's vowel substitution for homophones and OOV words.

I just need to get my other code up and running, and then I can forget about this disaster, so a quick heuristic is what's needed.

I'd post an answer soon.


Solution

  • Here's an attempt https://godbolt.org/z/z6G4o6c4K

    It pronounces school as s-chul (in arpabet S CH UW L). But that's good enough I suppose.

    It first tries to parse the first two characters, if they match common digram (i.e. ch, sh, th) then return the corresponding phoneme and pass the remainder. Otherwise convert the first letter to the closest phoneme.