Crates.io | fakeyou-api |
lib.rs | fakeyou-api |
version | 0.3.0 |
source | src |
created_at | 2023-07-08 15:37:18.985424 |
updated_at | 2023-07-23 07:22:58.136017 |
description | A very simple Rust library for FakeYou API. |
homepage | https://github.com/alexjercan/fakeyou-api |
repository | |
max_upload_size | |
id | 911527 |
size | 56,014 |
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.
cargo add fakeyou-api
Export your API key into the environment variables (if you use the paid version).
export FAKEYOU_API_KEY=...
Then use the crate in your Rust code:
// 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 FAKEYOU_API_KEY.
// You can also hadcode through `Auth::new(<your_api_key>)`, but it is not recommended.
let auth = Auth::default();
let fakeyou = FakeYou::new(auth, FAKEYOU_API_URL);
// 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 output_result = fakeyou.create_tts_task(&inference_body).unwrap();
// Do what you need with the audio file
std::fs::write("output.wav", output_result.bytes).unwrap();
This project is licensed under MIT