I've never tried this, but the Speak it! app from the App Store might be what you're looking for. If you are jailbroken you can also try Action Menu Voice, available in Cydia. I've used this and it works nicely. I don't think either app will actually speak as you are typing though, only after you have entered or selected text.