In my case it was a windows SAPI program (run under wine) and lame just refused to work on the file although it converted well final files generated by the program. My workaround was to generate smaller files and feed lame with them.
On Wed, Sep 9, 2009 at 2:53 PM, Andreas Karlsson<andreas_k...@yahoo.com> wrote: > Hi, > Bad news that you failed - what went wrong and what was the workaround? > Thanks for the useful links, I'll go back to them if my approach fails. > Right now I'm stuck on a 'Broken pipe' exception while writing a stream from > the TTS-generated file to the console where Lame executes. > The approach is to execute Lame in a console which converts the inputstream > from PCm to mp3. The inputstream is generated from the file which the TTS > engine is still writing to. > It is the > bouts.write(b); > that generates the "broken pipe" exception. > > Here is the code if anyone wants to help > brgds > Andreas > > String command = "/bin/bash -c \"/usr/bin/lame -r -x -m m -b 32 -s 22.05 - - > > output.mp3\" "; > log.info("COMMAND: "+command ); > > BufferedOutputStream bouts=null; > BufferedInputStream bfins=null; > BufferedReader br2=null; > BufferedReader input=null; > > try { > Runtime rt = Runtime.getRuntime(); > Process pr = rt.exec(command); > bouts=new > BufferedOutputStream(pr.getOutputStream());//will use this stream to send > data to Lame > File tmpFile = new File(tmpOutputFileNamePath);// this is > the file where data is being written from the TTS > while(tmpFile.exists()==false) > { > log.info("File does not exist yet... going to sleep" ); > Thread.sleep(500); > } > bfins = new BufferedInputStream(new > FileInputStream(tmpFile)); > > int b=0; > int noOfBytesAvailable=0; > // Read chunks of bytes and write them to the Lame input > stream > while(ttsThreadObj.isAlive()) // TODO might miss some data > when the thread has finished > { > noOfBytesAvailable= bfins.available(); > if(noOfBytesAvailable>0) > { > log.info(noOfBytesAvailable +" bytes available" ); > for( ;noOfBytesAvailable>0;noOfBytesAvailable--) > { > b=bfins.read(); > bouts.write(b); > } > } > else { > log.info("Nothing available..." ); > } > } > > > > --- On Tue, 9/8/09, Aleksandar Kostadinov <ava...@friendofpooh.com> wrote: > >> From: Aleksandar Kostadinov <ava...@friendofpooh.com> >> Subject: Re: [mp3encoder] text to speech application - will lame solve my >> problem? >> To: "MP3 encoders development list" <mp3encoder@minnie.tuhs.org> >> Date: Tuesday, September 8, 2009, 10:36 AM >> I have once tried to make a TTS >> engine write to a pipe file and have >> lame read from the pipe file but that failed badly. I found >> a >> workaround so didn't find a fix. >> >> Is this Linux? You could try some magic with ALSA. For >> example writing >> to file or memory and have lame read from there. As well >> I've heard >> sound servers are also quite capable (pulseaudio, etc.). >> >> And btw for me encoding is often at 50x on my old laptop so >> I'm not >> sure why encoding for you takes so much time. >> >> On Tue, Sep 8, 2009 at 10:44 AM, Andreas Karlsson<andreas_k...@yahoo.com> >> wrote: >> > 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 >> > >> > >> > >> > >> > >> > _______________________________________________ >> > mp3encoder mailing list >> > mp3encoder@minnie.tuhs.org >> > https://minnie.tuhs.org/mailman/listinfo/mp3encoder >> > >> _______________________________________________ >> mp3encoder mailing list >> mp3encoder@minnie.tuhs.org >> https://minnie.tuhs.org/mailman/listinfo/mp3encoder >> > > > > > _______________________________________________ > mp3encoder mailing list > mp3encoder@minnie.tuhs.org > https://minnie.tuhs.org/mailman/listinfo/mp3encoder > _______________________________________________ mp3encoder mailing list mp3encoder@minnie.tuhs.org https://minnie.tuhs.org/mailman/listinfo/mp3encoder