Skip to main content

PyWorld: a Python wrapper for WORLD vocoder

Reason this release was yanked:

There is a minor but fatal bug that prevents it from working when imported.

Project description

pyworld-prebuilt - A Python wrapper of WORLD Vocoder

[!TIP]
This is a prebuilt version of pyworld for multiple platforms.
There are no differences from pyworld except for some migration from some deprecated APIs and the addition of type hints.

WORLD Vocoder is a fast and high-quality vocoder which parameterizes speech into three components:

  1. f0: Pitch contour
  2. sp: Harmonic spectral envelope
  3. ap: Aperiodic spectral envelope (relative to the harmonic spectral envelope)

It can also (re)synthesize speech using these features (see examples below).

For more information, please visit Dr. Morise's WORLD repository and the official website of WORLD Vocoder

APIs

Vocoder Functions

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) # synthesize an utterance using the parameters

Utility

# Convert speech into features (using default arguments)
f0, sp, ap = pw.wav2world(x, fs)

You can change the default arguments of the function, too. See more info using help.

Installation

Using pip

pip install pyworld-prebuilt

Building from Source

git clone https://github.com/tsukumijima/pyworld-prebuilt.git
cd pyworld-prebuilt
git submodule update --init
pip install -U pip
pip install -r requirements.txt
pip install .

It will automatically git clone Morise's World Vocoder (C++ version).
(It seems to me that using virtualenv or conda is the best practice.)

Installation Validation

You can validate installation by running

cd demo
python demo.py

to see if you get results in test/ direcotry. (Please avoid writing and executing codes in the pyworld-prebuilt folder for now.)

Environment/Dependencies

  • Operating systems
    • Linux Ubuntu 14.04+
    • Windows (thanks to wuaalb)
    • WSL
  • Python
    • 3.7+

You can install dependencies these by pip install -r requirements.txt

Notice

  • WORLD vocoder is designed for speech sampled ≥ 16 kHz. Applying WORLD to 8 kHz speech will fail. See a possible workaround here.
  • When the SNR is low, extracting pitch using harvest instead of dio is a better option.

Troubleshooting

  1. 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, and python setup.py install it.
    (I tried pip install Cython but the upgrade didn't seem correct)
    (Again, add --user if you don't have root access.)
  2. Upon executing demo/demo.py, the following code might be needed in some environments (e.g. when you're working on a remote Linux server):
import matplotlib
matplotlib.use('Agg')
  1. If you encounter library not found: sndfile error upon executing demo.py, you might have to install it by apt-get install libsoundfile1. You can also replace pysoundfile with scipy or librosa, but some modification is needed:

    • librosa:
      • load(fiilename, dtype=np.float64)
      • output.write_wav(filename, wav, fs)
      • remember to pass dtype argument to ensure that the method gives you a double.
    • 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
  2. If you have installation issue on Windows, I probably could not provide much help because my development environment is Ubuntu and Windows Subsystem for Linux (read this if you are interested in installing it).

Other Installation Suggestions

  1. Use pip install . is safer and you can easily uninstall pyworld by pip uninstall pyworld-prebuilt
  • For Mac users: You might need to do MACOSX_DEPLOYMENT_TARGET=10.9 pip install . See issue.
  1. Another way to install pyworld is via
    python setup.py install
    • Add --user if you don't have root access
    • Add --record install.txt to track the installation dir
  2. 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 .

Acknowledgement

Thank all contributors (tats-u, wuaalb, r9y9, rikrd, kudan2510) for making this repo better and sotelo whose world.py inspired this repo.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyworld-prebuilt-0.3.4.tar.gz (76.8 kB view hashes)

Uploaded Source

Built Distributions

pyworld_prebuilt-0.3.4-cp312-cp312-win_amd64.whl (180.8 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

pyworld_prebuilt-0.3.4-cp312-cp312-win32.whl (146.4 kB view hashes)

Uploaded CPython 3.12 Windows x86

pyworld_prebuilt-0.3.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pyworld_prebuilt-0.3.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (988.6 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

pyworld_prebuilt-0.3.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (982.4 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyworld_prebuilt-0.3.4-cp312-cp312-macosx_11_0_arm64.whl (193.1 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

pyworld_prebuilt-0.3.4-cp312-cp312-macosx_10_9_x86_64.whl (221.6 kB view hashes)

Uploaded CPython 3.12 macOS 10.9+ x86-64

pyworld_prebuilt-0.3.4-cp312-cp312-macosx_10_9_universal2.whl (409.1 kB view hashes)

Uploaded CPython 3.12 macOS 10.9+ universal2 (ARM64, x86-64)

pyworld_prebuilt-0.3.4-cp311-cp311-win_amd64.whl (184.8 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

pyworld_prebuilt-0.3.4-cp311-cp311-win32.whl (147.8 kB view hashes)

Uploaded CPython 3.11 Windows x86

pyworld_prebuilt-0.3.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pyworld_prebuilt-0.3.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.0 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

pyworld_prebuilt-0.3.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.0 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyworld_prebuilt-0.3.4-cp311-cp311-macosx_11_0_arm64.whl (195.5 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

pyworld_prebuilt-0.3.4-cp311-cp311-macosx_10_9_x86_64.whl (230.2 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

pyworld_prebuilt-0.3.4-cp311-cp311-macosx_10_9_universal2.whl (420.9 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64)

pyworld_prebuilt-0.3.4-cp310-cp310-win_amd64.whl (185.0 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

pyworld_prebuilt-0.3.4-cp310-cp310-win32.whl (148.3 kB view hashes)

Uploaded CPython 3.10 Windows x86

pyworld_prebuilt-0.3.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pyworld_prebuilt-0.3.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (958.6 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

pyworld_prebuilt-0.3.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (955.6 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyworld_prebuilt-0.3.4-cp310-cp310-macosx_11_0_arm64.whl (195.2 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

pyworld_prebuilt-0.3.4-cp310-cp310-macosx_10_9_x86_64.whl (230.1 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

pyworld_prebuilt-0.3.4-cp310-cp310-macosx_10_9_universal2.whl (420.5 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64)

pyworld_prebuilt-0.3.4-cp39-cp39-win_amd64.whl (185.5 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

pyworld_prebuilt-0.3.4-cp39-cp39-win32.whl (148.9 kB view hashes)

Uploaded CPython 3.9 Windows x86

pyworld_prebuilt-0.3.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pyworld_prebuilt-0.3.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (961.3 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

pyworld_prebuilt-0.3.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (958.1 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyworld_prebuilt-0.3.4-cp39-cp39-macosx_11_0_arm64.whl (196.1 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

pyworld_prebuilt-0.3.4-cp39-cp39-macosx_10_9_x86_64.whl (230.7 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

pyworld_prebuilt-0.3.4-cp39-cp39-macosx_10_9_universal2.whl (422.0 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64)

pyworld_prebuilt-0.3.4-cp38-cp38-win_amd64.whl (185.6 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

pyworld_prebuilt-0.3.4-cp38-cp38-win32.whl (149.0 kB view hashes)

Uploaded CPython 3.8 Windows x86

pyworld_prebuilt-0.3.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pyworld_prebuilt-0.3.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (970.9 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

pyworld_prebuilt-0.3.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (965.5 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyworld_prebuilt-0.3.4-cp38-cp38-macosx_11_0_arm64.whl (192.4 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

pyworld_prebuilt-0.3.4-cp38-cp38-macosx_10_9_x86_64.whl (225.6 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

pyworld_prebuilt-0.3.4-cp38-cp38-macosx_10_9_universal2.whl (412.8 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64)

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page