StreamFlow: Streaming Flow Matching with Block-wise Guided Attention Mask for Speech Token Decoding

Dake Guo, Jixun Yao, Linhan Ma, He Wang, Lei XiearXiv 2025 · DOI

Abstract

StreamFlow is a novel neural architecture designed for high-quality, real-time streaming speech synthesis. By leveraging Diffusion Transformers (DiT) and Conditional Flow Matching (CFM), the model addresses the traditional trade-offs between latency, computational efficiency, and audio quality. Through the introduction of a hierarchical "block-wise guided attention mask," StreamFlow achieves a first-packet latency of 180ms and maintains stable inference speeds for long sequences, delivering audio quality that rivals non-streaming state-of-the-art methods.

Introduction

Recent advancements in speech AI, such as GPT-4o, utilize "Codec-LMs" to predict discrete speech tokens. However, the subsequent step—decoding these tokens into high-fidelity audio in real-time—remains a significant challenge. Conditional Flow Matching (CFM) has emerged as a leading technique for producing natural-sounding speech, but it typically requires a global receptive field, making it difficult to implement in streaming scenarios.

Existing streaming decoders often suffer from two primary issues: quality degradation due to phase conflicts in purely causal models, and efficiency bottlenecks where inference time increases linearly with sequence length. StreamFlow overcomes these hurdles by localizing the attention mechanism within the DiT framework.

Architecture and Methods

StreamFlow replaces the standard global attention in Diffusion Transformers with a localized, block-based approach. The model consists of a 22-layer DiT that processes semantic tokens, speaker embeddings, and diffusion timesteps to predict mel-spectrograms, which are then converted to 24kHz waveforms using a BigVGAN vocoder.

The StreamFlow architecture utilizes a DiT-based backbone with hierarchical masking to process semantic tokens and speaker embeddings into high-fidelity audio via BigVGAN.

Block-wise Guided Attention Masks

The core innovation of StreamFlow is the use of three distinct attention masks to manage the flow of information across blocks of tokens:

  • Block Mask: Isolates a block, preventing it from attending to any other tokens.
  • Backward Mask: Allows a block to attend to the preceding block, providing necessary historical context.
  • Forward Mask: Enables a block to attend to the subsequent block, offering a limited "look-ahead" into the future.

By strategically distributing these masks across the 22 layers of the DiT, the researchers can precisely tune the model's receptive field. For instance, the "Large Receptive field" (LR) configuration allows each block to perceive two blocks of past and future context, significantly improving prosodic consistency and acoustic detail.

The three primary masking strategies: Block Mask for isolation, Backward Mask for historical context, and Forward Mask for limited future look-ahead.

Sliding Window Inference

To ensure real-time performance, StreamFlow employs a sliding window inference strategy. Unlike traditional causal models where the attention matrix grows with the sequence, StreamFlow maintains a fixed context size. This results in constant time complexity per chunk, ensuring that latency does not spike during long-form speech generation.

Experimental Setup and Results

The model was trained on the Emilia Dataset, comprising 100,000 hours of diverse Chinese and English speech. Semantic tokens were extracted at 25Hz using the S3tokenizer. Evaluation was conducted on 100 sentences from unseen speakers using both objective metrics (PESQ, STOI, ViSQOL) and subjective human listening tests (NMOS/SMOS).

Key Findings

  • Latency and Stability: StreamFlow achieved a first-packet latency of 180ms. Crucially, this latency remains stable throughout the generation process, unlike baseline models where latency increases over time.
  • The Importance of Future Context: Results indicated that purely causal streaming (only looking at the past) leads to significant quality loss. Allowing the model to see just one or two blocks into the future brings audio quality near non-streaming levels.
  • Audio Quality: In subjective tests, the StreamFlow-LR variant achieved an NMOS of 4.153, nearly matching the non-streaming DiT-CV score of 4.213 and outperforming other streaming baselines.

Conclusion

StreamFlow demonstrates that high-quality streaming speech synthesis is achievable by combining Flow Matching with hierarchical block-wise attention. By maintaining a constant computational cost and providing a tunable balance between latency and quality, StreamFlow offers a robust solution for the next generation of interactive AI agents. Future work will explore the joint optimization of LLM token predictors with the StreamFlow decoder and further model compression for edge device deployment.

Summary updated

BibTeX
@misc{guo2025streamflow,
  author = {Dake Guo and Jixun Yao and Linhan Ma and He Wang and Lei Xie},
  title = {{StreamFlow: Streaming Flow Matching with Block-wise Guided Attention Mask for Speech Token Decoding}},
  year = {2025},
  eprint = {2506.23986},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2506.23986},
}
Figure