These are the scripts I use on my own system to print an IPA representation of a word, using both modern text to speech programs and older (1970's/1980's) lightweight text to speech programs. They won't work directly on anyone else's system but should give you some clues as to where to start. I'm not sure but I think I had to modify some of the modern text to speech suites to support the extraction of phonemes. (This was all several years ago). I definitely made some mods to the older software but those are obvious in the source files and can be easily undone.