﻿# Vocos waveform reconstruction: predicted magnitude and phase meet in an ISTFT head

Inspect the Vocos ISTFT head, complex coefficient assembly, and overlap-add normalization before replacing the Fourier reconstruction stage during export.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-vocos-istft-head-magnitude-phase-reconstruction/
Language: en

## Identify the Fourier-based vocoder

The [Vocos paper](https://arxiv.org/abs/2306.00814) studies neural generation of spectral coefficients rather than direct time-domain sample upsampling. The [official repository](https://github.com/gemelo-ai/vocos) provides models and reconstruction examples. This article concerns its ISTFT head, not a claim that every configurable Fourier head in the project uses identical mathematics. Preserve the selected head and conditioning configuration when comparing a deployed vocoder with its reference implementation.

## Inspect the prediction boundary

The [head implementation](https://raw.githubusercontent.com/gemelo-ai/vocos/main/vocos/heads.py) projects hidden features and separates magnitude-related values from phase values. It exponentiates the former and constructs complex coefficients using sine and cosine of the latter before inverse spectral reconstruction. The projected channels therefore are not final waveform samples. Treating them as interchangeable real and imaginary outputs without following the implemented parameterization changes the represented signal even when the exported linear layer itself matches exactly.

## Preserve overlap-add normalization

The [spectral reconstruction source](https://raw.githubusercontent.com/gemelo-ai/vocos/main/vocos/spectral_ops.py) shows the selected inverse transform, synthesis window, overlap-add assembly, edge trimming, and normalization by the window envelope. A generic inverse transform with different centering can produce another length or boundary behavior. These deterministic operations belong to inference correctness even though they do not add learned parameters. A successful neural-network export is consequently only part of a faithful full-vocoder conversion.

## Investigate an export with edge artifacts

Consider a port whose central speech sounds close to reference but whose start and end contain clicks or shifted samples. Compare predicted complex coefficients before changing network precision. If those agree, investigate padding, window placement, trimming, and envelope normalization in reconstruction. Save both coefficients and final waveforms in a fixture. This isolates the earliest discrepancy without claiming that every click has the same cause or assuming that a vocoder can accept arbitrary mel conventions because its tensor dimensions happen to fit.

## Test the complete waveform contract

Record acoustic feature settings, neural backbone, output head, transform configuration, and returned sample length. Guides to [tensor axes](/journal/tensor-axes-batch-sequence-hidden/) and [inference evaluation](/journal/inference-benchmark-method/) support comparison. Evaluate short inputs and boundary-heavy fixtures in addition to long speech. Reporting projection speed alone does not describe end-to-end vocoding, and matching parameter files does not establish equivalent audio when the complex reconstruction and overlap-add boundary policy differ.
