gtts_rs

Crates.iogtts_rs
lib.rsgtts_rs
version0.1.0
created_at2025-11-07 16:33:41.249862+00
updated_at2025-11-07 16:33:41.249862+00
descriptionA Rust library and CLI for Google Translate's text-to-speech API.
homepage
repositoryhttps://github.com/dhairy-online/gtts_rs
max_upload_size
id1921815
size59,093
Dhairy Srivastava (nytly0)

documentation

README

gtts_rs

A Rust library for Google Translate’s text-to-speech API. Writes audio to an mp3 file and plays it using the rodio crate.

Usage

Add this to your Cargo.toml:

[dependencies]
gtts_rs = "0.1"

Example

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(())
}

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contribution

Contributions are very welcome! Please feel free to submit issues and pull requests.

Commit count: 0

cargo fmt