subx_cli/services/
mod.rs

1//! External services integration for SubX.
2//!
3//! This module provides comprehensive integration with external services that power
4//! SubX's intelligent subtitle processing capabilities. It serves as the abstraction
5//! layer between SubX's core processing engines and external AI providers, audio
6//! analysis libraries, and other third-party services.
7//!
8//! # Architecture Overview
9//!
10//! The services layer follows a provider pattern with standardized interfaces:
11//! - **Service Abstraction**: Common traits for different service types
12//! - **Multiple Providers**: Support for different AI and audio processing backends
13//! - **Async Integration**: Non-blocking service calls with proper error handling
14//! - **Resource Management**: Connection pooling, rate limiting, and caching
15//! - **Failover Support**: Automatic fallback between different service providers
16//!
17//! # Service Categories
18//!
19//! ## AI Services (`ai` module)
20//! Intelligent content analysis and matching services:
21//! - **Content Analysis**: Video and subtitle content understanding
22//! - **Semantic Matching**: AI-powered file pairing with confidence scoring
23//! - **Language Detection**: Automatic language identification and verification
24//! - **Quality Assessment**: Content quality evaluation and recommendations
25//! - **Multi-Provider Support**: OpenAI, Anthropic, and other AI service backends
26//!
27//! ## Audio Processing (`audio` module)
28//! Advanced audio analysis and synchronization services:
29//! - **Dialogue Detection**: Speech segment identification and timing
30//! - **Audio Feature Extraction**: Waveform analysis and acoustic features
31//! - **Synchronization Analysis**: Audio-subtitle timing correlation
32//! - **Voice Activity Detection**: Speech vs. silence classification
33//! - **Multi-Language Support**: Language-specific audio processing models
34//!
35//! # Usage Patterns
36//!
37//! ## AI-Powered Matching
38//! ```rust,ignore
39//! use subx_cli::services::ai::{AIClientFactory, AnalysisRequest};
40//!
41//! async fn intelligent_matching() -> subx_cli::Result<()> {
42//!     let ai_client = AIClientFactory::create_client("openai").await?;
43//!     
44//!     let request = AnalysisRequest {
45//!         video_files: vec!["movie.mp4".to_string()],
46//!         subtitle_files: vec!["subs1.srt".to_string(), "subs2.srt".to_string()],
47//!         content_samples: vec![/* content samples */],
48//!     };
49//!     
50//!     let result = ai_client.analyze_content(request).await?;
51//!     println!("Best match confidence: {}", result.confidence);
52//!     Ok(())
53//! }
54//! ```
55//!
56//! ## Audio Synchronization
57//! ```rust,ignore
58//! use subx_cli::services::audio::AudioTranscoder;
59//!
60//! async fn synchronize_audio() -> subx_cli::Result<()> {
61//!     let transcoder = AudioTranscoder::new()?;
62//!     
63//!     let wav_path = transcoder.transcode_to_wav("video.mp4").await?;
64//!     
65//!     // Process audio for synchronization
66//!     println!("Audio transcoded to: {}", wav_path.display());
67//!     
68//!     Ok(())
69//! }
70//! ```
71//!
72//! # Performance Considerations
73//!
74//! - **Caching Strategy**: Aggressive caching of AI analysis results and audio features
75//! - **Async Processing**: Non-blocking service calls with concurrent processing
76//! - **Resource Pooling**: Connection and compute resource management
77//! - **Rate Limiting**: Built-in rate limiting for external API compliance
78//! - **Memory Efficiency**: Streaming processing for large audio files
79//!
80//! # Error Handling
81//!
82//! All services use standardized error handling with automatic retry logic:
83//! - **Network Failures**: Automatic retry with exponential backoff
84//! - **Service Unavailability**: Graceful fallback to alternative providers
85//! - **Rate Limiting**: Intelligent backoff and queue management
86//! - **Data Validation**: Input validation and sanitization
87//!
88//! # Configuration
89//!
90//! Services are configured through SubX's unified configuration system:
91//! - API credentials and endpoints
92//! - Performance tuning parameters
93//! - Provider priority and fallback rules
94//! - Caching and resource limits
95//!
96//! # Modules
97//!
98//! - [`ai`] - AI service providers for content analysis and intelligent matching
99//! - [`audio`] - Audio processing and synchronization analysis utilities
100#![allow(dead_code)]
101
102pub mod ai;
103pub mod audio;
104
105// VAD service modules
106pub mod vad;