text to speech application - will lame solve my problem?

Andreas Karlsson <andreas_k_se-/[email protected]> Tue, 8 Sep 2009 00:44:51 -0700 (PDT)
Newsgroups gmane.comp.audio.mp3.encoders
Message-ID <[email protected]>
Hi guys,
I'm into writing an application in JAVA that takes the output from a TTS (Text to speech) engine and outputs that as a mp3 stream on a webpage.
My problem is the TTS-engine generating raw PCM as output and I have to start sending the mp3-stream before the TTS is done since 10 second of speeach takes 10 second to generate.
I read some parts from the LAME documentation and I'm into trying calling the command line version of LAME (linux) from within my program with something like 
cat PCMFileUnderConstruction | lame -r -m m -b 32 -s 22.05 - - > output.mp3

The raw PCM is sampled with 22.05 kHz.

Will this work, reading from a file that the TTS is still generating?
I want Lame to process the content being written to that file until the file PCMFileUnderConstruction is closed.

brgds
Andreas