1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#![warn(unused_crate_dependencies)]
#![forbid(unsafe_code)]
#![warn(clippy::all)]

//!<div align="center">
//! <!-- Build -->
//! <img src="https://img.shields.io/github/actions/workflow/status/alexjercan/fakeyou-api/rust.yml?style=flat-square"
//! alt="Github Worflow Status" />
//! <!-- Version -->
//! <a href="https://crates.io/crates/fakeyou-api">
//!   <img src="https://img.shields.io/crates/v/fakeyou-api?style=flat-square"
//!   alt="Crates.io version" />
//! </a>
//! <!-- Docs -->
//! <a href="https://docs.rs/fakeyou-api">
//!   <img src="https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square"
//!     alt="docs.rs docs" />
//! </a>
//! <!-- Downloads -->
//! <a href="https://crates.io/crates/fakeyou-api">
//!   <img src="https://img.shields.io/crates/d/fakeyou-api?style=flat-square"
//!     alt="Crates.io downloads" />
//! </a>
//! <!-- License -->
//! <a href="https://github.com/alexjercan/fakeyou-api/blob/master/LICENSE">
//!   <img src="https://img.shields.io/github/license/alexjercan/fakeyou-api?style=flat-square"
//!     alt="Crates.io downloads" />
//! </a>
//!</div>
//!
//! A very simple Rust library for FakeYou API.
//!
//! ## API
//!
//! Check the [official](https://docs.fakeyou.com/) API reference.
//!
//! |API|Support|
//! |---|---|
//! |Text to Speech|✔️|
//! |Voices|❌|
//! |Categories|❌|
//!
//! ## Usage
//!
//! 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:
//!
//! ```no_run
//! # fn main() {
//! // Import the dependencies
//! // Import the dependencies
//! use fakeyou_api::{
//!     tts::{InferenceBody, TtsApi, TtsJobStatus},
//!     *,
//! };
//!
//! // 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 {
//!     tts_model_token: "TM:ebgxj0j4fvzp".to_string(),
//!     inference_text: "Hello, World! What should we do today?".to_string(),
//!     uuid_idempotency_token: None,
//! };
//!
//! // Call the TTS API
//! let inference_result = fakeyou.tts_inference(&inference_body).unwrap();
//!
//! // Print the result
//! println!("{:?}", inference_result);
//!
//! loop {
//!     // Call the TTS API
//!     let job_result = fakeyou.tts_job(&inference_result.inference_job_token).unwrap();
//!
//!     // Check if the job is done
//!     match job_result.state.status {
//!         TtsJobStatus::Pending => {
//!             println!("Job is pending");
//!         }
//!         TtsJobStatus::Started => {
//!             println!("Job is started");
//!         }
//!         TtsJobStatus::AttemptFailed => {
//!             println!("Job attempt failed. Trying again...");
//!         }
//!         TtsJobStatus::CompleteSuccess => {
//!             println!("Job completed successfully");
//!             let output_result = fakeyou.tts_output(&job_result.state.maybe_public_bucket_wav_audio_path.unwrap()).unwrap();
//!
//!             // Do what you need with the audio file
//!             std::fs::write("output.wav", output_result.bytes).unwrap();
//!
//!             break;
//!         }
//!         _ => {
//!             println!("Job failed");
//!
//!             break;
//!         }
//!     }
//!
//!     // Wait 1 second before trying again
//!     std::thread::sleep(std::time::Duration::from_secs(1));
//! }
//! # }
//! ```
//!
//! ## License
//! This project is licensed under MIT
//!

pub mod apis;
pub use apis::*;

pub mod fakeyou;
pub use fakeyou::*;

pub mod error;
pub use error::*;

pub mod util;