LPCyNet is a Cython wrapper that allows Python access to the high-performance C version of LPCNet.
This wrapper was designed for the latest 2019 version of LPCNet but may work with more recent versions.
- Download and compile this version of LPCNet.
- Copy the following files from LPCNet into the
./lpcnetfolder of LPCyNet:
./libs/liblpcnet.so
./libs/liblpcnet.so.0
./libs/liblpcnet.so.0.0.0
- Copy the
./include/lpcnet.hfile from LPCNet into the./includeLPCyNet folder. - Run
sh build.sh. - You should now have a
lpcynet.cpython-*.sofile that you can include from Python usingimport lpcynet.
import lpcynet
from scipy.io import wavfile
sampling_rate, pcm = wavfile.read("test.wav")
# Your wav file should be compatible with LPCNet
assert sampling_rate == 16000 and pcm.dtype == "int16"
# Returns a float32 numpy array of shape (frame_number, features_dimension)
# features_dimension = 20, with the first 18 numbers representing the ceptrum
# and the last 2 representing respectively the period and the correlation parameters
lpcnet_features = lpcynet.analyze_frames(pcm)
resynthesized_pcm = lpcynet.synthesize_frames(lpcnet_features)
wavfile.write("resynth.wav", 16000, resynthesized_pcm)