-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9875037
commit 416f24d
Showing
26 changed files
with
2,766 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Publish Python package | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.x" | ||
- name: Install pypa/setuptools | ||
run: >- | ||
python -m | ||
pip install wheel | ||
- name: Build a binary wheel | ||
run: >- | ||
python setup.py sdist bdist_wheel | ||
- name: Publish to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
password: ${{ secrets.PYPI_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
.pybuilder/ | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# poetry | ||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. | ||
# This is especially recommended for binary packages to ensure reproducibility, and is more | ||
# commonly ignored for libraries. | ||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control | ||
#poetry.lock | ||
|
||
# pdm | ||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. | ||
#pdm.lock | ||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it | ||
# in version control. | ||
# https://pdm.fming.dev/#use-with-ide | ||
.pdm.toml | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
# PyCharm | ||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can | ||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | ||
# and can be added to the global gitignore or merged into this file. For a more nuclear | ||
# option (not recommended) you can uncomment the following to ignore the entire idea folder. | ||
.idea/ | ||
|
||
logs/ | ||
*.pt | ||
*.ckpt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Charactr Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,124 @@ | ||
# Vocos: Closing the gap between time-domain and Fourier-based neural vocoders for high-quality audio synthesis | ||
|
||
[Audio samples](https://charactr-platform.github.io/vocos/) | Paper [[abs]](https://arxiv.org/abs/2306.00814) [[pdf]](https://arxiv.org/pdf/2306.00814.pdf) | ||
[Audio samples](https://charactr-platform.github.io/vocos/) | | ||
Paper [[abs]](https://arxiv.org/abs/2306.00814) [[pdf]](https://arxiv.org/pdf/2306.00814.pdf) | ||
|
||
## Installation | ||
|
||
To use Vocos only in inference mode, install it using: | ||
|
||
```bash | ||
pip install vocos | ||
``` | ||
|
||
If you wish to train the model, install it with additional dependencies: | ||
|
||
```bash | ||
pip install vocos[train] | ||
``` | ||
|
||
## Usage | ||
|
||
### Reconstruct audio from mel-spectrogram | ||
|
||
```python | ||
import torch | ||
|
||
from vocos import Vocos | ||
|
||
vocos = Vocos.from_pretrained("charactr/vocos-mel-24khz") | ||
|
||
mel = torch.randn(1, 100, 256) # B, C, T | ||
|
||
with torch.no_grad(): | ||
audio = vocos.decode(mel) | ||
``` | ||
|
||
Copy-synthesis from a file: | ||
|
||
```python | ||
import torchaudio | ||
|
||
y, sr = torchaudio.load(YOUR_AUDIO_FILE) | ||
if y.size(0) > 1: # mix to mono | ||
y = y.mean(dim=0, keepdim=True) | ||
y = torchaudio.functional.resample(y, orig_freq=sr, new_freq=24000) | ||
|
||
with torch.no_grad(): | ||
y_hat = vocos(y) | ||
``` | ||
|
||
### Reconstruct audio from EnCodec | ||
|
||
Additionally, you need to provide a `bandwidth_id` which corresponds to the lookup embedding for bandwidth from the | ||
list: `[1.5, 3.0, 6.0, 12.0]`. | ||
|
||
```python | ||
vocos = Vocos.from_pretrained("charactr/vocos-encodec-24khz") | ||
|
||
quantized_features = torch.randn(1, 128, 256) | ||
bandwidth_id = torch.tensor([3]) # 12 kbps | ||
|
||
with torch.no_grad(): | ||
audio = vocos.decode(quantized_features, bandwidth_id=bandwidth_id) | ||
``` | ||
|
||
Copy-synthesis from a file: It extracts and quantizes features with EnCodec, then reconstructs them with Vocos in a | ||
single forward pass. | ||
|
||
```python | ||
y, sr = torchaudio.load(YOUR_AUDIO_FILE) | ||
if y.size(0) > 1: # mix to mono | ||
y = y.mean(dim=0, keepdim=True) | ||
y = torchaudio.functional.resample(y, orig_freq=sr, new_freq=24000) | ||
|
||
with torch.no_grad(): | ||
y_hat = vocos(y, bandwidth_id=bandwidth_id) | ||
``` | ||
|
||
## Pre-trained models | ||
|
||
The provided models were trained up to 2.5 million generator iterations, which resulted in slightly better objective | ||
scores | ||
compared to those reported in the paper. | ||
|
||
| Model Name | Dataset | Training Iterations | Parameters | ||
|-------------------------------------------------------------------------------------|---------------|---------------------|------------| | ||
| [charactr/vocos-mel-24khz](https://huggingface.co/charactr/vocos-mel-24khz) | LibriTTS | 2.5 M | 13.5 M | ||
| [charactr/vocos-encodec-24khz](https://huggingface.co/charactr/vocos-encodec-24khz) | DNS Challenge | 2.5 M | 7.9 M | ||
|
||
## Training | ||
|
||
Prepare a filelist of audio files for the training and validation set: | ||
|
||
```bash | ||
find $TRAIN_DATASET_DIR -name *.wav > filelist.train | ||
find $VAL_DATASET_DIR -name *.wav > filelist.val | ||
``` | ||
|
||
Fill a config file, e.g. [vocos.yaml](configs%2Fvocos.yaml), with your filelist paths and start training with: | ||
|
||
```bash | ||
python train.py -c configs/vocos.yaml | ||
``` | ||
|
||
Refer to [Pytorch Lightning documentation](https://lightning.ai/docs/pytorch/stable/) for details about customizing the | ||
training pipeline. | ||
|
||
## Citation | ||
|
||
If this code contributes to your research, please cite our work: | ||
|
||
``` | ||
@article{siuzdak2023vocos, | ||
title={Vocos: Closing the gap between time-domain and Fourier-based neural vocoders for high-quality audio synthesis}, | ||
author={Siuzdak, Hubert}, | ||
journal={arXiv preprint arXiv:2306.00814}, | ||
year={2023} | ||
} | ||
``` | ||
|
||
## License | ||
|
||
The code in this repository is released under the MIT license as found in the | ||
[LICENSE](LICENSE) file. |
Oops, something went wrong.