Expand description
An easy, synchronous API to access FakeYou’s AI TTS services
This is an unofficial API with no connection to storyteller.ai
An account with FakeYou is required to use this API.
It has not been tested on lower tiers, and is still missing features.
At the moment, it is the minimum necessary to query voices, categories, and generate audio using them.
Examples
Using only two lines of code, it is possible to generate usable audio.
In these examples, we are using a model token which is already known to us.
These will take some time to finish, due to the API’s queue
use fakeyou;
fn main() {
let fake_you = fakeyou::authenticate("user_name", "password").unwrap();
fake_you.generate_file_from_token("Hello!", "TM:mc2kebvfwr1p", "hello.wav").unwrap();
}
You may also stream the resulting audio directly to an audio playback library, such as rodio
:
use std::io::Cursor;
use rodio::{Decoder, OutputStream, source::Source, Sink};
use fakeyou;
fn main() {
// rodio setup
let (_stream, stream_handle) = OutputStream::try_default().unwrap();
let sink = Sink::try_new(&stream_handle).unwrap();
// actual API use
let fake_you = fakeyou::authenticate("user_name", "password").unwrap();
let bytes = fake_you.generate_bytes_from_token("Hello!", "TM:mc2kebvfwr1p").unwrap();
// play resulting audio
let cursor = Cursor::new(bytes);
let decoder = Decoder::new(cursor).unwrap();
sink.append(decoder);
sink.sleep_until_end();
}
Session token:
Once authenticated, your session token is valid for 20 years, so re-authenticating is practically unnecessary, however, re-caching may be necessary using FakeYouClient::invalidate_cache to keep the list of Category and Voice up to date.
Structs
- Representation of a category of voices
- An authenticated FakeYou client capable of making requests and directly downloading voice samples.
- Representation of a single voice
Enums
Functions
- Requests a FakeYouClient using a valid username and password