The Carnegie Mellon University pronouncing dictionary allows to get phonemes from words. I did some research on the Internet and it appears that there are some extensions as the LOGIOS Lexicon Tool which derives the phonemes for arbitrary words that might not be included in the original CMU dictionary (http://www.speech.cs.cmu.edu/tools/lextool.html). The same can be obtained by using a neural network model (https://github.com/cmusphinx/g2p-seq2seq), so that basically for each word we can get the corresponding phonemes.
But is the process reversible for every word? Obviously for words already contained in the CMU dictionary the reversing is unnecessary since the word is attached to the corresponding phonemes. But how can I get the word from arbitrary phonemes? Is that a tool for that (possibly in Python) or should I implement the reverse by myself maybe looking at the source code doing the word-to-phoneme parsing and trying to revert it (if possible)?
The most natural way is to train some seq2seq neural network model to perform phoneme to grapheme conversion.
g2p-seq2seq used to support phoneme to grapheme mode, see github issue, but this feature was lost in recent upgrade. It would be nice to bring it back.