How juanmc2005/diart works
Main System Components
a. Audio Sources
• FileAudioSource (pre‐recorded WAV)
• MicrophoneAudioSource (live capture via sounddevice/portaudio)
• WebSocketAudioSource (client/server over websockets)
b. Core Pipeline Blocks
• SegmentationModel (ONNX/PyTorch)
• EmbeddingModel (ONNX/PyTorch)
• Overlap-Aware Segmentation & SpeakerEmbedding (blocks)
• Incremental Clustering (diarization algorithm)
c. Streaming & Control
• StreamingInference (RxPY-powered observer pattern)
• CLI entry points (diart.stream, diart.tune, diart.benchmark, diart.serve, diart.client)
• Optimizer (Optuna based hyper-parameter tuner)
d. Outputs & Observers
• RTTMWriter (write diarization results)
• WebSocketAudioSource.send (stream RTTM back to client)
• Benchmark & evaluation modules
Relationships & Data Flow
a. Audio Source → StreamingInference → Pipeline Blocks → Observer Sinks
b. CLI & Configuration
• diart.stream / diart.serve instantiate StreamingInference with config (sample_rate, step, latency)
• diart.tune → Optimizer → repeatedly run Benchmark on offline datasets
• diart.benchmark / diart.inference.Benchmark → uses same pipeline blocks in batch mode
Architectural Patterns & Principles
• Modular Blocks: each functionality (segmentation, embedding, clustering) is a self-contained “block” in src/diart/blocks
• Reactive Streams: StreamingInference uses RxPY to implement a push-based dataflow (operators in diart.operators)
• Adapter Pattern: SegmentationModel/EmbeddingModel wrap third-party models (PyTorch/ONNX) behind a unified API
• Observer Pattern: sinks (RTTMWriter, WebSocketAudioSource) attach to inference to receive results
• CLI-driven extensibility: console commands in src/diart/console orchestrate pipelines, tuning, serving
Putting It All Together
– From StreamingInference, branch into the AI pipeline: SegmentationModel → EmbeddingModel → Incremental Clustering.
– Collect outputs into “Observers” on the right (RTTMWriter, WebSocket send, Benchmark).
– Above or below, show CLI commands invoking the same pipeline with different configs.