k2-fsa / sherpa-onnx

Speech-to-text, text-to-speech, speaker recognition, and VAD using next-gen Kaldi with onnxruntime without Internet connection. Support embedded systems, Android, iOS, Raspberry Pi, RISC-V, x86_64 servers, websocket server/client, C/C++, Python, Kotlin, C#, Go, NodeJS, Java, Swift, Dart, JavaScript, Flutter, Object Pascal, Lazarus, Rust
https://k2-fsa.github.io/sherpa/onnx/index.html
Apache License 2.0
3.16k stars 368 forks source link

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

Open domasofan opened 4 months ago

domasofan commented 4 months ago

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 commented 4 months ago

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

csukuangfj commented 3 months ago

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.

danpovey commented 3 months ago

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

domasofan commented 3 months ago

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 commented 3 months ago

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