# PyWORLD - A Python wrapper of WORLD Vocoder
| **`Linux`** | **`Windows`** |
|-----------------|-----------|
| [![Build Status](https://app.travis-ci.com/JeremyCCHsu/Python-Wrapper-for-World-Vocoder.svg?branch=master)](https://app.travis-ci.com/JeremyCCHsu/Python-Wrapper-for-World-Vocoder) | [![Build Status](https://ci.appveyor.com/api/projects/status/github/JeremyCCHsu/Python-Wrapper-for-World-Vocoder?svg=true)](https://ci.appveyor.com/project/JeremyCCHsu/python-wrapper-for-world-vocoder) |
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](https://github.com/mmorise/World)
and the [official website of WORLD Vocoder](http://ml.cs.yamanashi.ac.jp/world/english)
## APIs
### Vocoder Functions
```python
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
```python
# Convert speech into features (using default arguments)
f0, sp, ap = pw.wav2world(x, fs)
```
<br/>
You can change the default arguments of the function, too.
See more info using `help`.
## Installation
### Using Pip
`pip install pyworld`
<br/>
### Building from Source
```bash
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 .
```
It will automatically `git clone` Morise's World Vocoder (C++ version).<br/>
(It seems to me that using `virtualenv` or `conda` is the best practice.)<br/>
<br/>
### Installation Validation
You can validate installation by running
```bash
cd demo
python demo.py
```
to see if you get results in `test/` direcotry.
(Please avoid writing and executing codes in the `Python-Wrapper-for-World-Vocoder` folder for now.)<br/>
### Environment/Dependencies
- Operating systems
- Linux Ubuntu 14.04+
- Windows (thanks to [wuaalb](https://github.com/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](https://github.com/JeremyCCHsu/Python-Wrapper-for-World-Vocoder/issues/54).
- 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.<br/>
(I failed to build it on Cython 0.20.1post0)<br/>
It'll require you to download Cython form http://cython.org/<br/>
Unzip it, and `python setup.py install` it.<br/>
(I tried `pip install Cython` but the upgrade didn't seem correct)<br/>
(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):<br/>
```python
import matplotlib
matplotlib.use('Agg')
```
3. 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
4. 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](https://github.com/JeremyCCHsu/wsl)).
### Other Installation Suggestions
1. Use `pip install .` is safer and you can easily uninstall pyworld by `pip uninstall pyworld`
- For Mac users: You might need to do `MACOSX_DEPLOYMENT_TARGET=10.9 pip install .` See [issue](https://github.com/SeanNaren/warp-ctc/issues/129#issuecomment-502349652).
2. Another way to install pyworld is via<br/>
`python setup.py install`<br/>
- Add `--user` if you don't have root access<br/>
- Add `--record install.txt` to track the installation dir<br/>
3. If you just want to try out some experiments, execute<br/>
`python setup.py build_ext --inplace`<br/>
Then you can use PyWorld from this directory.<br/>
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.<br/>
Alternatively you can copy/symlink the compiled files using pip, e.g. `pip install -e .`
## Acknowledgement
Thank all contributors ([tats-u](https://github.com/tats-u), [wuaalb](https://github.com/wuaalb), [r9y9](https://github.com/r9y9), [rikrd](https://github.com/rikrd), [kudan2510](https://github.com/kundan2510)) for making this repo better and [sotelo](https://github.com/sotelo) whose [world.py](https://github.com/sotelo/world.py) inspired this repo.<br/>
Raw data
{
"_id": null,
"home_page": "https://github.com/JackismyShephard/Python-Wrapper-for-World-Vocoder",
"name": "pyworld-fixed",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "vocoder",
"author": "Pyworld Contributors",
"author_email": "jackismyshephard@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/16/47/9f4840895aa74978d62071758e1f92e8ce40fb18e499d3c32f39e7973450/pyworld_fixed-0.3.8.tar.gz",
"platform": null,
"description": "# PyWORLD - A Python wrapper of WORLD Vocoder\r\n\r\n\r\n| **`Linux`** | **`Windows`** |\r\n|-----------------|-----------|\r\n| [![Build Status](https://app.travis-ci.com/JeremyCCHsu/Python-Wrapper-for-World-Vocoder.svg?branch=master)](https://app.travis-ci.com/JeremyCCHsu/Python-Wrapper-for-World-Vocoder) | [![Build Status](https://ci.appveyor.com/api/projects/status/github/JeremyCCHsu/Python-Wrapper-for-World-Vocoder?svg=true)](https://ci.appveyor.com/project/JeremyCCHsu/python-wrapper-for-world-vocoder) |\r\n\r\n\r\n\r\n\r\nWORLD Vocoder is a fast and high-quality vocoder\r\nwhich parameterizes speech into three components:\r\n\r\n 1. `f0`: Pitch contour\r\n 2. `sp`: Harmonic spectral envelope\r\n 3. `ap`: Aperiodic spectral envelope (relative to the harmonic spectral envelope)\r\n\r\nIt can also (re)synthesize speech using these features (see examples below).\r\n\r\nFor more information, please visit Dr. Morise's [WORLD repository](https://github.com/mmorise/World)\r\nand the [official website of WORLD Vocoder](http://ml.cs.yamanashi.ac.jp/world/english)\r\n\r\n\r\n## APIs\r\n\r\n### Vocoder Functions\r\n```python\r\nimport pyworld as pw\r\n_f0, t = pw.dio(x, fs) # raw pitch extractor\r\nf0 = pw.stonemask(x, _f0, t, fs) # pitch refinement\r\nsp = pw.cheaptrick(x, f0, t, fs) # extract smoothed spectrogram\r\nap = pw.d4c(x, f0, t, fs) # extract aperiodicity\r\n\r\ny = pw.synthesize(f0, sp, ap, fs) # synthesize an utterance using the parameters\r\n```\r\n\r\n\r\n### Utility\r\n```python\r\n# Convert speech into features (using default arguments)\r\nf0, sp, ap = pw.wav2world(x, fs)\r\n```\r\n<br/>\r\n\r\nYou can change the default arguments of the function, too.\r\nSee more info using `help`.\r\n\r\n\r\n## Installation\r\n\r\n### Using Pip\r\n`pip install pyworld`\r\n<br/>\r\n\r\n### Building from Source\r\n```bash\r\ngit clone https://github.com/JeremyCCHsu/Python-Wrapper-for-World-Vocoder.git\r\ncd Python-Wrapper-for-World-Vocoder\r\ngit submodule update --init\r\npip install -U pip\r\npip install -r requirements.txt\r\npip install .\r\n```\r\nIt will automatically `git clone` Morise's World Vocoder (C++ version).<br/>\r\n(It seems to me that using `virtualenv` or `conda` is the best practice.)<br/>\r\n<br/>\r\n\r\n### Installation Validation\r\nYou can validate installation by running\r\n```bash\r\ncd demo\r\npython demo.py\r\n```\r\nto see if you get results in `test/` direcotry.\r\n(Please avoid writing and executing codes in the `Python-Wrapper-for-World-Vocoder` folder for now.)<br/>\r\n\r\n### Environment/Dependencies\r\n- Operating systems\r\n - Linux Ubuntu 14.04+\r\n - Windows (thanks to [wuaalb](https://github.com/wuaalb))\r\n - WSL\r\n- Python\r\n - 3.7+\r\n\r\nYou can install dependencies these by `pip install -r requirements.txt`\r\n\r\n\r\n\r\n## Notice\r\n- WORLD vocoder is designed for speech sampled \u2265 16 kHz.\r\n Applying WORLD to 8 kHz speech will fail.\r\n See a possible workaround [here](https://github.com/JeremyCCHsu/Python-Wrapper-for-World-Vocoder/issues/54).\r\n- When the SNR is low, extracting pitch using `harvest` instead of `dio`\r\n is a better option.\r\n\r\n\r\n## Troubleshooting\r\n1. Upgrade your Cython version to 0.24.<br/>\r\n (I failed to build it on Cython 0.20.1post0)<br/>\r\n It'll require you to download Cython form http://cython.org/<br/>\r\n Unzip it, and `python setup.py install` it.<br/>\r\n (I tried `pip install Cython` but the upgrade didn't seem correct)<br/>\r\n (Again, add `--user` if you don't have root access.)\r\n2. 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):<br/>\r\n\r\n ```python\r\n import matplotlib\r\n matplotlib.use('Agg')\r\n ```\r\n3. If you encounter `library not found: sndfile` error upon executing `demo.py`,\r\n you might have to install it by `apt-get install libsoundfile1`.\r\n You can also replace `pysoundfile` with `scipy` or `librosa`, but some modification is needed:\r\n - librosa:\r\n - load(fiilename, dtype=np.float64)\r\n - output.write_wav(filename, wav, fs)\r\n - remember to pass `dtype` argument to ensure that the method gives you a `double`.\r\n - scipy:\r\n - You'll have to write a customized utility function based on the following methods\r\n - scipy.io.wavfile.read (but this gives you `short`)\r\n - scipy.io.wavfile.write\r\n\r\n4. If you have installation issue on Windows, I probably could not provide\r\n much help because my development environment is Ubuntu\r\n and Windows Subsystem for Linux ([read this if you are interested in installing it](https://github.com/JeremyCCHsu/wsl)).\r\n\r\n\r\n### Other Installation Suggestions\r\n1. Use `pip install .` is safer and you can easily uninstall pyworld by `pip uninstall pyworld`\r\n - For Mac users: You might need to do `MACOSX_DEPLOYMENT_TARGET=10.9 pip install .` See [issue](https://github.com/SeanNaren/warp-ctc/issues/129#issuecomment-502349652).\r\n2. Another way to install pyworld is via<br/>\r\n `python setup.py install`<br/>\r\n - Add `--user` if you don't have root access<br/>\r\n - Add `--record install.txt` to track the installation dir<br/>\r\n3. If you just want to try out some experiments, execute<br/>\r\n `python setup.py build_ext --inplace`<br/>\r\n Then you can use PyWorld from this directory.<br/>\r\n You can also copy the resulting **pyworld.so** (pyworld.{arch}.pyd on Windows) file to\r\n `~/.local/lib/python2.7/site-packages` (or corresponding Windows directory)\r\n so that you can use it everywhere like an installed package.<br/>\r\n Alternatively you can copy/symlink the compiled files using pip, e.g. `pip install -e .`\r\n\r\n\r\n\r\n## Acknowledgement\r\nThank all contributors ([tats-u](https://github.com/tats-u), [wuaalb](https://github.com/wuaalb), [r9y9](https://github.com/r9y9), [rikrd](https://github.com/rikrd), [kudan2510](https://github.com/kundan2510)) for making this repo better and [sotelo](https://github.com/sotelo) whose [world.py](https://github.com/sotelo/world.py) inspired this repo.<br/>\r\n",
"bugtrack_url": null,
"license": null,
"summary": "PyWorld: a Python wrapper for WORLD vocoder -- Now supporting Python 3.12",
"version": "0.3.8",
"project_urls": {
"Homepage": "https://github.com/JackismyShephard/Python-Wrapper-for-World-Vocoder"
},
"split_keywords": [
"vocoder"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3cb48f37185c2bb262eb8fa5036f821c7a4e22839e79e79f0e2d0d2c91bc7c3f",
"md5": "3e198babb668e1c25aff74b1f5b16792",
"sha256": "52743fcb5d65e3ca44248b411f1d180fd60800c238eeb3c70b4a5e63ec80df91"
},
"downloads": -1,
"filename": "pyworld_fixed-0.3.8-cp312-cp312-win_amd64.whl",
"has_sig": false,
"md5_digest": "3e198babb668e1c25aff74b1f5b16792",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": null,
"size": 182181,
"upload_time": "2024-11-07T23:44:53",
"upload_time_iso_8601": "2024-11-07T23:44:53.538916Z",
"url": "https://files.pythonhosted.org/packages/3c/b4/8f37185c2bb262eb8fa5036f821c7a4e22839e79e79f0e2d0d2c91bc7c3f/pyworld_fixed-0.3.8-cp312-cp312-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "16479f4840895aa74978d62071758e1f92e8ce40fb18e499d3c32f39e7973450",
"md5": "989257af0a5dd45bc9d71bd4ba2cc46a",
"sha256": "2520a751684746549177aeee2cf98203fe59bf5f86ca9691ab0db0c2c20705b5"
},
"downloads": -1,
"filename": "pyworld_fixed-0.3.8.tar.gz",
"has_sig": false,
"md5_digest": "989257af0a5dd45bc9d71bd4ba2cc46a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 261309,
"upload_time": "2024-11-07T23:44:54",
"upload_time_iso_8601": "2024-11-07T23:44:54.754135Z",
"url": "https://files.pythonhosted.org/packages/16/47/9f4840895aa74978d62071758e1f92e8ce40fb18e499d3c32f39e7973450/pyworld_fixed-0.3.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-07 23:44:54",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "JackismyShephard",
"github_project": "Python-Wrapper-for-World-Vocoder",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"appveyor": true,
"requirements": [],
"lcname": "pyworld-fixed"
}