WorldNet

WorldNet brings the WORLD vocoder to .NET, faster than the original C++.
It is verified against the original and performs no managed allocation.

Try it in your browser. Nothing to install, nothing uploaded.


Install

dotnet add package WorldNet

Use

This program reads a monaural WAV file, estimates the F0 contour with Harvest, the spectral envelope with CheapTrick and the aperiodicity with D4C, and synthesizes a waveform from the three results.

using WorldNet;

int length = WaveFile.GetLength("input.wav");
double[] x = new double[length];
WaveFile.Read("input.wav", x, out int fs, out _);

using WorldArena arena = new();

HarvestOption harvestOption = HarvestOption.Default;
int f0Length = Harvest.GetSamplesForHarvest(fs, x.Length, harvestOption.FramePeriod);
double[] temporalPositions = new double[f0Length];
double[] f0 = new double[f0Length];
Harvest.Estimate(x, fs, harvestOption, temporalPositions, f0, arena);

CheapTrickOption cheapTrickOption = CheapTrickOption.Create(fs);
int fftSize = cheapTrickOption.FftSize;
int spectrumLength = (fftSize / 2) + 1;
double[] spectrogram = new double[f0Length * spectrumLength];
CheapTrick.Estimate(x, fs, cheapTrickOption, temporalPositions, f0, spectrogram, arena);

double[] aperiodicity = new double[f0Length * spectrumLength];
D4C.Estimate(x, fs, D4COption.Default, temporalPositions, f0, fftSize, aperiodicity, arena);

int yLength = Synthesis.GetSamplesForSynthesis(fs, f0Length, harvestOption.FramePeriod);
double[] y = new double[yLength];
Synthesis.Synthesize(f0, spectrogram, aperiodicity, fftSize, harvestOption.FramePeriod, fs, y, arena);

WaveFile.Write("output.wav", y, fs);

What it does

Why WorldNet

Links