PyWORLD Documentation

repository·master·Indexed 21 days ago

https://github.com/jeremycchsu/python-wrapper-for-world-vocoder

A Python wrapper for the WORLD Vocoder, a high-quality speech parameterization and synthesis tool. PyWORLD allows developers to decompose speech into pitch (f0), harmonic spectral envelope (sp), and aperiodic spectral envelope (ap) components, and provides a high-level wav2world utility for feature conversion.

Tokens
856
Snippets
5
Records
7
Agent score
24%

What's inside PyWORLD

  1. Build PyWORLD from source

    master

    To build from source, clone the repository, initialize submodules (which includes the C++ WORLD Vocoder), and install the requirements. It is recommended to use virtualenv or conda for this process.

    git clone https://github.com/JeremyCCHsu/Python-Wrapper-for-World-Vocoder.git
    cd Python-Wrapper-for-World-Vocoder
    git submodule update --init
    pip install -U pip
    pip install -r requirements.txt
    pip install .
  2. Troubleshoot PyWORLD installation and execution

    master

    Common issues and solutions:

    • Cython version: If building fails, upgrade Cython to version 0.24 or higher. If pip install Cython does not work, download it from cython.org and run python setup.py install.
    • Matplotlib in remote environments: If running demo.py on a remote Linux server, you may need to use the 'Agg' backend:
      import matplotlib
      matplotlib.use('Agg')
    • Missing sndfile: If you see library not found: sndfile, install it via apt-get install libsoundfile1.
    • Windows Installation: If you encounter issues on Windows, consider using WSL (Windows Subsystem for Linux).
    • Mac Users: You might need to set the deployment target during installation: MACOSX_DEPLOYMENT_TARGET=10.9 pip install ..
  3. Use Vocoder functions for speech parameterization

    master

    PyWORLD provides low-level functions to parameterize speech into three components: f0 (pitch contour), sp (harmonic spectral envelope), and ap (aperiodic spectral envelope). You can then use these to synthesize speech.

    import pyworld as pw
    
    # 1. Extract pitch
    _f0, t = pw.dio(x, fs)    # raw pitch extractor
    f0 = pw.stonemask(x, _f0, t, fs)  # pitch refinement
    
    # 2. Extract spectral envelopes
    sp = pw.cheaptrick(x, f0, t, fs)  # extract smoothed spectrogram
    ap = pw.d4c(x, f0, t, fs)         # extract aperiodicity
    
    # 3. Synthesize speech
    y = pw.synthesize(f0, sp, ap, fs)