Skip to content

Conversation

@ribbon-otter
Copy link

Inspired by issue#56 and my general frustration of not having an better sounding alternative to espeak that is easy-to-install on Linux, I decided to try my hand at writing a C++ front-end to libpiper. Currently, it supports reading from stdin, reading a text file passed on the commandline and reading the command-line first argument.

Since piper1 depends on espeak-ng, I used espeak-ng's audio library pcaudiolib to play audio. I have a pull request with the documentation I reconstructed for it currently open.

There are many obvious features to yet implement and ways the code could be improved. For example, an option to select the voice instead of just using the first one in directory or an option to pick the speed or noise or audio output device. Offering a way to save to a wav file would help reach feature parity with espeak.

Many of the various weaknesses of code are noted in comments. For example, when reading a file, the entire file is loaded into memory and sent to libpiper at once. This could cause problems if the file is large enough that doesn't fit into memory.

Currently, the CMakeLists.txt for it builds against the system's copy of pcaudiolib, but for the other dependencies, it uses the copies of the onnx runtime and espeak-ng from following the libpiper README.txt instructions. It needs some modification to make the built binary installable. You have to manually download a voice and place it into the voices directory. I am not sure what is the correct policy for voices. Perhaps automatically downloading a single English voice would be an appropriate action during the build process to make the software work without any manual actions, assuming that such bundling is permitted by licensing.

My understanding is that libpiper is waiting on the new version of espeak-ng to either release or fully roll out before switching to building against the system copy of espeak-ng and onnx. So fully fixing piper-speak's build system likely should wait until then.

Piper-speak currently targets c++17 because I didn't see any particular c++ version to target elsewhere in the code and I wanted to use std::filesystem so I didn't target any older.

I make a pull request now, rather than when the piper-speak is blemish free and feature complete, to get feedback and gauge interest.

ribbon-otter added 2 commits September 12, 2025 17:54
There is still a lot of work that need to be done before it is remotely usable.
However, the core of the build system for piper-speak works, and speech is synthesised. piper-speak.cpp is currently almost a copy and paste from the libpiper README.md example.
@ribbon-otter ribbon-otter changed the title Piper-speak: a espeak-style C++ commandline front-end for libpiper Piper-speak: an espeak-style C++ commandline front-end for libpiper Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant