Linux |
---|
Morise's World Vocoder is a fast and high-quality vocoder. World Vocoder parameterizes speech into three components:
- Pitch (fundamental frequency, F0) contour
- Harmonic spectral envelope
- Aperiodic spectral envelope (relative to the harmonic spectral envelope)
It can also resynthesize speech using these features (see examples below).
For more information, please visit Morise's World repository and the official website of World Vocoder
import pyworld as pw
_f0, t = pw.dio(x, fs) # raw pitch extractor
f0 = pw.stonemask(x, _f0, t, fs) # pitch refinement
sp = pw.cheaptrick(x, f0, t, fs) # extract smoothed spectrogram
ap = pw.d4c(x, f0, t, fs) # extract aperiodicity
y = pw.synthesize(f0, sp, ap, fs)
# Convert speech into features (using default options)
f0, sp, ap = pw.wav2world(x, fs)
git clone https://github.com/JeremyCCHsu/Python-Wrapper-for-World-Vocoder.git
cd Python-Wrapper-for-World-Vocoder
pip install -U pip
pip install -r requirements.txt
bash download_vocoder.sh
python setup.py install
It will automatically git clone
Morise's World Vocoder (C++ version).
Alternatively you can clone or download the World repository manually and copy its "src" directory to this repositories directory.
As for installation mode (the last line), you can choose from the following options.
- If you want to "install" this package, try
python setup.py install
(add--user
if you don't have root access) - If you just want to try out some experiments, execute
python setup.py build_ext --inplace
Then you can use PyWorld from this directory.
You can also copy the resulting pyworld.so (pyworld.{arch}.pyd on Windows) file to~/.local/lib/python2.7/site-packages
(or corresponding Windows directory) so that you can use it everywhere like an installed package.
Alternatively you can copy/symlink the compiled files using pip, e.g.pip install -e .
- Operating systems
- Linux Ubuntu 16.04/14.04
- Windows (thanks to wuaalb)
- Python
- 2.7
- 3.6/3.5
- Required packages
- Cython 0.24 (or later versions; required)
- Numpy
- Optional (for demo.py only)
- argparse
- pysoundfile
- Matplotlib
You can simply install these by pip install -r requirements.txt
You can validate installation by running
python demo.py
to see if you get results in test/
direcotry.
- Upgrade your Cython version to 0.24.
(I failed to build it on Cython 0.20.1post0)
It'll require you to download Cython form http://cython.org/
Unzip it, andpython setup.py install
it.
(I triedpip install Cython
but the upgrade didn't seem correct)
(Again, add--user
if you don't have root access.) - The following code might be needed in some configurations:
import matplotlib
matplotlib.use('Agg')
- If you encounter
library not found: sndfile
error upon executingdemo.py
,
you might have to install it byapt-get install libsoundfile1
.
You can also replacepysoundfile
withscipy
orlibrosa
.- librosa:
- load(fiilename, dtype=np.float64)
- output.write_wav(filename, wav, fs)
- remember to pass
dtype
argument to ensure that the method gives you adouble
.
- scipy:
- You'll have to write a customized utility function based on the following methods
- scipy.io.wavfile.read (but this gives you
short
) - scipy.io.wavfile.write
- librosa:
- Realtime synthesizer
Thank all contributors (wuaalb, rikrd) for making this repo better!
This wrapper is an updated version of sotelo's "world.py"