https://github.com/jackycamp/flite-rs
Basic rust bindings for flite c library.
https://github.com/jackycamp/flite-rs
flite rust tts
Last synced: 3 months ago
JSON representation
Basic rust bindings for flite c library.
- Host: GitHub
- URL: https://github.com/jackycamp/flite-rs
- Owner: jackycamp
- Created: 2024-01-21T18:12:54.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-01-17T00:14:04.000Z (over 1 year ago)
- Last Synced: 2025-01-17T01:23:44.764Z (over 1 year ago)
- Topics: flite, rust, tts
- Language: Rust
- Homepage:
- Size: 48.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
fliters
rust bindings for the flite c library
## Usage
Check out `/examples` directory for more examples.
```rust
// standard example
use fliters;
fn main() {
fliters::tts("hello, world!").play();
}
```
```rust
// Controlling the output stream. (i.e. playing and pausing)
use fliters;
use rodio::{OutputStream, Sink};
fn main() {
let (_stream, handle) = OutputStream::try_default().unwrap();
let sink = Sink::try_new(&handle).unwrap();
let fwav = fliters::tts("play this audio with some stream controls");
let decoder = fwav.get_decoder();
sink.append(decoder);
sink.play();
std::thread::sleep(std::time::Duration::from_secs(1));
sink.pause();
std::thread::sleep(std::time::Duration::from_secs(3));
sink.play();
sink.sleep_until_end();
}
```
Check out the `make_waveform` example to see how we go from
text -> 16-bit samples -> (time, amplitude) pairs -> wave form visualization in your terminal!
```bash
cargo run --example make_waveform
```

## Tested on
- MacOS Sonoma 14.2
- Debian (bookworm)
## Roadmap
- [x] basic tts api
- [x] control output stream with `play`
- [ ] optimize build (include only necessary c files)
- [ ] customize voice (defaults to slt right now)
- [x] debian linux amd64 support
- [ ] jetson orin support
## Installation
**Linux Dependencies**
On linux, `rodio` relies on `cpal` and `cpal` needs alsa development files to build.
You can see [rodio's repo](https://github.com/RustAudio/rodio?tab=readme-ov-file#dependencies-linux-only) for more info.
```bash
sudo apt install libasound2-dev
```
**crate**
Add this to your cargo.toml:
`fliters = "0.1.8"`
If you install the crate, but encounter build errors, try to specify the repo as the dependency. Submit an issue in the meantime while I investigate.
`fliters = { git = "https://github.com/jackycamp/flite-rs" }`
## Building
```bash
# clone the repository
git clone https://github.com/jackycamp/flite-rs.git
# If you want the git submodules on first clone
git clone --recursive https://github.com/jackycamp/flite-rs.git
# do the build
cd flite-rs && cargo build
# run an example
cargo run --example tts
```
## Troubleshooting
On linux, sometimes pulseaudio crashes and you might see ALSA messages in your terminal
when you try to call the `play()` fn, e.g.:
```bash
...
ALSA lib pcm.c:8570:(snd_pcm_recover) underrun occurred
ALSA lib pcm.c:8570:(snd_pcm_recover) underrun occurred
ALSA lib pcm.c:8570:(snd_pcm_recover) underrun occurred
...
```
Restarting pulseaudio's (daemon) can sometimes fix this:
```bash
pulseaudio -k # kills the deamon, and should automatically restart
```