Skip to content

nytly0/gtts_rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

this will produce an audio: hello_world

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.

About

Rust library & CLI for Google Translate's text‑to‑speech (TTS)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages