Welcome to JavaRanch.
Sun has defined an API called
Java Speech API for both text-to-speech and speech-to-text. That's just an API, though - it doesn't come with implementations.
What you're asking is the harder of the two by far; it's a subject being actively researched. Any solution (which will be partial at best) is going to cost you money.