$ show dejan/espeak-ruby
espeak-ruby is a Ruby gem providing a simple API to generate Text-to-Speech audio using the `espeak` command-line tool and optionally compress to MP3 using `lame`. It exposes two main classes: `ESpeak::Speech` for generating speech (speak, save to file, or retrieve raw bytes) and `ESpeak::Voice` for listing available voices. The architecture is a thin wrapper around external CLI commands using `IO.popen`, with a clean hash-based options interface for pitch, speed, voice, amplitude, and capital letter emphasis. The repository also includes a full demo web application (Roda + Stimulus + WaveSurfer) that demonstrates the library in a browser, with a Kubernetes deployment configuration. The core library is well-structured, tested, and actively maintained, but it is a straightforward wrapper with no complex internal logic.
The LLM identified 2 files worth highlighting for reuse:
The core class for generating speech. It wraps `espeak` and `lame` CLI commands via `IO.popen`. Provides methods `speak`, `save`, `bytes`, and `bytes_wav` to either play audio, save to MP3 file, or return raw bytes. The options are passed as a hash and merged with sensible defaults. The use of `IO.popen` with pipes for both reading and writing demonstrates a clean pattern for interacting with external processes. This is a reusable pattern for any Ruby project that needs to invoke command-line tools and capture output.
Provides a class method `all` that parses the output of `espeak --voices` into structured `Voice` objects with language, name, gender, and file attributes. The `find_by_language` method filters the list. This is a clean, reusable pattern for parsing structured CLI output into Ruby objects, suitable for any project that needs to wrap a command-line tool that outputs tabular data.