﻿# MetricGAN+ masking: log-magnitude multiplication is not a linear spectral gain

Follow the SpeechBrain MetricGAN+ reference through log-magnitude features, masking, inverse transformation, and resynthesis before optimizing or exporting its inference path.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-metricgan-plus-log-magnitude-mask-domain/
Language: en

## Keep the trained objective and inference path separate

The [MetricGAN+ paper](https://arxiv.org/abs/2104.03538) uses a learned relationship to an objective speech-quality metric during training. This does not mean the deployed system simply evaluates that metric and selects a clean waveform. A concrete deployment still has a specific feature representation and enhancement computation. Inspect the released inference route before replacing operations with a familiar spectral-mask pattern from another speech-processing model.

## Locate the transformed feature domain

The [SpeechBrain enhancement interface](https://raw.githubusercontent.com/speechbrain/speechbrain/develop/speechbrain/inference/enhancement.py) computes spectral magnitude and applies `log1p` before passing features to the enhancement model. The predicted mask multiplies those transformed features. It then applies `expm1` before resynthesis. This order is part of the demonstrated method. Multiplication before the logarithmic transform is not generally equivalent to multiplication afterward, so moving the operation for convenience can change output even when the learned mask tensor itself is unchanged.

## Preserve resynthesis inputs

The interface forwards the transformed-back enhanced representation and the original noisy waveform to the configured resynthesis component. A standalone mask predictor therefore is not a complete waveform enhancement service. The [official checkpoint card](https://huggingface.co/speechbrain/metricgan-plus-voicebank) provides the concrete artifact and supported enhancement entry point. Keep its configuration assets alongside the neural weights rather than assuming a generic inverse transform reproduces all behavior because the returned waveform has the expected length.

## Diagnose an exported-mask discrepancy

Consider an export that matches the reference mask values but produces different audio. Compare the features before masking, the multiplication domain, and the values after inverse transformation. If the port treats the mask as a direct linear spectral gain, the discrepancy already exists before final waveform assembly. This fixture isolates a mathematical reordering error from numerical precision or model loading. It does not claim that every audible mismatch is caused by the same issue or that shape equality alone can certify enhancement equivalence.

## Evaluate beyond the optimized metric

Record checkpoint, spectral feature configuration, transform order, mask output, resynthesis setup, and waveform result. Guides to [tensor axes](/journal/tensor-axes-batch-sequence-hidden/) and [inference evaluation](/journal/inference-benchmark-method/) support the comparison. Evaluate intelligibility, content preservation, and representative noise conditions separately from the model's training objective. A faithful implementation should preserve the actual inference mathematics first; a pleasant output or improved single metric does not prove that an altered mask domain is the same deployed algorithm.
