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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
//! # VoiRS SDK
//!
//! Unified SDK and public API for VoiRS speech synthesis framework.
//!
//! VoiRS SDK provides a comprehensive, high-level interface for neural speech synthesis,
//! abstracting the complexity of G2P (Grapheme-to-Phoneme), acoustic modeling, and vocoding
//! into a simple, efficient API.
//!
//! ## Quick Start
//!
//! ```no_run
//! use voirs_sdk::prelude::*;
//!
//! #[tokio::main]
//! async fn main() -> Result<()> {
//! // Create a pipeline with default settings
//! let pipeline = VoirsPipelineBuilder::new()
//! .with_quality(QualityLevel::High)
//! .with_voice("default")
//! .build()
//! .await?;
//!
//! // Synthesize speech
//! let audio = pipeline.synthesize("Hello, world!").await?;
//!
//! // Save to file
//! audio.save_wav("output.wav")?;
//!
//! Ok(())
//! }
//! ```
//!
//! ## Key Features
//!
//! - **Simple API**: High-level interface for speech synthesis
//! - **Async/Concurrent**: Built for modern async Rust applications
//! - **Streaming**: Real-time synthesis with low latency
//! - **Plugin System**: Extensible audio effects and processing
//! - **Caching**: Intelligent model and result caching
//! - **Quality Control**: Comprehensive audio quality validation
//! - **Performance**: Optimized for both speed and memory efficiency
//!
//! ## Architecture
//!
//! The VoiRS SDK consists of several key components:
//!
//! - [`VoirsPipeline`]: Main synthesis pipeline
//! - [`VoirsPipelineBuilder`]: Fluent API for pipeline configuration
//! - [`AudioBuffer`]: Audio data management and processing
//! - [`streaming`]: Real-time synthesis capabilities
//! - [`plugins`]: Extensible effects system
//! - [`cache`]: Intelligent caching system
//!
//! ## Examples
//!
//! ### Basic Synthesis
//!
//! ```no_run
//! use voirs_sdk::prelude::*;
//!
//! #[tokio::main]
//! async fn main() -> Result<()> {
//! let pipeline = VoirsPipelineBuilder::new().build().await?;
//! let audio = pipeline.synthesize("Hello, world!").await?;
//! audio.save_wav("hello.wav")?;
//! Ok(())
//! }
//! ```
//!
//! ### Streaming Synthesis
//!
//! ```no_run
//! use voirs_sdk::prelude::*;
//! use futures::StreamExt;
//!
//! #[tokio::main]
//! async fn main() -> Result<()> {
//! let pipeline = Arc::new(VoirsPipelineBuilder::new().build().await?);
//!
//! let mut stream = pipeline.synthesize_stream(
//! "This is a longer text that will be synthesized in real-time."
//! ).await?;
//!
//! while let Some(chunk) = stream.next().await {
//! let audio_chunk = chunk?;
//! // Process audio chunk in real-time
//! println!("Received {} samples", audio_chunk.len());
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! ### Voice Management
//!
//! ```no_run
//! use voirs_sdk::prelude::*;
//!
//! #[tokio::main]
//! async fn main() -> Result<()> {
//! let pipeline = VoirsPipelineBuilder::new()
//! .with_voice("female_voice")
//! .build()
//! .await?;
//!
//! // List available voices
//! let voices = pipeline.list_voices().await?;
//! for voice in voices {
//! println!("Available voice: {} ({})", voice.name, voice.language);
//! }
//!
//! // Switch voice at runtime
//! pipeline.set_voice("male_voice").await?;
//! let audio = pipeline.synthesize("Speaking with a different voice").await?;
//!
//! Ok(())
//! }
//! ```
//!
//! ### Advanced Configuration
//!
//! ```no_run
//! use voirs_sdk::prelude::*;
//!
//! #[tokio::main]
//! async fn main() -> Result<()> {
//! let pipeline = VoirsPipelineBuilder::new()
//! .with_quality(QualityLevel::High)
//! .with_gpu_acceleration(true)
//! .with_threads(4)
//! .build()
//! .await?;
//!
//! let audio = pipeline.synthesize("High quality synthesis!").await?;
//! audio.save_wav("quality_output.wav")?;
//!
//! Ok(())
//! }
//! ```
//!
//! ### Configuration and Quality Control
//!
//! ```no_run
//! use voirs_sdk::prelude::*;
//! use std::path::PathBuf;
//!
//! #[tokio::main]
//! async fn main() -> Result<()> {
//! let pipeline = VoirsPipelineBuilder::new()
//! .with_quality(QualityLevel::High)
//! .with_threads(4)
//! .with_cache_dir(PathBuf::from("/tmp/voirs-cache"))
//! .build()
//! .await?;
//!
//! let audio = pipeline.synthesize("High quality synthesis").await?;
//!
//! // Access audio properties
//! println!("Sample rate: {} Hz", audio.sample_rate());
//! println!("Duration: {:.2} seconds", audio.duration());
//!
//! Ok(())
//! }
//! ```
//!
//! ## Performance
//!
//! The VoiRS SDK is designed for high performance:
//!
//! - **Initialization**: ≤ 2 seconds (cold start with model download)
//! - **Synthesis Latency**: ≤ 100ms overhead per synthesis
//! - **Memory Usage**: ≤ 50MB SDK overhead
//! - **Real-time Factor**: ≤ 0.5 (synthesis faster than playback)
//! - **Concurrent Operations**: 100+ simultaneous operations supported
//!
//! ## Error Handling
//!
//! All operations return [`Result<T, VoirsError>`](VoirsError) for comprehensive error handling:
//!
//! ```no_run
//! use voirs_sdk::prelude::*;
//!
//! #[tokio::main]
//! async fn main() {
//! match VoirsPipelineBuilder::new().build().await {
//! Ok(pipeline) => {
//! match pipeline.synthesize("Hello!").await {
//! Ok(audio) => println!("Success! {} samples", audio.len()),
//! Err(e) => eprintln!("Synthesis error: {}", e),
//! }
//! }
//! Err(e) => eprintln!("Pipeline creation error: {}", e),
//! }
//! }
//! ```
//!
//! ## Feature Flags
//!
//! - `gpu`: Enable GPU acceleration for models
//! - `onnx`: Enable ONNX runtime support
//! - `default`: Standard CPU-based processing
//!
//! ## Platform Support
//!
//! - **Operating Systems**: Linux, macOS, Windows
//! - **Architectures**: x86_64, ARM64
//! - **Runtimes**: Tokio async runtime required
// Allow pedantic lints that are acceptable for audio/DSP processing code
// Acceptable for audio sample conversions
// Controlled truncation in audio processing
// Intentional in index calculations
// Many internal functions with self-documenting error types
// Panics are documented where relevant
// Some trait implementations require &self for consistency
// Not all return values need must_use annotation
// Technical terms don't all need backticks
// Result wrappers maintained for API consistency
// Exact float comparisons are intentional in some contexts
// Pattern matching clarity sometimes requires duplication
// Type names often repeat module names
// Config structs naturally have many boolean flags
// Some functions are inherently complex
// Some functions designed for ownership transfer
// Many similar variable names in algorithms
// Public API functions may need async for consistency
// Range loops sometimes clearer than iterators
// Explicit argument names can improve clarity
// Manual clamping sometimes clearer
// Not all builder methods need must_use
// Controlled wrapping in processing code
// Explicit casts preferred for clarity
// Prelude imports are convenient and standard
// Sometimes more readable than alternative
// Closures sometimes needed for type inference
// Some functions naturally need many parameters
// Sometimes clearer than builder pattern
// API consistency more important
// Controlled lock holding in async contexts
// Advanced voice features
// Web Integration modules
// Cloud Integration modules
// Re-export core types and traits
pub use ;
pub use AudioBuffer;
pub use VoirsPipelineBuilder;
pub use CapabilityManager;
pub use ;
pub use VoirsError;
pub use PerformanceMonitor;
pub use VoirsPipeline;
pub use ;
pub use *;
// Advanced voice features re-exports
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
/// Result type alias for VoiRS operations
pub type Result<T> = Result;