| Crates.io | gtts_rs |
| lib.rs | gtts_rs |
| version | 0.1.0 |
| created_at | 2025-11-07 16:33:41.249862+00 |
| updated_at | 2025-11-07 16:33:41.249862+00 |
| description | A Rust library and CLI for Google Translate's text-to-speech API. |
| homepage | |
| repository | https://github.com/dhairy-online/gtts_rs |
| max_upload_size | |
| id | 1921815 |
| size | 59,093 |
A Rust library for Google Translate’s text-to-speech API. Writes audio to an mp3 file and plays it using the rodio crate.
Add this to your Cargo.toml:
[dependencies]
gtts_rs = "0.1"
using default configuration:
use gtts_rs::tts::{ GttsClient, Language, Speed };
fn main() -> Result<(), String> {
let client = GttsClient::default();
client.speak("Hello, world!")?;
Ok(())
}
with custom configuration:
use gtts_rs::tts::{ GttsClient, Language, Speed };
fn main() -> Result<(), String> {
let mut client: GttsClient = GttsClient {
volume: 1.0,
language: Language::English,
speed: Speed::Slow,
tld: "com",
};
client.speak("Hello, world!")?;
Ok(())
}
or a different language:
use gtts_rs::tts::{ GttsClient, Language, Speed };
fn main() -> Result<(), String> {
let client = GttsClient {
volume: 1.0,
language: Language::Japanese,
speed: Speed::Normal,
tld: "co.jp",
};
client.speak("こんにちは、元気ですか?")?;
Ok(())
}
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are very welcome! Please feel free to submit issues and pull requests.