A very simple Rust library for FakeYou API.
Check the official API reference.
|API|Support| |---|---| |Text to Speech|✔️| |Voices|❌| |Categories|❌|
Install the library using the Cargo.toml file or run the following command.
console
cargo add fakeyou-api
Export your API key into the environment variables (if you use the paid version).
console
export FAKEYOU_API_KEY=...
Then use the crate in your Rust code:
```rust // Import the dependencies use fakeyou_api::{tts::InferenceBody, util::tts::TtsApiSync, *};
// You can create a default client without any api key.
// You can also load the API key from environment FAKEYOUAPIKEY.
// You can also hadcode through Auth::new(<your_api_key>)
, but it is not recommended.
let auth = Auth::default();
let fakeyou = FakeYou::new(auth, FAKEYOUAPIURL);
// Create the TTS body let inference_body = InferenceBody::new("TM:ebgxj0j4fvzp", "Hello, World! What should we do today?");
// Call the TTS API // This uses the util module of this crate and will block the thread until the task is done let outputresult = fakeyou.createttstask(&inferencebody).unwrap();
// Do what you need with the audio file std::fs::write("output.wav", output_result.bytes).unwrap(); ```
This project is licensed under MIT