Vococo

BERT-style Flow Matching
for Singing Voice Pitch Restoration

给一段唱得略不准的人声,用户在编辑器里把若干音符的 F0 拖到想要的位置; 系统先用传统 DSP(这里是 WORLD)做一次粗糙渲染,再由神经网络在 STFT 域上把它修复成自然的歌声。

Abstract

本页所有结果对应代码仓库的 v5.2 版本(epoch 24 中间产出)。 代码位于 github.com/Da1sypetals/sar-archive

商业人声音高编辑工具(如 Melodyne)的核心交互是:把音频以"音符块"的形式呈现在钢琴卷帘上, 用户可以单独拖动一个音符的中心音高、重绘 F0 曲线、压缩拉伸时长。 我想尝试做的事情是用神经网络去替换内部那个"把被你拖过的音符渲染回音频"的引擎。

这个任务从监督学习的角度看缺乏配对数据——没有人会为同一段演唱录两版(一版走音、一版精修)。 我们的做法是:先用传统 DSP(WORLD)对要被修改的段做一次粗糙的变调, 再把整段被破坏 / 局部干净的混合音频送进网络进行 BERT 风格的 masked 修复。 从噪声分布通过 flow matching 在 STFT 表示 (mag0.3, cos φ, sin φ) 上积分到 clean 频谱,masked 帧重新生成、context 帧锁死保持原样。

Method (briefly)

Representation

STFT (n_fft = 2048, hop = 512, sr = 44100),取前 1024 个频点。 每个 TF bin 表示成 (A0.3, cos φ, sin φ) 三通道, 避免 phase wrapping,又避免 (Re, Im) 在低能量区不稳定。

BERT-style mask

把 8 秒序列切成 context 帧(用户没动过、保留 clean)和 masked 帧(用户拖过的音符所覆盖)。 模型在 masked 帧上重新生成 STFT,可以双向看到两侧 context 的真实干净频谱。

Flow Matching

线性路径 zt = (1−t)·z0 + t·z1, velocity target v = z1 − z0。 z0:mag 通道标准正态,phase 通道在单位圆内截断的二维高斯(σ ≈ 0.4,半径 1.125 截断)。 loss 只在 masked 帧上累加。

DSP corruption

训练数据由 WORLD 整段 analyze-synthesize 得到 artifact, masked 区间用 artifact 替换、其余保留 clean,时域边界做 ~6 ms crossfade。 5 % identity 样本 (artifact = clean) 教模型"已经是好的就别动"。

Network

Hierarchical U-Net Transformer。 频率轴用 Perceiver cross-attention 做 1024 → 128 → 64 的下采样, 时间轴用 strided conv;bottleneck 才有 time attention,浅层只有 time depthwise conv。 F0 通过 harmonic Gaussian encoding 在第 0 / 最后一层 concat 进 attention。

Inference

从 z0 Euler 积分 20 步到 z1, masked 帧逐步从噪声推到 clean,context 帧始终锁定 z1。 最终拼回 ISTFT 输出波形。

Architecture

Hierarchical U-Net Transformer。频率轴用 Perceiver cross-attention 做 1024 → 128 → 64 的逐级压缩; 时间轴用 stride-2 Conv1d 下采样、interpolate ×2 上采样。 浅层用 LocalBlock(freq full attn + time depthwise conv),bottleneck 用 GlobalBlock(freq + time 双轴 attention)。 timestep t 通过 AdaLN-Zero 注入每个 block;F0 仅在 Level 0 通过 harmonic Gaussian 编码后 concat 到 attention 的 Q/K/V 输入。

Input z_t ⊕ artifact ⊕ mask · 7ch × 1024 × T Output predicted velocity v̂ · 3ch × 1024 × T Encoder Level 0 2× LocalBlock D=256 · F=1024 Decoder Level 0 2× LocalBlock D=256 · F=1024 Encoder Level 1 2× LocalBlock D=384 · F=128 Decoder Level 1 2× LocalBlock D=384 · F=128 Bottleneck 4× GlobalBlock · freq + time attention D=512 · F=64 · T=65 Perceiver freq 1024→128 + Conv1d stride 2 (time) Perceiver freq 128→64 + Conv1d stride 2 (time) Perceiver freq 64→128 + Time interp ×2 Perceiver freq 128→1024 + Time interp ×2 U-Net skip · concat + linear U-Net skip · concat + linear F0 → harmonic enc F0 → harmonic enc Conditioning injected into every block timestep t → sinusoidal embedding → MLP → AdaLN-Zero (shift / scale / gate per block, per axis) F0 (per frame) → harmonic Gaussian encoding (16 harmonics × 1024 bins) → channel concat into Q/K/V at Level 0 only
训练时模型把 input 映射到 velocity field ;推理时按 ODE Euler 步在 masked 帧上从 z0 积分到 z1, context 帧始终锁定 z1,最终拼回 ISTFT 输出波形。

Local Block

Encoder / Decoder Level 0 & 1 · 频率 full attention + 时间局部卷积,无时间 attention

Input x · [B, D, F, T] residual Freq Self-Attention (+ F0 harmonic) AdaLN-Zero(t) · RoPE · gate(t) residual Time Depthwise Conv (k=15, GLU) AdaLN-Zero(t) · gate(t) residual Feed-Forward (SiLU, ×4) AdaLN-Zero(t) · gate(t) Output · [B, D, F, T]

Global Block

Bottleneck Level 2 · 频率 + 时间双轴 attention,时间卷积取直连残差

Input x · [B, D, F, T] residual Freq Self-Attention AdaLN-Zero(t) · RoPE · gate(t) residual Time Self-Attention AdaLN-Zero(t) · RoPE · gate(t) residual Time Depthwise Conv (k=15, GLU) plain residual · 无 AdaLN · 无 gate residual Feed-Forward (SiLU, ×4) AdaLN-Zero(t) · gate(t) Output · [B, D, F, T]

Audio Samples

每段 8 秒,44.1 kHz。每行三个播放器: Original 是 clean ground truth; Mixed (input) 是送进模型的输入——masked 区间被 WORLD 整段 analyze-synthesize 后的 artifact 替换、unmasked 区间保留 clean, 边界做 256 samples 的 crossfade; Restored (ours) 是模型在 masked 区间上从噪声 ODE 积分 20 步得到的输出,再和 unmasked 的 clean STFT 拼回 ISTFT。 pipeline 图展示了 transition 区间(DSP envelope 拐点)和实际 mask 选取后的帧级覆盖。

数据没有 cherry-pick。下面 18 段就是训练时 epoch 24 的 evaluation set 全部样本,按数据集分组原样放出来—— 每个 dataset 各取 3 段,覆盖中文 studio、中文翻唱、中文网络爬取、日语男 / 女声等不同来源。

Original (clean target) Mixed (input to network) Restored (ours)

OpenCpop · 中文女声 studio recording

#00 opencpop / 2098.wav · @ 209.8 s mask 59 % · 5 segments
Pipeline visualizationpipeline
#01 opencpop / 2099.wav · @ 135.6 s mask 43 % · 4 segments
Pipeline visualizationpipeline
#02 opencpop / 2100.wav · @ 22.6 s mask 33 % · 5 segments
Pipeline visualizationpipeline

OpenSinger · 中文多歌手

#03 9_爱的供养 / 9_爱的供养_7.wav · @ 4.9 s mask 54 % · 5 segments
Pipeline visualizationpipeline
#04 9_空白格 / 9_空白格_19.wav · @ 4.2 s mask 65 % · 6 segments
Pipeline visualizationpipeline
#05 9_遇见你的时候所有星星都落在我头上 / 9_遇见你的时候所有星星都落在我头上_10.wav · @ 5.6 s mask 23 % · 4 segments
Pipeline visualizationpipeline

Itako · 日语女声

#06 split / itako48_01.wav · @ 4.0 s mask 47 % · 7 segments
Pipeline visualizationpipeline
#07 split / itako49_00.wav · @ 16.3 s mask 42 % · 4 segments
Pipeline visualizationpipeline
#08 split / itako50_03.wav · @ 8.3 s mask 30 % · 3 segments
Pipeline visualizationpipeline

PJS · 日语男声

#09 split / pjs097_song_00.wav · @ 8.3 s mask 44 % · 4 segments
Pipeline visualizationpipeline
#10 split / pjs098_song_00.wav · @ 5.3 s mask 26 % · 3 segments
Pipeline visualizationpipeline
#11 split / pjs100_song_00.wav · @ 4.8 s mask 62 % · 6 segments
Pipeline visualizationpipeline

Bilibili 网络爬取 · 中文清唱

#12 bili / 小可_歌行四方_seg003.wav · @ 27.9 s mask 31 % · 4 segments
Pipeline visualizationpipeline
#13 bili / 清唱1_seg001.wav · @ 68.6 s mask 33 % · 4 segments
Pipeline visualizationpipeline
#14 bili / 清唱2_seg001.wav · @ 17.3 s mask 33 % · 3 segments
Pipeline visualizationpipeline

CCMusic · 中文流行翻唱

#15 YYH_月亮代表我的心 / YYH_月亮代表我的心_seg001.wav · @ 24.5 s mask 50 % · 4 segments
Pipeline visualizationpipeline
#16 YYH_甜蜜蜜 / YYH_甜蜜蜜_seg001.wav · @ 66.7 s mask 33 % · 6 segments
Pipeline visualizationpipeline
#17 YYH_至少还有你 / YYH_至少还有你_seg001.wav · @ 40.1 s mask 41 % · 6 segments
Pipeline visualizationpipeline
Previous checkpoint · 3-second samples (epoch 17)

早期实验阶段的输出,每段 3 秒。模型容量、mask 策略、训练数据均与上面 epoch 24 一致; 区别主要在训练步数、序列长度(3 → 8 秒)和若干超参。这里保留下来作为对照。

OpenCpop · 中文女声 studio recording

#00 opencpop / 2098.wav · @ 175.7 s mask 59 % · 4 segments
Pipeline visualizationpipeline
#01 opencpop / 2099.wav · @ 46.0 s mask 41 % · 2 segments
Pipeline visualizationpipeline
#02 opencpop / 2100.wav · @ 23.5 s mask 39 % · 2 segments
Pipeline visualizationpipeline

OpenSinger · 中文多歌手

#03 9_追光者 / 9_追光者_38.wav · @ 1.6 s mask 39 % · 3 segments
Pipeline visualizationpipeline
#04 9_遇见你的时候所有星星都落在我头上 / 9_遇见你的时候所有星星都落在我头上_17.wav · @ 1.8 s mask 39 % · 2 segments
Pipeline visualizationpipeline
#05 9_遥不可及的你 / 9_遥不可及的你_0.wav · @ 2.0 s mask 27 % · 2 segments
Pipeline visualizationpipeline

Itako · 日语女声

#06 split / itako48_01.wav · @ 17.9 s mask 23 % · 2 segments
Pipeline visualizationpipeline
#07 split / itako49_00.wav · @ 10.0 s mask 23 % · 2 segments
Pipeline visualizationpipeline
#08 split / itako50_01.wav · @ 3.3 s mask 28 % · 2 segments
Pipeline visualizationpipeline

PJS · 日语男声

#09 split / pjs098_song_00.wav · @ 8.7 s mask 48 % · 4 segments
Pipeline visualizationpipeline
#10 split / pjs099_song_00.wav · @ 3.0 s mask 51 % · 3 segments
Pipeline visualizationpipeline
#11 split / pjs100_song_00.wav · @ 3.4 s mask 41 % · 3 segments
Pipeline visualizationpipeline

Bilibili 网络爬取 · 中文清唱

#12 bili / 小可_歌行四方_seg003.wav · @ 32.7 s mask 55 % · 4 segments
Pipeline visualizationpipeline
#13 bili / 清唱1_seg001.wav · @ 41.2 s mask 65 % · 5 segments
Pipeline visualizationpipeline
#14 bili / 清唱2_seg001.wav · @ 6.2 s mask 69 % · 4 segments
Pipeline visualizationpipeline

CCMusic · 中文流行翻唱

#15 YYH_月亮代表我的心 / YYH_月亮代表我的心_seg001.wav · @ 36.6 s mask 34 % · 2 segments
Pipeline visualizationpipeline
#16 YYH_甜蜜蜜 / YYH_甜蜜蜜_seg001.wav · @ 4.1 s mask 72 % · 5 segments
Pipeline visualizationpipeline
#17 YYH_至少还有你 / YYH_至少还有你_seg001.wav · @ 29.6 s mask 46 % · 4 segments
Pipeline visualizationpipeline

Notes

References

  1. Liu, Y. & Akama, T. Self-Supervised Restoration of Singing Voice Degraded by Pitch Shifting Using Shallow Diffusion. arXiv preprint arXiv:2601.10345, 2026. arxiv
  2. Welker, S., Le, M., Chen, R. T. Q., Hsu, W.-N., Gerkmann, T., Richard, A. & Wu, Y.-C. FlowDec: A Flow-Based Full-Band General Audio Codec with High Perceptual Quality. ICLR 2025. openreview
  3. Luo, T., Miao, X. & Duan, W. WaveFM: A High-Fidelity and Efficient Vocoder Based on Flow Matching. NAACL 2025. aclanthology
  4. Morise, M., Yokomori, F. & Ozawa, K. WORLD: A Vocoder-Based High-Quality Speech Synthesis System for Real-Time Applications. IEICE Transactions on Information and Systems, vol. E99-D, no. 7, pp. 1877–1884, 2016. jstage
  5. Luo, Y., Zhang, R., Liu, L.-C., Li, T. & Liu, H. FCPE: A Fast Context-based Pitch Estimation Model. arXiv preprint arXiv:2509.15140, 2025. arxiv
  6. 苏剑林. Muon 优化器指南:快速上手与关键细节. 科学空间 (kexue.fm), 2025 年 11 月. kexue.fm