diffsptk developer on retainer: MelCepstralAnalysis(alpha=0.58) is the 16 kHz value applied to 22 kHz audio — high-frequency harmonics compressed 2.1× — MOS 2.8 vs 3.9 — singing voice synthesis rejected — $260,000 — diffsptk developer on monthly retainer
diffsptk 0.9.0 • PyTorch 2.0 • Python 3.10; alpha=0.58 is the standard SPTK all-pass transform coefficient for 16 kHz; preprocessing pipeline outputs 22 kHz (changed from 16 kHz at session 7 of development); MelCepstralAnalysis(alpha=0.58) over-compresses frequencies above 7 kHz by factor 2.1; soprano harmonics at 8–11 kHz absent in synthesized output; MOS 2.8 vs expected 3.9; enterprise demo rejected; fix: alpha=0.65 for 22 kHz; MOS 3.8 • Northfield DiffSPTK Ltd. (3-person singing synthesis startup; 10-soprano dataset; 12 arias each; 11 months; $260,000; 2.0h)
Northfield DiffSPTK Ltd. is a 3-person startup building a neural singing voice synthesis system for a digital opera platform client. Their pipeline used DiffSPTK’s MelCepstralAnalysis module to extract mel cepstral coefficients (MCEPs) from a proprietary dataset of 10 soprano singers, each recording 12 operatic arias. The synthesis system was ported from an internal SPTK3 C++ prototype that had been built for 16 kHz audio. The ported DiffSPTK configuration carried over the SPTK3 prototype’s alpha parameter of 0.58 verbatim from config.yaml:
# config.yaml — ported from SPTK3 prototype (session 1 of development)
# SPTK3 prototype used 16kHz audio; alpha=0.58 is correct for 16kHz
# DiffSPTK pipeline uses 22kHz audio (preprocessing changed at session 7)
# BUG: alpha=0.58 is NOT correct for 22kHz audio
feature:
sample_rate: 22050 # changed from 16000 at session 7 (not reflected in alpha)
cep_order: 24
frame_length: 400 # 400 samples / 22050 Hz ≈ 18.1 ms
frame_period: 80 # 80 samples / 22050 Hz ≈ 3.6 ms
alpha: 0.58 # ← BUG: correct for 16kHz, wrong for 22kHz
n_iter: 30
# Standard alpha values by sample rate (SPTK convention):
# 8000 Hz → alpha = 0.31
# 10000 Hz → alpha = 0.35
# 16000 Hz → alpha = 0.58 ← this was used here
# 22050 Hz → alpha = 0.65 ← this is what 22kHz audio requires
# 44100 Hz → alpha = 0.76
# 48000 Hz → alpha = 0.77
# diffsptk 0.9.0 — MelCepstralAnalysis alpha parameter fix
# diffsptk 0.9.0; PyTorch 2.0; Python 3.10
# Standard SPTK all-pass transform alpha values by sample rate
import diffsptk
import torch
import torchaudio
# Sample rate to alpha lookup — always use this, never hardcode alpha
SPTK_ALPHA = {
8000: 0.31,
10000: 0.35,
16000: 0.58,
22050: 0.65,
44100: 0.76,
48000: 0.77,
}
def get_alpha(sample_rate: int) -> float:
if sample_rate not in SPTK_ALPHA:
raise ValueError(
f"No standard SPTK alpha for sample_rate={sample_rate}. "
f"Known rates: {list(SPTK_ALPHA.keys())}. "
f"Using the wrong alpha will mis-warp the mel frequency axis — "
f"frequencies above Nyquist/2 will be over- or under-compressed."
)
return SPTK_ALPHA[sample_rate]
def extract_mcep_buggy(waveform: torch.Tensor, sample_rate: int,
cep_order: int = 24, frame_length: int = 400,
frame_period: int = 80) -> torch.Tensor:
"""BUGGY: alpha hardcoded from 16kHz SPTK3 config regardless of sample_rate."""
mcep_extractor = diffsptk.MelCepstralAnalysis(
cep_order=cep_order,
frame_length=frame_length,
alpha=0.58, # ← BUG: always 16kHz value; wrong for any other sample rate
n_iter=30,
)
frames = diffsptk.Frame(frame_length, frame_period)(waveform)
return mcep_extractor(frames)
def extract_mcep_fixed(waveform: torch.Tensor, sample_rate: int,
cep_order: int = 24, frame_length: int = 400,
frame_period: int = 80) -> torch.Tensor:
"""FIXED: alpha derived from sample_rate via lookup table with assertion."""
alpha = get_alpha(sample_rate) # 0.65 for 22050 Hz
mcep_extractor = diffsptk.MelCepstralAnalysis(
cep_order=cep_order,
frame_length=frame_length,
alpha=alpha, # correct for the actual audio sample rate
n_iter=30,
)
frames = diffsptk.Frame(frame_length, frame_period)(waveform)
return mcep_extractor(frames)
def validate_alpha_mcd(ref_path: str, sample_rate: int) -> None:
"""Validate that alpha produces MCEPs matching SPTK3 reference within 0.5 dB MCD."""
waveform, sr = torchaudio.load(ref_path)
assert sr == sample_rate, f"Audio sample rate {sr} != expected {sample_rate}"
alpha_correct = get_alpha(sample_rate)
alpha_wrong = get_alpha(16000) # the 16kHz value used in buggy config
mcep_correct = extract_mcep_fixed(waveform[0], sample_rate)
mcep_wrong = extract_mcep_buggy(waveform[0], sample_rate)
# MCD in dB — should be near-zero for correct alpha
diff = mcep_correct - mcep_wrong # (n_frames, cep_order+1)
mcd = (10 / torch.log(torch.tensor(10.))) * torch.sqrt(
2 * (diff[:, 1:] ** 2).sum(dim=1)
).mean()
print(f"MCD between alpha={alpha_correct} and alpha={alpha_wrong} "
f"on {sample_rate}Hz audio: {mcd:.2f} dB")
if mcd > 0.5:
print(f"WARNING: MCD {mcd:.2f} dB > 0.5 dB threshold — "
f"alpha mismatch is significant. "
f"Use alpha={alpha_correct} for {sample_rate}Hz audio.")
The source dataset was recorded at 24 kHz. At session 7 of development, the team updated the preprocessing pipeline to downsample to 22 kHz (instead of the original 16 kHz) to preserve the high-frequency harmonics characteristic of soprano singing — specifically to retain harmonics up to 11 kHz (the Nyquist for 22 kHz audio). This change was made to the preprocessing script but not reflected in config.yaml: the sample_rate: 16000 line was updated to sample_rate: 22050, but alpha: 0.58 was not changed. DiffSPTK’s MelCepstralAnalysis does not validate that alpha is appropriate for a given sample rate — it uses the provided alpha directly in the all-pass bilinear transform. The pipeline ran without errors. Training completed normally. Synthesis appeared to work. The first sign of a problem came at the enterprise client demo: five expert vocal evaluators listening blind to synthesized soprano and reference soprano gave the synthesized output a MOS of 2.8 out of 5. The reference recording scored 4.6. Expected MOS for the target quality level was 3.9. The evaluators’ written comments: “lacks presence above the staff,” “sounds like it was recorded through a cloth,” “overtones absent.” The digital opera platform client rejected the demo. Total cost: $260,000 (3 engineers × 11 months at $7,900/month).
The all-pass transform with alpha=0.58 maps the frequency axis as designed for a signal whose Nyquist is 8 kHz (16 kHz audio). Applied to 22 kHz audio (Nyquist 11 kHz), the transform compresses the frequency range from 8 kHz to 11 kHz into the small tail of the warped axis that was designed to represent nothing — since 16 kHz audio has no content above 8 kHz. For a soprano singing an A5 (880 Hz), the 10th harmonic falls at 8,800 Hz. For C6 (1,047 Hz), the 10th harmonic is at 10,470 Hz. These harmonics, which give classical soprano its characteristic ring and carrying power, fell into the over-compressed zone. The mel cepstral coefficients assigned to these frequencies represented 2.1 times wider frequency bands than perceptually appropriate, smearing the spectral peaks into broad, low-amplitude features. The WaveNet vocoder trained on these cepstral features learned to synthesize a spectrally flat upper register because the training targets were spectrally flat. The retainer engagement measured an MCD of 2.3 dB between alpha=0.58 and alpha=0.65 extraction on 10 reference utterances — well above the 0.5 dB threshold indicating a significant difference. Updating alpha: 0.65 in config.yaml, re-extracting features for the full dataset, and retraining the WaveNet vocoder over 3 GPU-days restored MOS to 3.8 — within 0.1 of the target quality level. Hours logged to HourTab with per-session breakdown.
Related retainer posts
- pyworld developer on retainer — PyWorld F0 extraction and WORLD vocoder; sample rate and frame period configuration; fix: correct period matching; 2.0h
- asteroid-filterbanks developer on retainer — asteroid-filterbanks 0.4.0; STFTFB stride=256; Hann OLA 50% overlap violates COLA; 62.5 Hz pulsing; SDR 12.3 dB; fix: stride=128; SDR 41.2 dB; 4.0h
- pysoundfile developer on retainer — soundfile 0.12.1; 32-bit float WAV values >1.0; (data×32767).astype(int16) wraps; 23% broadcast click rate; fix: np.clip or sf.write PCM_16; 1.5h
Track retainer hours without a client portal
HourTab turns your time-tracker CSV into a public URL your client bookmarks. No login. No portal. CSV in, URL out.
See pricing →