How zai-org/realvideo works
RealVideo is a WebSocket text-to-talking-video service. A browser client configures an avatar or cloned voice, sends text, and receives synchronized audio and generated frames. The sampled entry point assigns rank zero to the application and other ranks to DiT inference; the application handler queues speech and audio, while lip-sync coordinates audio conditioning, latent generation, VAE decoding and frame delivery. The graph includes the documented TTS, voice-cloning and real-time communication capabilities. Several implementation details are unsampled, so uncertain subsystem links are omitted.
Main entry points: lip_sync.py Lip-sync coordinator · wan_wrapper.py Wan diffusion wrapper · app_interface.py WebSocket application · causal_model_s2v.py Causal audio-video model
Components 26
Client interface
- WebSocket application
core/app_interface.py - Connection handling
core/connection.py - Session model handler
core/model_handler.py
Speech generation
- Text-to-speech
core/tts_pipeline.py - Voice cloning
core/voice_clone.py
Video synthesis
- Lip-sync coordinator
core/lip_sync.py - DiT inference service
core/dit_service.py
Distributed runtime
- Service entry
app.py - Service configuration
config/config.py - Sequence parallel state
self_forcing/utils/parallel_state.py - Rank communication
core/distributed.py - Parallel all-to-all
self_forcing/utils/all_to_all.py
Wan model internals
- Wan VAE wrapper
self_forcing/utils/wan_wrapper.py - Wan diffusion wrapper
self_forcing/utils/wan_wrapper.py - Causal audio-video model
self_forcing/wan/modules/causal_model_s2v.py - Wan transformer
self_forcing/wan/modules/model.py - Attention layers
self_forcing/wan/modules/attention.py - Audio encoder
self_forcing/wan/modules/audio_encoder.py - Audio utilities
self_forcing/wan/modules/audio_utils.py - Text encoder
self_forcing/wan/modules/t5.py - Image-text encoder
self_forcing/wan/modules/clip.py - Tokenizers
self_forcing/wan/modules/tokenizers.py - Flow-match scheduler
self_forcing/utils/scheduler.py - Diffusion solvers
self_forcing/wan/utils/fm_solvers.py
Other components
- Browser client
- GLM services
Connections 35
- Browser client → WebSocket application: opens session
README.md - WebSocket application → Session model handler: dispatches messages
core/app_interface.py - WebSocket application → Connection handling: uses connection
core/app_interface.py - Session model handler → Text-to-speech: starts speech tasks
core/model_handler.py - Session model handler → Lip-sync coordinator: forwards audio
core/model_handler.py - Session model handler → Voice cloning: supports cloning
core/app_interface.py - Browser client → WebSocket application: sends text
README.md - Text-to-speech → GLM services: requests speech
README.md - Lip-sync coordinator → DiT inference service: queues conditions
core/lip_sync.py - DiT inference service → Lip-sync coordinator: sends latent blocks
- Lip-sync coordinator → Wan VAE wrapper: decodes frames
core/lip_sync.py - Lip-sync coordinator → Audio encoder: encodes audio
core/lip_sync.py - Lip-sync coordinator → Text encoder: conditions prompts
core/lip_sync.py - Lip-sync coordinator → WebSocket application: streams frames
README.md - Service entry → Service configuration: loads settings
app.py - Service entry → Rank communication: launches ranks
app.py - Service entry → WebSocket application: starts rank zero
app.py - Service entry → DiT inference service: starts workers
app.py - Rank communication → Sequence parallel state: initializes groups
core/distributed.py - Rank communication → DiT inference service: transfers tensors
core/distributed.py - DiT inference service → Wan diffusion wrapper: runs inference
core/dit_service.py - Wan diffusion wrapper → Causal audio-video model: invokes model
self_forcing/utils/wan_wrapper.py - Wan diffusion wrapper → Wan transformer: uses transformer
self_forcing/utils/wan_wrapper.py - Wan diffusion wrapper → Wan VAE wrapper: uses VAE
self_forcing/utils/wan_wrapper.py - Wan diffusion wrapper → Flow-match scheduler: uses scheduler
self_forcing/utils/wan_wrapper.py - Wan diffusion wrapper → Tokenizers: uses tokenizers
self_forcing/utils/wan_wrapper.py - Causal audio-video model → Wan transformer: reuses components
self_forcing/wan/modules/causal_model_s2v.py - Causal audio-video model → Audio utilities: uses audio ops
self_forcing/wan/modules/causal_model_s2v.py - Causal audio-video model → Attention layers: uses attention
self_forcing/wan/modules/causal_model_s2v.py - Wan transformer → Attention layers: uses attention
self_forcing/wan/modules/model.py - Image-text encoder → Tokenizers: uses tokenizers
self_forcing/wan/modules/clip.py - Text encoder → Tokenizers: uses tokenizers
self_forcing/wan/modules/t5.py - Causal audio-video model → Sequence parallel state: uses sequence groups
self_forcing/wan/modules/causal_model_s2v.py - Wan transformer → Sequence parallel state: uses sequence groups
self_forcing/wan/modules/model.py - Wan transformer → Parallel all-to-all: redistributes tensors
self_forcing/wan/modules/model.py