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
//! # Gradium Rust Client
//!
//! A Rust client library for the Gradium API, providing text-to-speech (TTS) capabilities
//! via WebSocket connections.
//!
//! ## Quick Start
//!
//! ```no_run
//! use gradium::{Client, protocol::tts::Setup, protocol::AudioFormat};
//!
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! let api_key = gradium::api_key_from_env().expect("GRADIUM_API_KEY not set");
//! let client = Client::new(&api_key);
//!
//! let setup = Setup::new("m86j6D7UZpGzHsNu").with_output_format(AudioFormat::Wav);
//!
//! let result = gradium::tts("Hello, world!", setup, &client).await?;
//! let filename = "output.wav";
//! std::fs::write(filename, result.raw_data())?;
//! println!("Generated {} bytes of audio and saved to {}", result.raw_data().len(), filename);
//! Ok(())
//! }
//! ```
//!
//! ## Features
//!
//! - **Simple API**: High-level `tts()` function for one-shot text-to-speech conversion
//! - **Streaming Support**: `TtsStream` for advanced use cases with real-time audio streaming
//! - **Multiple Formats**: Support for PCM, WAV, and Opus audio formats
//! - **Async/Await**: Built on tokio for efficient async I/O
//!
//! ## Environment Configuration
//!
//! The client expects the `GRADIUM_API_KEY` environment variable to be set with your API key.
//! You can retrieve it using the [`api_key_from_env()`] function.
pub use Client;
pub use ;
pub use ;
/// Represents text with associated timing information.
///
/// This structure is returned as part of TTS results to provide timing data
/// for the generated audio segments.
/// Retrieves the Gradium API key from the `GRADIUM_API_KEY` environment variable.
///
/// # Returns
///
/// `Some(String)` if the environment variable is set, `None` otherwise.
///
/// # Example
///
/// ```no_run
/// let api_key = gradium::api_key_from_env().expect("GRADIUM_API_KEY not set");
/// ```
/// Retrieves the Gradium base URL from the `GRADIUM_BASE_URL` environment variable.
///
/// # Returns
///
/// `Some(String)` if the environment variable is set, `None` otherwise.
///
/// # Example
///
/// ```no_run
/// let base_url = gradium::base_url_from_env();
/// ```