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:
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.
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.