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::core::ComponentFactory;
40//! use subx_cli::config::ProductionConfigService;
41//! use std::sync::Arc;
42//!
43//! async fn intelligent_matching() -> subx_cli::Result<()> {
44//!     let config_service = Arc::new(ProductionConfigService::new()?);
45//!     let factory = ComponentFactory::new(config_service.as_ref())?;
46//!     let ai_client = factory.create_ai_provider()?;
47//!     
48//!     // AI client is ready to use for analysis
49//!     println!("AI client created successfully");
50//!     Ok(())
51//! }
52//! ```
53//!
54//! ## Audio Synchronization
55//! ```rust,ignore
56//! use subx_cli::services::vad::LocalVadDetector;
57//! use subx_cli::config::VadConfig;
58//!
59//! async fn synchronize_audio() -> subx_cli::Result<()> {
60//!     let vad_config = VadConfig::default();
61//!     let detector = LocalVadDetector::new(vad_config)?;
62//!
63//!     // Directly process various audio formats without transcoding
64//!     let result = detector.detect_speech("video.mp4").await?;
65//!
66//!     println!("Detected {} speech segments", result.speech_segments.len());
67//!     Ok(())
68//! }
69//! ```
70//!
71//! # Performance Considerations
72//!
73//! - **Caching Strategy**: Aggressive caching of AI analysis results and audio features
74//! - **Async Processing**: Non-blocking service calls with concurrent processing
75//! - **Resource Pooling**: Connection and compute resource management
76//! - **Rate Limiting**: Built-in rate limiting for external API compliance
77//! - **Memory Efficiency**: Streaming processing for large audio files
78//!
79//! # Error Handling
80//!
81//! All services use standardized error handling with automatic retry logic:
82//! - **Network Failures**: Automatic retry with exponential backoff
83//! - **Service Unavailability**: Graceful fallback to alternative providers
84//! - **Rate Limiting**: Intelligent backoff and queue management
85//! - **Data Validation**: Input validation and sanitization
86//!
87//! # Configuration
88//!
89//! Services are configured through SubX's unified configuration system:
90//! - API credentials and endpoints
91//! - Performance tuning parameters
92//! - Provider priority and fallback rules
93//! - Caching and resource limits
94//!
95//! # Modules
96//!
97//! - [`ai`] - AI service providers for content analysis and intelligent matching
98//! - [`audio`] - Audio processing and synchronization analysis utilities
99#![allow(dead_code)]
100
101pub mod ai;
102pub mod audio;
103
104// VAD service modules
105pub mod vad;