This is a Rust client for Google Translate's TTS (Text-To-Speech) service. It allows you to synthesize text to speech using Google Translate and write the output to an audio file.
- Rust (1.41 or later)
- Cargo (1.41 or later)
reqwest
andtokio
crates.
-
Clone the repository:
git clone https://github.com/sabry-awad97/text-to-speech.git cd text-to-speech
-
Build the project:
cargo build --release
The basic usage of the Text-To-Speech Rust client is as follows:
use std::error::Error;
use text_to_speech::TextToSpeech;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let text = "Hello, world!";
let language = "en-US";
let path = "output.mp3";
let mut tts = TextToSpeech::new(language, path).await?;
tts.synthesize_text(text).await?;
Ok(())
}
text
is the input text that you want to synthesize.language
is the language in which you want to synthesize the text.path
is the output audio file path.
Bug reports and pull requests are welcome on GitHub at https://github.com/sabry-awad97/text-to-speech. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The Text-To-Speech Rust client is available as open source under the terms of the MIT License.