I'm writing a computer program which requires some of this functionality at one point, so I wanted to get into a (better-written) code and have a look, to get some inspiration. Are there any good ones out there?
Have you tried WikSpeak? It is a GUI-based tool for converting English texts into their IPA transcriptions. Since it is open source, it should be no problem to extract and examine the functionality that is relevant to your project.
You're probably not still wanting answers, but I'll add this for posterity. espeak is a command line speech synthesis program. It outputs to various formats (including IPA), and has various different voices. For instance, English has voices en, en-us, en-sc (Scottish), en-n (Northern English), en-rp and en-wm (West Midlands). There are many other languages, too.