sherpa-onnx icon indicating copy to clipboard operation
sherpa-onnx copied to clipboard

sherpa-onnx-offline-tts: Allow piping text using cat or text file input with command line parameter

Open domasofan opened this issue 1 year ago • 6 comments

Hi all,

Is it possible to add the possibility to pipe text into the tts engine using cat or a command line parameter? That would help greatly when converting large amounts of text into speech. Especially blind people might be interested in that feature.

Greetings and thanks, Simon

domasofan avatar May 09 '24 18:05 domasofan

It might be a good idea to provide both. text input through stdin and also through a command line parameter.

domasofan avatar May 10 '24 23:05 domasofan

Hi, we have already provided all required APIs to implement your requirements.

But if you have trouble with programming, I am afraid it is difficult for you to implement it.

csukuangfj avatar Jun 17 '24 06:06 csukuangfj

Sometimes, using /dev/stdin as a pseudo-file can be a workaround for this type of situation.

danpovey avatar Jun 17 '24 06:06 danpovey

Hi @csukuangfj,

Sorry, my programming skills are pretty limited. We blind people are looking into converting text documents and books into audio. So we need a solution that we can pipe text files into the engine. Writing a batch or bash script later shouldn't be a big problem.

Greetings, Simon

domasofan avatar Jun 17 '24 08:06 domasofan

Hi @danpovey,

Thanks for replying. I don't know if i am understanding you right but i recently tried to pipe in the text file like that: cat file.txt | sherpa-onnx-offline-tts --model=model.onnx ...

Though that seemed not to work. I haven't tried it the other way around or adding /dev/stdin at the end of the command.

Most of the time i am using Windows and linux is just my second os which i am using part time. :-)

That's why i guess it might be best to add a possibility to pipe in the text using cat to sherpa-onnx-offline-tts and the raw audio output to pipe it into lame or ffmpeg for direct conversion to mp3 or other formats. cat can be installed on windows without any problem.

Greetings, Simon

domasofan avatar Jun 17 '24 08:06 domasofan