├── setup.py ├── .vscode └── settings.json ├── bark ├── assets │ └── prompts │ │ ├── lee.npz │ │ ├── lee_2.npz │ │ ├── output.npz │ │ ├── announcer.npz │ │ ├── speaker_0.npz │ │ ├── speaker_1.npz │ │ ├── speaker_2.npz │ │ ├── speaker_3.npz │ │ ├── speaker_4.npz │ │ ├── speaker_5.npz │ │ ├── speaker_6.npz │ │ ├── speaker_7.npz │ │ ├── speaker_8.npz │ │ ├── speaker_9.npz │ │ ├── de_speaker_0.npz │ │ ├── de_speaker_1.npz │ │ ├── de_speaker_2.npz │ │ ├── de_speaker_3.npz │ │ ├── de_speaker_4.npz │ │ ├── de_speaker_5.npz │ │ ├── de_speaker_6.npz │ │ ├── de_speaker_7.npz │ │ ├── de_speaker_8.npz │ │ ├── de_speaker_9.npz │ │ ├── en_speaker_0.npz │ │ ├── en_speaker_1.npz │ │ ├── en_speaker_2.npz │ │ ├── en_speaker_3.npz │ │ ├── en_speaker_4.npz │ │ ├── en_speaker_5.npz │ │ ├── en_speaker_6.npz │ │ ├── en_speaker_7.npz │ │ ├── en_speaker_8.npz │ │ ├── en_speaker_9.npz │ │ ├── es_speaker_0.npz │ │ ├── es_speaker_1.npz │ │ ├── es_speaker_2.npz │ │ ├── es_speaker_3.npz │ │ ├── es_speaker_4.npz │ │ ├── es_speaker_5.npz │ │ ├── es_speaker_6.npz │ │ ├── es_speaker_7.npz │ │ ├── es_speaker_8.npz │ │ ├── es_speaker_9.npz │ │ ├── fr_speaker_0.npz │ │ ├── fr_speaker_1.npz │ │ ├── fr_speaker_2.npz │ │ ├── fr_speaker_3.npz │ │ ├── fr_speaker_4.npz │ │ ├── fr_speaker_5.npz │ │ ├── fr_speaker_6.npz │ │ ├── fr_speaker_7.npz │ │ ├── fr_speaker_8.npz │ │ ├── fr_speaker_9.npz │ │ ├── hi_speaker_0.npz │ │ ├── hi_speaker_1.npz │ │ ├── hi_speaker_2.npz │ │ ├── hi_speaker_3.npz │ │ ├── hi_speaker_4.npz │ │ ├── hi_speaker_5.npz │ │ ├── hi_speaker_6.npz │ │ ├── hi_speaker_7.npz │ │ ├── hi_speaker_8.npz │ │ ├── hi_speaker_9.npz │ │ ├── it_speaker_0.npz │ │ ├── it_speaker_1.npz │ │ ├── it_speaker_2.npz │ │ ├── it_speaker_3.npz │ │ ├── it_speaker_4.npz │ │ ├── it_speaker_5.npz │ │ ├── it_speaker_6.npz │ │ ├── it_speaker_7.npz │ │ ├── it_speaker_8.npz │ │ ├── it_speaker_9.npz │ │ ├── ja_speaker_0.npz │ │ ├── ja_speaker_1.npz │ │ ├── ja_speaker_2.npz │ │ ├── ja_speaker_3.npz │ │ ├── ja_speaker_4.npz │ │ ├── ja_speaker_5.npz │ │ ├── ja_speaker_6.npz │ │ ├── ja_speaker_7.npz │ │ ├── ja_speaker_8.npz │ │ ├── ja_speaker_9.npz │ │ ├── ko_speaker_0.npz │ │ ├── ko_speaker_1.npz │ │ ├── ko_speaker_2.npz │ │ ├── ko_speaker_3.npz │ │ ├── ko_speaker_4.npz │ │ ├── ko_speaker_5.npz │ │ ├── ko_speaker_6.npz │ │ ├── ko_speaker_7.npz │ │ ├── ko_speaker_8.npz │ │ ├── ko_speaker_9.npz │ │ ├── pl_speaker_0.npz │ │ ├── pl_speaker_1.npz │ │ ├── pl_speaker_2.npz │ │ ├── pl_speaker_3.npz │ │ ├── pl_speaker_4.npz │ │ ├── pl_speaker_5.npz │ │ ├── pl_speaker_6.npz │ │ ├── pl_speaker_7.npz │ │ ├── pl_speaker_8.npz │ │ ├── pl_speaker_9.npz │ │ ├── pt_speaker_0.npz │ │ ├── pt_speaker_1.npz │ │ ├── pt_speaker_2.npz │ │ ├── pt_speaker_3.npz │ │ ├── pt_speaker_4.npz │ │ ├── pt_speaker_5.npz │ │ ├── pt_speaker_6.npz │ │ ├── pt_speaker_7.npz │ │ ├── pt_speaker_8.npz │ │ ├── pt_speaker_9.npz │ │ ├── ru_speaker_0.npz │ │ ├── ru_speaker_1.npz │ │ ├── ru_speaker_2.npz │ │ ├── ru_speaker_3.npz │ │ ├── ru_speaker_4.npz │ │ ├── ru_speaker_5.npz │ │ ├── ru_speaker_6.npz │ │ ├── ru_speaker_7.npz │ │ ├── ru_speaker_8.npz │ │ ├── ru_speaker_9.npz │ │ ├── tr_speaker_0.npz │ │ ├── tr_speaker_1.npz │ │ ├── tr_speaker_2.npz │ │ ├── tr_speaker_3.npz │ │ ├── tr_speaker_4.npz │ │ ├── tr_speaker_5.npz │ │ ├── tr_speaker_6.npz │ │ ├── tr_speaker_7.npz │ │ ├── tr_speaker_8.npz │ │ ├── tr_speaker_9.npz │ │ ├── zh_speaker_0.npz │ │ ├── zh_speaker_1.npz │ │ ├── zh_speaker_2.npz │ │ ├── zh_speaker_3.npz │ │ ├── zh_speaker_4.npz │ │ ├── zh_speaker_5.npz │ │ ├── zh_speaker_6.npz │ │ ├── zh_speaker_7.npz │ │ ├── zh_speaker_8.npz │ │ ├── zh_speaker_9.npz │ │ └── readme.md ├── __init__.py ├── api.py ├── model_fine.py ├── model.py └── generation.py ├── .gitignore ├── notebooks ├── runs │ └── linear_projection │ │ ├── events.out.tfevents.1683572933.melchior.7747.0 │ │ ├── events.out.tfevents.1683574068.melchior.7747.1 │ │ ├── events.out.tfevents.1683574191.melchior.7747.2 │ │ ├── events.out.tfevents.1683575623.melchior.7747.3 │ │ ├── events.out.tfevents.1683575632.melchior.7747.4 │ │ ├── events.out.tfevents.1683576047.melchior.7747.5 │ │ ├── events.out.tfevents.1683576055.melchior.7747.6 │ │ ├── events.out.tfevents.1683576273.melchior.7747.7 │ │ └── events.out.tfevents.1683577423.melchior.7747.8 ├── create_dataset.ipynb └── fake_classifier.ipynb ├── pyproject.toml ├── model-card.md ├── generate.ipynb ├── generate_chunked.ipynb ├── README.md └── LICENSE /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | setup() 4 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "python.formatting.provider": "black" 3 | } -------------------------------------------------------------------------------- /bark/assets/prompts/lee.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/lee.npz -------------------------------------------------------------------------------- /bark/assets/prompts/lee_2.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/lee_2.npz -------------------------------------------------------------------------------- /bark/assets/prompts/output.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/output.npz -------------------------------------------------------------------------------- /bark/assets/prompts/announcer.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/announcer.npz -------------------------------------------------------------------------------- /bark/assets/prompts/speaker_0.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/speaker_0.npz -------------------------------------------------------------------------------- /bark/assets/prompts/speaker_1.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/speaker_1.npz -------------------------------------------------------------------------------- /bark/assets/prompts/speaker_2.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/speaker_2.npz -------------------------------------------------------------------------------- /bark/assets/prompts/speaker_3.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/speaker_3.npz -------------------------------------------------------------------------------- /bark/assets/prompts/speaker_4.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/speaker_4.npz -------------------------------------------------------------------------------- /bark/assets/prompts/speaker_5.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/speaker_5.npz -------------------------------------------------------------------------------- /bark/assets/prompts/speaker_6.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/speaker_6.npz -------------------------------------------------------------------------------- /bark/assets/prompts/speaker_7.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/speaker_7.npz -------------------------------------------------------------------------------- /bark/assets/prompts/speaker_8.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/speaker_8.npz -------------------------------------------------------------------------------- /bark/assets/prompts/speaker_9.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/speaker_9.npz -------------------------------------------------------------------------------- /bark/assets/prompts/de_speaker_0.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/de_speaker_0.npz -------------------------------------------------------------------------------- /bark/assets/prompts/de_speaker_1.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/de_speaker_1.npz -------------------------------------------------------------------------------- /bark/assets/prompts/de_speaker_2.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/de_speaker_2.npz -------------------------------------------------------------------------------- /bark/assets/prompts/de_speaker_3.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/de_speaker_3.npz -------------------------------------------------------------------------------- /bark/assets/prompts/de_speaker_4.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/de_speaker_4.npz -------------------------------------------------------------------------------- /bark/assets/prompts/de_speaker_5.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/de_speaker_5.npz -------------------------------------------------------------------------------- /bark/assets/prompts/de_speaker_6.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/de_speaker_6.npz -------------------------------------------------------------------------------- /bark/assets/prompts/de_speaker_7.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/de_speaker_7.npz -------------------------------------------------------------------------------- /bark/assets/prompts/de_speaker_8.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/de_speaker_8.npz -------------------------------------------------------------------------------- /bark/assets/prompts/de_speaker_9.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/de_speaker_9.npz -------------------------------------------------------------------------------- /bark/assets/prompts/en_speaker_0.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/en_speaker_0.npz -------------------------------------------------------------------------------- /bark/assets/prompts/en_speaker_1.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/en_speaker_1.npz -------------------------------------------------------------------------------- /bark/assets/prompts/en_speaker_2.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/en_speaker_2.npz -------------------------------------------------------------------------------- /bark/assets/prompts/en_speaker_3.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/en_speaker_3.npz -------------------------------------------------------------------------------- /bark/assets/prompts/en_speaker_4.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/en_speaker_4.npz -------------------------------------------------------------------------------- /bark/assets/prompts/en_speaker_5.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/en_speaker_5.npz -------------------------------------------------------------------------------- /bark/assets/prompts/en_speaker_6.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/en_speaker_6.npz -------------------------------------------------------------------------------- /bark/assets/prompts/en_speaker_7.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/en_speaker_7.npz -------------------------------------------------------------------------------- /bark/assets/prompts/en_speaker_8.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/en_speaker_8.npz -------------------------------------------------------------------------------- /bark/assets/prompts/en_speaker_9.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/en_speaker_9.npz -------------------------------------------------------------------------------- /bark/assets/prompts/es_speaker_0.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/es_speaker_0.npz -------------------------------------------------------------------------------- /bark/assets/prompts/es_speaker_1.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/es_speaker_1.npz -------------------------------------------------------------------------------- /bark/assets/prompts/es_speaker_2.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/es_speaker_2.npz -------------------------------------------------------------------------------- /bark/assets/prompts/es_speaker_3.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/es_speaker_3.npz -------------------------------------------------------------------------------- /bark/assets/prompts/es_speaker_4.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/es_speaker_4.npz -------------------------------------------------------------------------------- /bark/assets/prompts/es_speaker_5.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/es_speaker_5.npz -------------------------------------------------------------------------------- /bark/assets/prompts/es_speaker_6.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/es_speaker_6.npz -------------------------------------------------------------------------------- /bark/assets/prompts/es_speaker_7.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/es_speaker_7.npz -------------------------------------------------------------------------------- /bark/assets/prompts/es_speaker_8.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/es_speaker_8.npz -------------------------------------------------------------------------------- /bark/assets/prompts/es_speaker_9.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/es_speaker_9.npz -------------------------------------------------------------------------------- /bark/assets/prompts/fr_speaker_0.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/fr_speaker_0.npz -------------------------------------------------------------------------------- /bark/assets/prompts/fr_speaker_1.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/fr_speaker_1.npz -------------------------------------------------------------------------------- /bark/assets/prompts/fr_speaker_2.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/fr_speaker_2.npz -------------------------------------------------------------------------------- /bark/assets/prompts/fr_speaker_3.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/fr_speaker_3.npz -------------------------------------------------------------------------------- /bark/assets/prompts/fr_speaker_4.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/fr_speaker_4.npz -------------------------------------------------------------------------------- /bark/assets/prompts/fr_speaker_5.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/fr_speaker_5.npz -------------------------------------------------------------------------------- /bark/assets/prompts/fr_speaker_6.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/fr_speaker_6.npz -------------------------------------------------------------------------------- /bark/assets/prompts/fr_speaker_7.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/fr_speaker_7.npz -------------------------------------------------------------------------------- /bark/assets/prompts/fr_speaker_8.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/fr_speaker_8.npz -------------------------------------------------------------------------------- /bark/assets/prompts/fr_speaker_9.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/fr_speaker_9.npz -------------------------------------------------------------------------------- /bark/assets/prompts/hi_speaker_0.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/hi_speaker_0.npz -------------------------------------------------------------------------------- /bark/assets/prompts/hi_speaker_1.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/hi_speaker_1.npz -------------------------------------------------------------------------------- /bark/assets/prompts/hi_speaker_2.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/hi_speaker_2.npz -------------------------------------------------------------------------------- /bark/assets/prompts/hi_speaker_3.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/hi_speaker_3.npz -------------------------------------------------------------------------------- /bark/assets/prompts/hi_speaker_4.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/hi_speaker_4.npz -------------------------------------------------------------------------------- /bark/assets/prompts/hi_speaker_5.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/hi_speaker_5.npz -------------------------------------------------------------------------------- /bark/assets/prompts/hi_speaker_6.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/hi_speaker_6.npz -------------------------------------------------------------------------------- /bark/assets/prompts/hi_speaker_7.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/hi_speaker_7.npz -------------------------------------------------------------------------------- /bark/assets/prompts/hi_speaker_8.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/hi_speaker_8.npz -------------------------------------------------------------------------------- /bark/assets/prompts/hi_speaker_9.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/hi_speaker_9.npz -------------------------------------------------------------------------------- /bark/assets/prompts/it_speaker_0.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/it_speaker_0.npz -------------------------------------------------------------------------------- /bark/assets/prompts/it_speaker_1.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/it_speaker_1.npz -------------------------------------------------------------------------------- /bark/assets/prompts/it_speaker_2.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/it_speaker_2.npz -------------------------------------------------------------------------------- /bark/assets/prompts/it_speaker_3.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/it_speaker_3.npz -------------------------------------------------------------------------------- /bark/assets/prompts/it_speaker_4.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/it_speaker_4.npz -------------------------------------------------------------------------------- /bark/assets/prompts/it_speaker_5.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/it_speaker_5.npz -------------------------------------------------------------------------------- /bark/assets/prompts/it_speaker_6.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/it_speaker_6.npz -------------------------------------------------------------------------------- /bark/assets/prompts/it_speaker_7.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/it_speaker_7.npz -------------------------------------------------------------------------------- /bark/assets/prompts/it_speaker_8.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/it_speaker_8.npz -------------------------------------------------------------------------------- /bark/assets/prompts/it_speaker_9.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/it_speaker_9.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ja_speaker_0.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ja_speaker_0.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ja_speaker_1.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ja_speaker_1.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ja_speaker_2.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ja_speaker_2.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ja_speaker_3.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ja_speaker_3.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ja_speaker_4.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ja_speaker_4.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ja_speaker_5.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ja_speaker_5.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ja_speaker_6.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ja_speaker_6.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ja_speaker_7.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ja_speaker_7.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ja_speaker_8.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ja_speaker_8.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ja_speaker_9.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ja_speaker_9.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ko_speaker_0.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ko_speaker_0.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ko_speaker_1.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ko_speaker_1.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ko_speaker_2.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ko_speaker_2.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ko_speaker_3.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ko_speaker_3.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ko_speaker_4.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ko_speaker_4.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ko_speaker_5.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ko_speaker_5.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ko_speaker_6.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ko_speaker_6.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ko_speaker_7.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ko_speaker_7.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ko_speaker_8.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ko_speaker_8.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ko_speaker_9.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ko_speaker_9.npz -------------------------------------------------------------------------------- /bark/assets/prompts/pl_speaker_0.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/pl_speaker_0.npz -------------------------------------------------------------------------------- /bark/assets/prompts/pl_speaker_1.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/pl_speaker_1.npz -------------------------------------------------------------------------------- /bark/assets/prompts/pl_speaker_2.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/pl_speaker_2.npz -------------------------------------------------------------------------------- /bark/assets/prompts/pl_speaker_3.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/pl_speaker_3.npz -------------------------------------------------------------------------------- /bark/assets/prompts/pl_speaker_4.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/pl_speaker_4.npz -------------------------------------------------------------------------------- /bark/assets/prompts/pl_speaker_5.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/pl_speaker_5.npz -------------------------------------------------------------------------------- /bark/assets/prompts/pl_speaker_6.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/pl_speaker_6.npz -------------------------------------------------------------------------------- /bark/assets/prompts/pl_speaker_7.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/pl_speaker_7.npz -------------------------------------------------------------------------------- /bark/assets/prompts/pl_speaker_8.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/pl_speaker_8.npz -------------------------------------------------------------------------------- /bark/assets/prompts/pl_speaker_9.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/pl_speaker_9.npz -------------------------------------------------------------------------------- /bark/assets/prompts/pt_speaker_0.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/pt_speaker_0.npz -------------------------------------------------------------------------------- /bark/assets/prompts/pt_speaker_1.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/pt_speaker_1.npz -------------------------------------------------------------------------------- /bark/assets/prompts/pt_speaker_2.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/pt_speaker_2.npz -------------------------------------------------------------------------------- /bark/assets/prompts/pt_speaker_3.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/pt_speaker_3.npz -------------------------------------------------------------------------------- /bark/assets/prompts/pt_speaker_4.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/pt_speaker_4.npz -------------------------------------------------------------------------------- /bark/assets/prompts/pt_speaker_5.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/pt_speaker_5.npz -------------------------------------------------------------------------------- /bark/assets/prompts/pt_speaker_6.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/pt_speaker_6.npz -------------------------------------------------------------------------------- /bark/assets/prompts/pt_speaker_7.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/pt_speaker_7.npz -------------------------------------------------------------------------------- /bark/assets/prompts/pt_speaker_8.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/pt_speaker_8.npz -------------------------------------------------------------------------------- /bark/assets/prompts/pt_speaker_9.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/pt_speaker_9.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ru_speaker_0.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ru_speaker_0.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ru_speaker_1.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ru_speaker_1.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ru_speaker_2.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ru_speaker_2.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ru_speaker_3.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ru_speaker_3.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ru_speaker_4.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ru_speaker_4.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ru_speaker_5.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ru_speaker_5.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ru_speaker_6.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ru_speaker_6.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ru_speaker_7.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ru_speaker_7.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ru_speaker_8.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ru_speaker_8.npz -------------------------------------------------------------------------------- /bark/assets/prompts/ru_speaker_9.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/ru_speaker_9.npz -------------------------------------------------------------------------------- /bark/assets/prompts/tr_speaker_0.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/tr_speaker_0.npz -------------------------------------------------------------------------------- /bark/assets/prompts/tr_speaker_1.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/tr_speaker_1.npz -------------------------------------------------------------------------------- /bark/assets/prompts/tr_speaker_2.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/tr_speaker_2.npz -------------------------------------------------------------------------------- /bark/assets/prompts/tr_speaker_3.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/tr_speaker_3.npz -------------------------------------------------------------------------------- /bark/assets/prompts/tr_speaker_4.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/tr_speaker_4.npz -------------------------------------------------------------------------------- /bark/assets/prompts/tr_speaker_5.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/tr_speaker_5.npz -------------------------------------------------------------------------------- /bark/assets/prompts/tr_speaker_6.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/tr_speaker_6.npz -------------------------------------------------------------------------------- /bark/assets/prompts/tr_speaker_7.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/tr_speaker_7.npz -------------------------------------------------------------------------------- /bark/assets/prompts/tr_speaker_8.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/tr_speaker_8.npz -------------------------------------------------------------------------------- /bark/assets/prompts/tr_speaker_9.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/tr_speaker_9.npz -------------------------------------------------------------------------------- /bark/assets/prompts/zh_speaker_0.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/zh_speaker_0.npz -------------------------------------------------------------------------------- /bark/assets/prompts/zh_speaker_1.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/zh_speaker_1.npz -------------------------------------------------------------------------------- /bark/assets/prompts/zh_speaker_2.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/zh_speaker_2.npz -------------------------------------------------------------------------------- /bark/assets/prompts/zh_speaker_3.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/zh_speaker_3.npz -------------------------------------------------------------------------------- /bark/assets/prompts/zh_speaker_4.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/zh_speaker_4.npz -------------------------------------------------------------------------------- /bark/assets/prompts/zh_speaker_5.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/zh_speaker_5.npz -------------------------------------------------------------------------------- /bark/assets/prompts/zh_speaker_6.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/zh_speaker_6.npz -------------------------------------------------------------------------------- /bark/assets/prompts/zh_speaker_7.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/zh_speaker_7.npz -------------------------------------------------------------------------------- /bark/assets/prompts/zh_speaker_8.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/zh_speaker_8.npz -------------------------------------------------------------------------------- /bark/assets/prompts/zh_speaker_9.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/bark/assets/prompts/zh_speaker_9.npz -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__/ 2 | **/venv/* 3 | suno_bark.egg-info 4 | build 5 | references 6 | 7 | *.wav 8 | _temp/ 9 | datasets/ 10 | models/ 11 | 12 | **/runs/ -------------------------------------------------------------------------------- /bark/__init__.py: -------------------------------------------------------------------------------- 1 | from .api import generate_audio, text_to_semantic, semantic_to_waveform, save_as_prompt 2 | from .generation import SAMPLE_RATE, preload_models 3 | -------------------------------------------------------------------------------- /notebooks/runs/linear_projection/events.out.tfevents.1683572933.melchior.7747.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/notebooks/runs/linear_projection/events.out.tfevents.1683572933.melchior.7747.0 -------------------------------------------------------------------------------- /notebooks/runs/linear_projection/events.out.tfevents.1683574068.melchior.7747.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/notebooks/runs/linear_projection/events.out.tfevents.1683574068.melchior.7747.1 -------------------------------------------------------------------------------- /notebooks/runs/linear_projection/events.out.tfevents.1683574191.melchior.7747.2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/notebooks/runs/linear_projection/events.out.tfevents.1683574191.melchior.7747.2 -------------------------------------------------------------------------------- /notebooks/runs/linear_projection/events.out.tfevents.1683575623.melchior.7747.3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/notebooks/runs/linear_projection/events.out.tfevents.1683575623.melchior.7747.3 -------------------------------------------------------------------------------- /notebooks/runs/linear_projection/events.out.tfevents.1683575632.melchior.7747.4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/notebooks/runs/linear_projection/events.out.tfevents.1683575632.melchior.7747.4 -------------------------------------------------------------------------------- /notebooks/runs/linear_projection/events.out.tfevents.1683576047.melchior.7747.5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/notebooks/runs/linear_projection/events.out.tfevents.1683576047.melchior.7747.5 -------------------------------------------------------------------------------- /notebooks/runs/linear_projection/events.out.tfevents.1683576055.melchior.7747.6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/notebooks/runs/linear_projection/events.out.tfevents.1683576055.melchior.7747.6 -------------------------------------------------------------------------------- /notebooks/runs/linear_projection/events.out.tfevents.1683576273.melchior.7747.7: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/notebooks/runs/linear_projection/events.out.tfevents.1683576273.melchior.7747.7 -------------------------------------------------------------------------------- /notebooks/runs/linear_projection/events.out.tfevents.1683577423.melchior.7747.8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EndlessReform/bark-with-voice-clone/HEAD/notebooks/runs/linear_projection/events.out.tfevents.1683577423.melchior.7747.8 -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | [project] 6 | name = "suno-bark" 7 | version = "0.0.1a" 8 | description = "Bark text to audio model" 9 | readme = "README.md" 10 | requires-python = ">=3.8" 11 | authors = [ 12 | {name = "Suno Inc", email = "hello@suno.ai"}, 13 | ] 14 | # Apache 2.0 15 | license = {file = "LICENSE"} 16 | 17 | dependencies = [ 18 | "boto3", 19 | "encodec", 20 | "funcy", 21 | "numpy", 22 | "scipy", 23 | "tokenizers", 24 | "torch==2.0.0+cu118", 25 | "tqdm", 26 | "transformers", 27 | ] 28 | 29 | [project.urls] 30 | source = "https://github.com/suno-ai/bark" 31 | 32 | [project.optional-dependencies] 33 | dev = [ 34 | "bandit", 35 | "black", 36 | "codecov", 37 | "flake8", 38 | "huggingface-hub", 39 | "hypothesis>=6.14,<7", 40 | "isort>=5.0.0,<6", 41 | "jupyter", 42 | "mypy", 43 | "nbconvert", 44 | "nbformat", 45 | "pydocstyle", 46 | "pylint", 47 | "pytest", 48 | "pytest-cov", 49 | ] 50 | 51 | [tool.setuptools] 52 | packages = ["bark"] 53 | 54 | [tool.setuptools.package-data] 55 | bark = ["assets/prompts/*.npz"] 56 | 57 | [tool.black] 58 | line-length = 100 59 | -------------------------------------------------------------------------------- /bark/assets/prompts/readme.md: -------------------------------------------------------------------------------- 1 | # Example Prompts Data 2 | 3 | The provided data is in the .npz format, which is a file format used in Python for storing arrays and data. The data contains three arrays: semantic_prompt, coarse_prompt, and fine_prompt. 4 | 5 | ```semantic_prompt``` 6 | 7 | The semantic_prompt array contains a sequence of token IDs generated by the BERT tokenizer from Hugging Face. These tokens encode the text input and are used as an input to generate the audio output. The shape of this array is (n,), where n is the number of tokens in the input text. 8 | 9 | ```coarse_prompt``` 10 | 11 | The coarse_prompt array is an intermediate output of the text-to-speech pipeline, and contains token IDs generated by the first two codebooks of the EnCodec Codec from Facebook. This step converts the semantic tokens into a different representation that is better suited for the subsequent step. The shape of this array is (2, m), where m is the number of tokens after conversion by the EnCodec Codec. 12 | 13 | ```fine_prompt``` 14 | 15 | The fine_prompt array is a further processed output of the pipeline, and contains 8 codebooks from the EnCodec Codec. These codebooks represent the final stage of tokenization, and the resulting tokens are used to generate the audio output. The shape of this array is (8, p), where p is the number of tokens after further processing by the EnCodec Codec. 16 | 17 | Overall, these arrays represent different stages of a text-to-speech pipeline that converts text input into synthesized audio output. The semantic_prompt array represents the input text, while coarse_prompt and fine_prompt represent intermediate and final stages of tokenization, respectively. 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /model-card.md: -------------------------------------------------------------------------------- 1 | # Model Card: Bark 2 | 3 | This is the official codebase for running the text to audio model, from Suno.ai. 4 | 5 | The following is additional information about the models released here. 6 | 7 | ## Model Details 8 | 9 | Bark is a series of three transformer models that turn text into audio. 10 | ### Text to semantic tokens 11 | - Input: text, tokenized with [BERT tokenizer from Hugging Face](https://huggingface.co/docs/transformers/model_doc/bert#transformers.BertTokenizer) 12 | - Output: semantic tokens that encode the audio to be generated 13 | 14 | ### Semantic to coarse tokens 15 | - Input: semantic tokens 16 | - Output: tokens from the first two codebooks of the [EnCodec Codec](https://github.com/facebookresearch/encodec) from facebook 17 | 18 | ### Coarse to fine tokens 19 | - Input: the first two codebooks from EnCodec 20 | - Output: 8 codebooks from EnCodec 21 | 22 | ### Architecture 23 | | Model | Parameters | Attention | Output Vocab size | 24 | |:-------------------------:|:----------:|------------|:-----------------:| 25 | | Text to semantic tokens | 80 M | Causal | 10,000 | 26 | | Semantic to coarse tokens | 80 M | Causal | 2x 1,024 | 27 | | Coarse to fine tokens | 80 M | Non-causal | 6x 1,024 | 28 | 29 | 30 | ### Release date 31 | April 2023 32 | 33 | ## Broader Implications 34 | We anticipate that this model's text to audio capabilities can be used to improve accessbility tools in a variety of languages. 35 | Straightforward improvements will allow models to run faster than realtime, rendering them useful for applications such as virtual assistants. 36 | 37 | While we hope that this release will enable users to express their creativity and build applications that are a force 38 | for good, we acknowledge that any text to audio model has the potential for dual use. While it is not straightforward 39 | to voice clone known people with Bark, they can still be used for nefarious purposes. To further reduce the chances of unintended use of Bark, 40 | we also release a simple classifier to detect Bark-generated audio with high accuracy (see notebooks section of the main repository). 41 | -------------------------------------------------------------------------------- /generate.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "from bark.api import generate_audio\n", 10 | "from transformers import BertTokenizer\n", 11 | "from bark.generation import SAMPLE_RATE, preload_models, codec_decode, generate_coarse, generate_fine, generate_text_semantic\n", 12 | "\n", 13 | "# Enter your prompt and speaker here\n", 14 | "text_prompt = \"Hello, my name is Serpy. And, uh — and I like pizza. [laughs]\"\n", 15 | "voice_name = \"speaker_0\" # use your custom voice name here if you have one\n", 16 | "\n", 17 | "# load the tokenizer\n", 18 | "tokenizer = BertTokenizer.from_pretrained(\"bert-base-multilingual-cased\")" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": null, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "# download and load all models\n", 28 | "preload_models(\n", 29 | " text_use_gpu=True,\n", 30 | " text_use_small=False,\n", 31 | " coarse_use_gpu=True,\n", 32 | " coarse_use_small=False,\n", 33 | " fine_use_gpu=True,\n", 34 | " fine_use_small=False,\n", 35 | " codec_use_gpu=True,\n", 36 | " force_reload=False,\n", 37 | " path=\"models\"\n", 38 | ")" 39 | ] 40 | }, 41 | { 42 | "cell_type": "code", 43 | "execution_count": null, 44 | "metadata": {}, 45 | "outputs": [], 46 | "source": [ 47 | "# simple generation\n", 48 | "audio_array = generate_audio(text_prompt, history_prompt=voice_name, text_temp=0.7, waveform_temp=0.7)" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": null, 54 | "metadata": {}, 55 | "outputs": [], 56 | "source": [ 57 | "# generation with more control\n", 58 | "x_semantic = generate_text_semantic(\n", 59 | " text_prompt,\n", 60 | " history_prompt=voice_name,\n", 61 | " temp=0.7,\n", 62 | " top_k=50,\n", 63 | " top_p=0.95,\n", 64 | ")\n", 65 | "\n", 66 | "x_coarse_gen = generate_coarse(\n", 67 | " x_semantic,\n", 68 | " history_prompt=voice_name,\n", 69 | " temp=0.7,\n", 70 | " top_k=50,\n", 71 | " top_p=0.95,\n", 72 | ")\n", 73 | "x_fine_gen = generate_fine(\n", 74 | " x_coarse_gen,\n", 75 | " history_prompt=voice_name,\n", 76 | " temp=0.5,\n", 77 | ")\n", 78 | "audio_array = codec_decode(x_fine_gen)" 79 | ] 80 | }, 81 | { 82 | "cell_type": "code", 83 | "execution_count": null, 84 | "metadata": {}, 85 | "outputs": [], 86 | "source": [ 87 | "from IPython.display import Audio\n", 88 | "# play audio\n", 89 | "Audio(audio_array, rate=SAMPLE_RATE)" 90 | ] 91 | }, 92 | { 93 | "cell_type": "code", 94 | "execution_count": null, 95 | "metadata": {}, 96 | "outputs": [], 97 | "source": [ 98 | "from scipy.io.wavfile import write as write_wav\n", 99 | "# save audio\n", 100 | "filepath = \"/output/audio.wav\" # change this to your desired output path\n", 101 | "write_wav(filepath, SAMPLE_RATE, audio_array)" 102 | ] 103 | }, 104 | { 105 | "cell_type": "code", 106 | "execution_count": null, 107 | "metadata": {}, 108 | "outputs": [], 109 | "source": [] 110 | } 111 | ], 112 | "metadata": { 113 | "kernelspec": { 114 | "display_name": "Python 3", 115 | "language": "python", 116 | "name": "python3" 117 | }, 118 | "language_info": { 119 | "codemirror_mode": { 120 | "name": "ipython", 121 | "version": 3 122 | }, 123 | "file_extension": ".py", 124 | "mimetype": "text/x-python", 125 | "name": "python", 126 | "nbconvert_exporter": "python", 127 | "pygments_lexer": "ipython3", 128 | "version": "3.10.8" 129 | }, 130 | "orig_nbformat": 4 131 | }, 132 | "nbformat": 4, 133 | "nbformat_minor": 2 134 | } 135 | -------------------------------------------------------------------------------- /bark/api.py: -------------------------------------------------------------------------------- 1 | from typing import Optional 2 | 3 | import numpy as np 4 | 5 | from .generation import codec_decode, generate_coarse, generate_fine, generate_text_semantic 6 | 7 | 8 | def text_to_semantic( 9 | text: str, 10 | history_prompt: Optional[str] = None, 11 | temp: float = 0.7, 12 | silent: bool = False, 13 | ): 14 | """Generate semantic array from text. 15 | 16 | Args: 17 | text: text to be turned into audio 18 | history_prompt: history choice for audio cloning 19 | temp: generation temperature (1.0 more diverse, 0.0 more conservative) 20 | silent: disable progress bar 21 | 22 | Returns: 23 | numpy semantic array to be fed into `semantic_to_waveform` 24 | """ 25 | x_semantic = generate_text_semantic( 26 | text, 27 | history_prompt=history_prompt, 28 | temp=temp, 29 | silent=silent, 30 | use_kv_caching=True 31 | ) 32 | return x_semantic 33 | 34 | 35 | def semantic_to_waveform( 36 | semantic_tokens: np.ndarray, 37 | history_prompt: Optional[str] = None, 38 | temp: float = 0.7, 39 | silent: bool = False, 40 | output_full: bool = False, 41 | ): 42 | """Generate audio array from semantic input. 43 | 44 | Args: 45 | semantic_tokens: semantic token output from `text_to_semantic` 46 | history_prompt: history choice for audio cloning 47 | temp: generation temperature (1.0 more diverse, 0.0 more conservative) 48 | silent: disable progress bar 49 | output_full: return full generation to be used as a history prompt 50 | 51 | Returns: 52 | numpy audio array at sample frequency 24khz 53 | """ 54 | coarse_tokens = generate_coarse( 55 | semantic_tokens, 56 | history_prompt=history_prompt, 57 | temp=temp, 58 | silent=silent, 59 | use_kv_caching=True 60 | ) 61 | fine_tokens = generate_fine( 62 | coarse_tokens, 63 | history_prompt=history_prompt, 64 | temp=0.5, 65 | ) 66 | audio_arr = codec_decode(fine_tokens) 67 | if output_full: 68 | full_generation = { 69 | "semantic_prompt": semantic_tokens, 70 | "coarse_prompt": coarse_tokens, 71 | "fine_prompt": fine_tokens, 72 | } 73 | return full_generation, audio_arr 74 | return audio_arr 75 | 76 | 77 | def save_as_prompt(filepath, full_generation): 78 | assert(filepath.endswith(".npz")) 79 | assert(isinstance(full_generation, dict)) 80 | assert("semantic_prompt" in full_generation) 81 | assert("coarse_prompt" in full_generation) 82 | assert("fine_prompt" in full_generation) 83 | np.savez(filepath, **full_generation) 84 | 85 | 86 | def generate_audio( 87 | text: str, 88 | history_prompt: Optional[str] = None, 89 | text_temp: float = 0.7, 90 | waveform_temp: float = 0.7, 91 | silent: bool = False, 92 | output_full: bool = False, 93 | ): 94 | """Generate audio array from input text. 95 | 96 | Args: 97 | text: text to be turned into audio 98 | history_prompt: history choice for audio cloning 99 | text_temp: generation temperature (1.0 more diverse, 0.0 more conservative) 100 | waveform_temp: generation temperature (1.0 more diverse, 0.0 more conservative) 101 | silent: disable progress bar 102 | output_full: return full generation to be used as a history prompt 103 | 104 | Returns: 105 | numpy audio array at sample frequency 24khz 106 | """ 107 | semantic_tokens = text_to_semantic( 108 | text, 109 | history_prompt=history_prompt, 110 | temp=text_temp, 111 | silent=silent, 112 | ) 113 | out = semantic_to_waveform( 114 | semantic_tokens, 115 | history_prompt=history_prompt, 116 | temp=waveform_temp, 117 | silent=silent, 118 | output_full=output_full, 119 | ) 120 | if output_full: 121 | full_generation, audio_arr = out 122 | return full_generation, audio_arr 123 | else: 124 | audio_arr = out 125 | return audio_arr 126 | -------------------------------------------------------------------------------- /bark/model_fine.py: -------------------------------------------------------------------------------- 1 | """ 2 | Much of this code is adapted from Andrej Karpathy's NanoGPT 3 | (https://github.com/karpathy/nanoGPT) 4 | """ 5 | from dataclasses import dataclass 6 | import math 7 | 8 | import torch 9 | import torch.nn as nn 10 | from torch.nn import functional as F 11 | 12 | from .model import GPT, GPTConfig, MLP 13 | 14 | 15 | class NonCausalSelfAttention(nn.Module): 16 | def __init__(self, config): 17 | super().__init__() 18 | assert config.n_embd % config.n_head == 0 19 | # key, query, value projections for all heads, but in a batch 20 | self.c_attn = nn.Linear(config.n_embd, 3 * config.n_embd, bias=config.bias) 21 | # output projection 22 | self.c_proj = nn.Linear(config.n_embd, config.n_embd, bias=config.bias) 23 | # regularization 24 | self.attn_dropout = nn.Dropout(config.dropout) 25 | self.resid_dropout = nn.Dropout(config.dropout) 26 | self.n_head = config.n_head 27 | self.n_embd = config.n_embd 28 | self.dropout = config.dropout 29 | # flash attention make GPU go brrrrr but support is only in PyTorch nightly and still a bit scary 30 | self.flash = ( 31 | hasattr(torch.nn.functional, "scaled_dot_product_attention") and self.dropout == 0.0 32 | ) 33 | 34 | def forward(self, x): 35 | B, T, C = x.size() # batch size, sequence length, embedding dimensionality (n_embd) 36 | 37 | # calculate query, key, values for all heads in batch and move head forward to be the batch dim 38 | q, k, v = self.c_attn(x).split(self.n_embd, dim=2) 39 | k = k.view(B, T, self.n_head, C // self.n_head).transpose(1, 2) # (B, nh, T, hs) 40 | q = q.view(B, T, self.n_head, C // self.n_head).transpose(1, 2) # (B, nh, T, hs) 41 | v = v.view(B, T, self.n_head, C // self.n_head).transpose(1, 2) # (B, nh, T, hs) 42 | 43 | # causal self-attention; Self-attend: (B, nh, T, hs) x (B, nh, hs, T) -> (B, nh, T, T) 44 | if self.flash: 45 | # efficient attention using Flash Attention CUDA kernels 46 | y = torch.nn.functional.scaled_dot_product_attention( 47 | q, k, v, attn_mask=None, dropout_p=self.dropout, is_causal=False 48 | ) 49 | else: 50 | # manual implementation of attention 51 | att = (q @ k.transpose(-2, -1)) * (1.0 / math.sqrt(k.size(-1))) 52 | att = F.softmax(att, dim=-1) 53 | att = self.attn_dropout(att) 54 | y = att @ v # (B, nh, T, T) x (B, nh, T, hs) -> (B, nh, T, hs) 55 | y = ( 56 | y.transpose(1, 2).contiguous().view(B, T, C) 57 | ) # re-assemble all head outputs side by side 58 | 59 | # output projection 60 | y = self.resid_dropout(self.c_proj(y)) 61 | return y 62 | 63 | 64 | class FineBlock(nn.Module): 65 | def __init__(self, config): 66 | super().__init__() 67 | self.ln_1 = nn.LayerNorm(config.n_embd) 68 | self.attn = NonCausalSelfAttention(config) 69 | self.ln_2 = nn.LayerNorm(config.n_embd) 70 | self.mlp = MLP(config) 71 | 72 | def forward(self, x): 73 | x = x + self.attn(self.ln_1(x)) 74 | x = x + self.mlp(self.ln_2(x)) 75 | return x 76 | 77 | 78 | class FineGPT(GPT): 79 | def __init__(self, config): 80 | super().__init__(config) 81 | del self.lm_head 82 | self.config = config 83 | self.n_codes_total = config.n_codes_total 84 | self.transformer = nn.ModuleDict( 85 | dict( 86 | wtes=nn.ModuleList( 87 | [ 88 | nn.Embedding(config.input_vocab_size, config.n_embd) 89 | for _ in range(config.n_codes_total) 90 | ] 91 | ), 92 | wpe=nn.Embedding(config.block_size, config.n_embd), 93 | drop=nn.Dropout(config.dropout), 94 | h=nn.ModuleList([FineBlock(config) for _ in range(config.n_layer)]), 95 | ln_f=nn.LayerNorm(config.n_embd), 96 | ) 97 | ) 98 | self.lm_heads = nn.ModuleList( 99 | [ 100 | nn.Linear(config.n_embd, config.output_vocab_size, bias=False) 101 | for _ in range(config.n_codes_given, self.n_codes_total) 102 | ] 103 | ) 104 | for i in range(self.n_codes_total - config.n_codes_given): 105 | self.transformer.wtes[i + 1].weight = self.lm_heads[i].weight 106 | 107 | def forward(self, pred_idx, idx): 108 | device = idx.device 109 | b, t, codes = idx.size() 110 | assert ( 111 | t <= self.config.block_size 112 | ), f"Cannot forward sequence of length {t}, block size is only {self.config.block_size}" 113 | assert pred_idx > 0, "cannot predict 0th codebook" 114 | assert codes == self.n_codes_total, (b, t, codes) 115 | pos = torch.arange(0, t, dtype=torch.long, device=device).unsqueeze(0) # shape (1, t) 116 | 117 | # forward the GPT model itself 118 | tok_embs = [ 119 | wte(idx[:, :, i]).unsqueeze(-1) for i, wte in enumerate(self.transformer.wtes) 120 | ] # token embeddings of shape (b, t, n_embd) 121 | tok_emb = torch.cat(tok_embs, dim=-1) 122 | pos_emb = self.transformer.wpe(pos) # position embeddings of shape (1, t, n_embd) 123 | x = tok_emb[:, :, :, : pred_idx + 1].sum(dim=-1) 124 | x = self.transformer.drop(x + pos_emb) 125 | for block in self.transformer.h: 126 | x = block(x) 127 | x = self.transformer.ln_f(x) 128 | logits = self.lm_heads[pred_idx - self.config.n_codes_given](x) 129 | return logits 130 | 131 | def get_num_params(self, non_embedding=True): 132 | """ 133 | Return the number of parameters in the model. 134 | For non-embedding count (default), the position embeddings get subtracted. 135 | The token embeddings would too, except due to the parameter sharing these 136 | params are actually used as weights in the final layer, so we include them. 137 | """ 138 | n_params = sum(p.numel() for p in self.parameters()) 139 | if non_embedding: 140 | for wte in self.transformer.wtes: 141 | n_params -= wte.weight.numel() 142 | n_params -= self.transformer.wpe.weight.numel() 143 | return n_params 144 | 145 | 146 | @dataclass 147 | class FineGPTConfig(GPTConfig): 148 | n_codes_total: int = 8 149 | n_codes_given: int = 1 150 | -------------------------------------------------------------------------------- /notebooks/create_dataset.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 2, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stderr", 10 | "output_type": "stream", 11 | "text": [ 12 | "/home/ritsuko/projects/ai/audio/bark/venv/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", 13 | " from .autonotebook import tqdm as notebook_tqdm\n" 14 | ] 15 | } 16 | ], 17 | "source": [ 18 | "#%pip install resampy\n", 19 | "import numpy as np\n", 20 | "import os\n", 21 | "from pprint import pprint\n", 22 | "from bark.api import text_to_semantic, semantic_to_waveform, generate_audio\n", 23 | "from bark.generation import SAMPLE_RATE, generate_text_semantic, SEMANTIC_RATE_HZ\n", 24 | "from IPython.display import Audio\n", 25 | "from scipy.io.wavfile import write as write_wav\n", 26 | "from datetime import datetime\n", 27 | "import torch\n", 28 | "import torchaudio\n", 29 | "import soundfile\n", 30 | "import resampy\n", 31 | "import sys" 32 | ] 33 | }, 34 | { 35 | "attachments": {}, 36 | "cell_type": "markdown", 37 | "metadata": {}, 38 | "source": [ 39 | "## Generate synthetic dataset\n", 40 | "\n", 41 | "This notebook creates a synthetic dataset of audio: semantic tokens pairs based on voice line prompts from Mozilla CommonVoice. The purpose of this dataset is to reconstruct the Bark semantic tokens codebook, which will enable us to convert ground-truth audio to a semantic prompt for use in fine-tuning and voice cloning. This notebook provides step-by-step instructions for creating the synthetic dataset and saving it in Fairseq dataset format. Let's get started!\n" 42 | ] 43 | }, 44 | { 45 | "attachments": {}, 46 | "cell_type": "markdown", 47 | "metadata": {}, 48 | "source": [ 49 | "For prototyping, we generate voice lines based on metadata from an old version of the [Mozilla CommonVoice dataset](https://www.kaggle.com/datasets/nickj26/common-voice-corpus-1?resource=download&select=validated.tsv) metadata. This is far from ideal; down the pike, we need a much more larger dataset with more diverse voice lines, including multilingual and non-spoken." 50 | ] 51 | }, 52 | { 53 | "cell_type": "code", 54 | "execution_count": 3, 55 | "metadata": {}, 56 | "outputs": [ 57 | { 58 | "data": { 59 | "text/plain": [ 60 | "Index(['client_id', 'path', 'sentence', 'up_votes', 'down_votes', 'age',\n", 61 | " 'gender', 'accent'],\n", 62 | " dtype='object')" 63 | ] 64 | }, 65 | "execution_count": 3, 66 | "metadata": {}, 67 | "output_type": "execute_result" 68 | } 69 | ], 70 | "source": [ 71 | "import pandas as pd\n", 72 | "\n", 73 | "CV_METADATA_PATH = '../datasets/validated.tsv'\n", 74 | "df = pd.read_csv(CV_METADATA_PATH, sep=\"\\t\")\n", 75 | "df.columns" 76 | ] 77 | }, 78 | { 79 | "cell_type": "code", 80 | "execution_count": 4, 81 | "metadata": {}, 82 | "outputs": [ 83 | { 84 | "data": { 85 | "text/plain": [ 86 | "array(['To give chalk for cheese', 'Judge may not think so.',\n", 87 | " 'I have already described the appearance of that colossal bulk which was embedded in the ground.',\n", 88 | " ..., \"How's the forecast for VI\",\n", 89 | " 'Please look up the Jenny of the Prairie television show.',\n", 90 | " 'Find me the creative work The Pickwick Papers'], dtype=object)" 91 | ] 92 | }, 93 | "execution_count": 4, 94 | "metadata": {}, 95 | "output_type": "execute_result" 96 | } 97 | ], 98 | "source": [ 99 | "# Preview\n", 100 | "lines = df[\"sentence\"].unique()\n", 101 | "lines" 102 | ] 103 | }, 104 | { 105 | "attachments": {}, 106 | "cell_type": "markdown", 107 | "metadata": {}, 108 | "source": [ 109 | "There are enough English lines for ~25 hours of audio with unique voice lines; _hopefully_ we'll need less than that." 110 | ] 111 | }, 112 | { 113 | "cell_type": "code", 114 | "execution_count": 5, 115 | "metadata": {}, 116 | "outputs": [], 117 | "source": [ 118 | "# Force cu118 generation if available\n", 119 | "#%pip install torch torchaudio --force --extra-index-url https://download.pytorch.org/whl/cu118" 120 | ] 121 | }, 122 | { 123 | "cell_type": "code", 124 | "execution_count": null, 125 | "metadata": {}, 126 | "outputs": [], 127 | "source": [ 128 | "minutes_to_generate = 3 * 60\n", 129 | "# Line index in commonvoice to start with. Useful when resuming\n", 130 | "start_line = 10307" 131 | ] 132 | }, 133 | { 134 | "cell_type": "code", 135 | "execution_count": 10, 136 | "metadata": {}, 137 | "outputs": [], 138 | "source": [ 139 | "%%capture log\n", 140 | "minutes_generated = 0\n", 141 | "\n", 142 | "label_file = open('../datasets/en/labels.txt', \"a\")\n", 143 | "manifest_file = open('../datasets/en/manifest.tsv', 'a')\n", 144 | "# Give TSV header at beginning.\n", 145 | "# No, this isn't robust. Too bad!\n", 146 | "if start_line == 0:\n", 147 | " manifest_file.write(str(os.path.abspath(\"../datasets/en\")) + \"\\n\")\n", 148 | "\n", 149 | "# Because HuBERT is trained on 16khz data\n", 150 | "OUTPUT_SAMPLE_RATE = 16_000\n", 151 | "resampler = torchaudio.transforms.Resample(orig_freq=SAMPLE_RATE, new_freq=OUTPUT_SAMPLE_RATE)\n", 152 | "\n", 153 | "for i, line in enumerate(lines[start_line:]):\n", 154 | " try:\n", 155 | " semantic_tokens = generate_text_semantic(text=line, temp=1)\n", 156 | " waveform_arr = semantic_to_waveform(semantic_tokens)\n", 157 | "\n", 158 | " # Persist sequence to new line\n", 159 | " label_file.write(' '.join(list(map(str, semantic_tokens.tolist()))) + \"\\n\")\n", 160 | " label_file.flush()\n", 161 | "\n", 162 | " # Downsample generated audio to 16khz and save \n", 163 | " waveform_tensor = torch.from_numpy(waveform_arr)\n", 164 | " resampled_tensor = resampler(waveform_tensor).unsqueeze(0)\n", 165 | " wav_fname = f\"en_{start_line + i}_{line}.wav\"\n", 166 | " wav_filepath = f\"../datasets/en/{wav_fname}\"\n", 167 | " torchaudio.save(wav_filepath, resampled_tensor, OUTPUT_SAMPLE_RATE)\n", 168 | "\n", 169 | " # Log info to manifest\n", 170 | " seconds_generated = len(semantic_tokens) / SEMANTIC_RATE_HZ\n", 171 | " manifest_file.write(f\"{wav_fname}\\t{resampled_tensor.shape[1]}\" + \"\\n\")\n", 172 | " manifest_file.flush()\n", 173 | "\n", 174 | " # Cutoff when sufficient data\n", 175 | " minutes_generated += seconds_generated / 60\n", 176 | " print(f\"Minutes of audio: {minutes_generated}\")\n", 177 | " if minutes_generated > minutes_to_generate:\n", 178 | " break\n", 179 | " except:\n", 180 | " pass" 181 | ] 182 | }, 183 | { 184 | "attachments": {}, 185 | "cell_type": "markdown", 186 | "metadata": {}, 187 | "source": [ 188 | "## ONE-OFF: Convert existing model to new\n", 189 | "\n", 190 | "DELETE THIS after finishing and verifying correctness!" 191 | ] 192 | }, 193 | { 194 | "cell_type": "code", 195 | "execution_count": 12, 196 | "metadata": {}, 197 | "outputs": [], 198 | "source": [ 199 | "# Create labels\n", 200 | "import glob\n", 201 | "\n", 202 | "old_folder_path = '../datasets/en_old/'\n", 203 | "search_pattern = os.path.join(old_folder_path, \"*.wav\")\n", 204 | "\n", 205 | "label_file = open(f'{old_folder_path}/labels.txt', \"w\")\n", 206 | "manifest_file = open(f'{old_folder_path}/manifest.tsv', 'w')\n", 207 | "manifest_file.write(str(os.path.abspath(\"../datasets/en_old\")) + \"\\n\")\n", 208 | "\n", 209 | "OUTPUT_SAMPLE_RATE = 16_000\n", 210 | "resampler = torchaudio.transforms.Resample(orig_freq=SAMPLE_RATE, new_freq=OUTPUT_SAMPLE_RATE)\n", 211 | "\n", 212 | "for wav_filename in glob.glob(search_pattern):\n", 213 | " # Load file\n", 214 | " basename = os.path.basename(wav_filename)\n", 215 | " wav, sr = torchaudio.load(wav_filename)\n", 216 | "\n", 217 | " # Convert to 16khz and overwrite original\n", 218 | " if sr != 16_000:\n", 219 | " resampled_tensor = resampler(wav)\n", 220 | " torchaudio.save(wav_filename, resampled_tensor, OUTPUT_SAMPLE_RATE)\n", 221 | " manifest_file.write(f\"{basename}\\t{resampled_tensor.shape[1]}\\n\")\n", 222 | " else:\n", 223 | " manifest_file.write(f\"{basename}\\t{wav.shape[1]}\\n\")\n", 224 | "\n", 225 | " \n", 226 | " manifest_file.flush()\n", 227 | " semantic_history = np.load(\n", 228 | " os.path.join(old_folder_path, f\"{basename[2:-4]}.npz\")\n", 229 | " )[\"tokens\"]\n", 230 | " wav_length_seconds = len(semantic_history) / 49.9\n", 231 | "\n", 232 | " # Add manifest entry\n", 233 | "\n", 234 | " # Write tokens to label file\n", 235 | " label_file.write(f'{\" \".join(list(map(str, semantic_history.tolist())))}\\n')\n", 236 | " label_file.flush()\n", 237 | "\n", 238 | " # Try only one for now\n" 239 | ] 240 | } 241 | ], 242 | "metadata": { 243 | "kernelspec": { 244 | "display_name": "venv", 245 | "language": "python", 246 | "name": "python3" 247 | }, 248 | "language_info": { 249 | "codemirror_mode": { 250 | "name": "ipython", 251 | "version": 3 252 | }, 253 | "file_extension": ".py", 254 | "mimetype": "text/x-python", 255 | "name": "python", 256 | "nbconvert_exporter": "python", 257 | "pygments_lexer": "ipython3", 258 | "version": "3.10.9" 259 | }, 260 | "orig_nbformat": 4, 261 | "vscode": { 262 | "interpreter": { 263 | "hash": "790f29072abc26870ccb3736e8ffe1b6fbe9bdb3e500c5faf362e772e52ef00f" 264 | } 265 | } 266 | }, 267 | "nbformat": 4, 268 | "nbformat_minor": 2 269 | } 270 | -------------------------------------------------------------------------------- /bark/model.py: -------------------------------------------------------------------------------- 1 | """ 2 | Much of this code is adapted from Andrej Karpathy's NanoGPT 3 | (https://github.com/karpathy/nanoGPT) 4 | """ 5 | import math 6 | import numpy as np 7 | from dataclasses import dataclass 8 | 9 | import torch 10 | import torch.nn as nn 11 | from torch.nn import functional as F 12 | 13 | 14 | class LayerNorm(nn.Module): 15 | """LayerNorm but with an optional bias. PyTorch doesn't support simply bias=False""" 16 | 17 | def __init__(self, ndim, bias): 18 | super().__init__() 19 | self.weight = nn.Parameter(torch.ones(ndim)) 20 | self.bias = nn.Parameter(torch.zeros(ndim)) if bias else None 21 | 22 | def forward(self, input): 23 | return F.layer_norm(input, self.weight.shape, self.weight, self.bias, 1e-5) 24 | 25 | 26 | class CausalSelfAttention(nn.Module): 27 | def __init__(self, config): 28 | super().__init__() 29 | assert config.n_embd % config.n_head == 0 30 | # key, query, value projections for all heads, but in a batch 31 | self.c_attn = nn.Linear(config.n_embd, 3 * config.n_embd, bias=config.bias) 32 | # output projection 33 | self.c_proj = nn.Linear(config.n_embd, config.n_embd, bias=config.bias) 34 | # regularization 35 | self.attn_dropout = nn.Dropout(config.dropout) 36 | self.resid_dropout = nn.Dropout(config.dropout) 37 | self.n_head = config.n_head 38 | self.n_embd = config.n_embd 39 | self.dropout = config.dropout 40 | # flash attention make GPU go brrrrr but support is only in PyTorch nightly and still a bit scary 41 | self.flash = hasattr(torch.nn.functional, "scaled_dot_product_attention") 42 | if not self.flash: 43 | # print("WARNING: using slow attention. Flash Attention atm needs PyTorch nightly and dropout=0.0") 44 | # causal mask to ensure that attention is only applied to the left in the input sequence 45 | self.register_buffer( 46 | "bias", 47 | torch.tril(torch.ones(config.block_size, config.block_size)).view( 48 | 1, 1, config.block_size, config.block_size 49 | ), 50 | ) 51 | 52 | def forward(self, x, past_kv=None, use_cache=False): 53 | B, T, C = x.size() # batch size, sequence length, embedding dimensionality (n_embd) 54 | 55 | # calculate query, key, values for all heads in batch and move head forward to be the batch dim 56 | q, k, v = self.c_attn(x).split(self.n_embd, dim=2) 57 | k = k.view(B, T, self.n_head, C // self.n_head).transpose(1, 2) # (B, nh, T, hs) 58 | q = q.view(B, T, self.n_head, C // self.n_head).transpose(1, 2) # (B, nh, T, hs) 59 | v = v.view(B, T, self.n_head, C // self.n_head).transpose(1, 2) # (B, nh, T, hs) 60 | 61 | if past_kv is not None: 62 | past_key = past_kv[0] 63 | past_value = past_kv[1] 64 | k = torch.cat((past_key, k), dim=-2) 65 | v = torch.cat((past_value, v), dim=-2) 66 | 67 | FULL_T = k.shape[-2] 68 | 69 | if use_cache is True: 70 | present = (k, v) 71 | else: 72 | present = None 73 | 74 | # causal self-attention; Self-attend: (B, nh, T, hs) x (B, nh, hs, T) -> (B, nh, T, T) 75 | if self.flash: 76 | # efficient attention using Flash Attention CUDA kernels 77 | if past_kv is not None: 78 | # When `past_kv` is provided, we're doing incremental decoding and `q.shape[2] == 1`: q only contains 79 | # the query for the last token. scaled_dot_product_attention interprets this as the first token in the 80 | # sequence, so if is_causal=True it will mask out all attention from it. This is not what we want, so 81 | # to work around this we set is_causal=False. 82 | is_causal = False 83 | else: 84 | is_causal = True 85 | 86 | y = torch.nn.functional.scaled_dot_product_attention( 87 | q, k, v, dropout_p=self.dropout, is_causal=is_causal 88 | ) 89 | else: 90 | # manual implementation of attention 91 | att = (q @ k.transpose(-2, -1)) * (1.0 / math.sqrt(k.size(-1))) 92 | att = att.masked_fill(self.bias[:, :, FULL_T - T : FULL_T, :FULL_T] == 0, float("-inf")) 93 | att = F.softmax(att, dim=-1) 94 | att = self.attn_dropout(att) 95 | y = att @ v # (B, nh, T, T) x (B, nh, T, hs) -> (B, nh, T, hs) 96 | y = ( 97 | y.transpose(1, 2).contiguous().view(B, T, C) 98 | ) # re-assemble all head outputs side by side 99 | 100 | # output projection 101 | y = self.resid_dropout(self.c_proj(y)) 102 | return (y, present) 103 | 104 | 105 | class MLP(nn.Module): 106 | def __init__(self, config): 107 | super().__init__() 108 | self.c_fc = nn.Linear(config.n_embd, 4 * config.n_embd, bias=config.bias) 109 | self.c_proj = nn.Linear(4 * config.n_embd, config.n_embd, bias=config.bias) 110 | self.dropout = nn.Dropout(config.dropout) 111 | self.gelu = nn.GELU() 112 | 113 | def forward(self, x): 114 | x = self.c_fc(x) 115 | x = self.gelu(x) 116 | x = self.c_proj(x) 117 | x = self.dropout(x) 118 | return x 119 | 120 | 121 | class Block(nn.Module): 122 | def __init__(self, config, layer_idx): 123 | super().__init__() 124 | self.ln_1 = LayerNorm(config.n_embd, bias=config.bias) 125 | self.attn = CausalSelfAttention(config) 126 | self.ln_2 = LayerNorm(config.n_embd, bias=config.bias) 127 | self.mlp = MLP(config) 128 | self.layer_idx = layer_idx 129 | 130 | def forward(self, x, past_kv=None, use_cache=False): 131 | attn_output, prev_kvs = self.attn(self.ln_1(x), past_kv=past_kv, use_cache=use_cache) 132 | x = x + attn_output 133 | x = x + self.mlp(self.ln_2(x)) 134 | return (x, prev_kvs) 135 | 136 | 137 | @dataclass 138 | class GPTConfig: 139 | block_size: int = 1024 140 | input_vocab_size: int = 10_048 141 | output_vocab_size: int = 10_048 142 | n_layer: int = 12 143 | n_head: int = 12 144 | n_embd: int = 768 145 | dropout: float = 0.0 146 | bias: bool = ( 147 | True # True: bias in Linears and LayerNorms, like GPT-2. False: a bit better and faster 148 | ) 149 | 150 | 151 | class GPT(nn.Module): 152 | def __init__(self, config): 153 | super().__init__() 154 | assert config.input_vocab_size is not None 155 | assert config.output_vocab_size is not None 156 | assert config.block_size is not None 157 | self.config = config 158 | 159 | self.transformer = nn.ModuleDict( 160 | dict( 161 | wte=nn.Embedding(config.input_vocab_size, config.n_embd), 162 | wpe=nn.Embedding(config.block_size, config.n_embd), 163 | drop=nn.Dropout(config.dropout), 164 | h=nn.ModuleList([Block(config, idx) for idx in range(config.n_layer)]), 165 | ln_f=LayerNorm(config.n_embd, bias=config.bias), 166 | ) 167 | ) 168 | self.lm_head = nn.Linear(config.n_embd, config.output_vocab_size, bias=False) 169 | 170 | def get_num_params(self, non_embedding=True): 171 | """ 172 | Return the number of parameters in the model. 173 | For non-embedding count (default), the position embeddings get subtracted. 174 | The token embeddings would too, except due to the parameter sharing these 175 | params are actually used as weights in the final layer, so we include them. 176 | """ 177 | n_params = sum(p.numel() for p in self.parameters()) 178 | if non_embedding: 179 | n_params -= self.transformer.wte.weight.numel() 180 | n_params -= self.transformer.wpe.weight.numel() 181 | return n_params 182 | 183 | def forward( 184 | self, 185 | idx, 186 | input_embeds=None, 187 | merge_context=False, 188 | past_kv=None, 189 | position_ids=None, 190 | use_cache=False, 191 | ): 192 | # Mixed embed and token input not supported 193 | assert (idx is None) ^ ( 194 | input_embeds is None 195 | ), "Either use embedded or tokenized input, not both" 196 | 197 | device = idx.device if idx else input_embeds.device 198 | if idx: 199 | b, t = idx.size() 200 | else: 201 | b, t, d = input_embeds.size() 202 | 203 | if input_embeds is not None: 204 | assert ( 205 | d == self.config.n_embd 206 | ), f"Embeds are the wrong dimension: Expected {self.config.n_embd}, got {d}" 207 | 208 | if past_kv is not None: 209 | assert t == 1, f"KV caching but t is {t} not 1!" 210 | tok_emb = ( 211 | self.transformer.wte(idx) if idx else input_embeds 212 | ) # token embeddings of shape (b, t, n_embd) 213 | else: 214 | if merge_context: 215 | assert idx.shape[1] >= 256 + 256 + 1 216 | t = idx.shape[1] - 256 217 | else: 218 | assert ( 219 | t <= self.config.block_size 220 | ), f"Cannot forward sequence of length {t}, block size is only {self.config.block_size}" 221 | 222 | # forward the GPT model itself 223 | if merge_context and idx: 224 | tok_emb = torch.cat( 225 | [ 226 | self.transformer.wte(idx[:, :256]) 227 | + self.transformer.wte(idx[:, 256 : 256 + 256]), 228 | self.transformer.wte(idx[:, 256 + 256 :]), 229 | ], 230 | dim=1, 231 | ) 232 | elif idx: 233 | tok_emb = self.transformer.wte(idx) # token embeddings of shape (b, t, n_embd) 234 | else: 235 | tok_emb = input_embeds # Assume the caller did the context merging already 236 | 237 | if past_kv is None: 238 | past_length = 0 239 | past_kv = tuple([None] * len(self.transformer.h)) 240 | else: 241 | past_length = past_kv[0][0].size(-2) 242 | 243 | if position_ids is None: 244 | position_ids = torch.arange( 245 | past_length, t + past_length, dtype=torch.long, device=device 246 | ) 247 | position_ids = position_ids.unsqueeze(0) # shape (1, t) 248 | assert position_ids.shape == (1, t) 249 | 250 | pos_emb = self.transformer.wpe(position_ids) # position embeddings of shape (1, t, n_embd) 251 | 252 | x = self.transformer.drop(tok_emb + pos_emb) 253 | 254 | new_kv = () if use_cache else None 255 | 256 | for i, (block, past_layer_kv) in enumerate(zip(self.transformer.h, past_kv)): 257 | x, kv = block(x, past_kv=past_layer_kv, use_cache=use_cache) 258 | 259 | if use_cache: 260 | new_kv = new_kv + (kv,) 261 | 262 | x = self.transformer.ln_f(x) 263 | 264 | # inference-time mini-optimization: only forward the lm_head on the very last position 265 | logits = self.lm_head(x[:, [-1], :]) # note: using list [-1] to preserve the time dim 266 | 267 | return (logits, new_kv) 268 | -------------------------------------------------------------------------------- /generate_chunked.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "from bark.generation import SAMPLE_RATE, preload_models, codec_decode, generate_coarse, generate_fine, generate_text_semantic" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": null, 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import re\n", 19 | "def split_and_recombine_text(text, desired_length=100, max_length=150):\n", 20 | " # from https://github.com/neonbjb/tortoise-tts\n", 21 | " \"\"\"Split text it into chunks of a desired length trying to keep sentences intact.\"\"\"\n", 22 | " # normalize text, remove redundant whitespace and convert non-ascii quotes to ascii\n", 23 | " text = re.sub(r\"\\n\\n+\", \"\\n\", text)\n", 24 | " text = re.sub(r\"\\s+\", \" \", text)\n", 25 | " text = re.sub(r\"[“”]\", '\"', text)\n", 26 | "\n", 27 | " rv = []\n", 28 | " in_quote = False\n", 29 | " current = \"\"\n", 30 | " split_pos = []\n", 31 | " pos = -1\n", 32 | " end_pos = len(text) - 1\n", 33 | "\n", 34 | " def seek(delta):\n", 35 | " nonlocal pos, in_quote, current\n", 36 | " is_neg = delta < 0\n", 37 | " for _ in range(abs(delta)):\n", 38 | " if is_neg:\n", 39 | " pos -= 1\n", 40 | " current = current[:-1]\n", 41 | " else:\n", 42 | " pos += 1\n", 43 | " current += text[pos]\n", 44 | " if text[pos] == '\"':\n", 45 | " in_quote = not in_quote\n", 46 | " return text[pos]\n", 47 | "\n", 48 | " def peek(delta):\n", 49 | " p = pos + delta\n", 50 | " return text[p] if p < end_pos and p >= 0 else \"\"\n", 51 | "\n", 52 | " def commit():\n", 53 | " nonlocal rv, current, split_pos\n", 54 | " rv.append(current)\n", 55 | " current = \"\"\n", 56 | " split_pos = []\n", 57 | "\n", 58 | " while pos < end_pos:\n", 59 | " c = seek(1)\n", 60 | " # do we need to force a split?\n", 61 | " if len(current) >= max_length:\n", 62 | " if len(split_pos) > 0 and len(current) > (desired_length / 2):\n", 63 | " # we have at least one sentence and we are over half the desired length, seek back to the last split\n", 64 | " d = pos - split_pos[-1]\n", 65 | " seek(-d)\n", 66 | " else:\n", 67 | " # no full sentences, seek back until we are not in the middle of a word and split there\n", 68 | " while c not in \"!?.\\n \" and pos > 0 and len(current) > desired_length:\n", 69 | " c = seek(-1)\n", 70 | " commit()\n", 71 | " # check for sentence boundaries\n", 72 | " elif not in_quote and (c in \"!?\\n\" or (c == \".\" and peek(1) in \"\\n \")):\n", 73 | " # seek forward if we have consecutive boundary markers but still within the max length\n", 74 | " while (\n", 75 | " pos < len(text) - 1 and len(current) < max_length and peek(1) in \"!?.\"\n", 76 | " ):\n", 77 | " c = seek(1)\n", 78 | " split_pos.append(pos)\n", 79 | " if len(current) >= desired_length:\n", 80 | " commit()\n", 81 | " # treat end of quote as a boundary if its followed by a space or newline\n", 82 | " elif in_quote and peek(1) == '\"' and peek(2) in \"\\n \":\n", 83 | " seek(2)\n", 84 | " split_pos.append(pos)\n", 85 | " rv.append(current)\n", 86 | "\n", 87 | " # clean up, remove lines with only whitespace or punctuation\n", 88 | " rv = [s.strip() for s in rv]\n", 89 | " rv = [s for s in rv if len(s) > 0 and not re.match(r\"^[\\s\\.,;:!?]*$\", s)]\n", 90 | "\n", 91 | " return rv\n", 92 | "\n", 93 | "def generate_with_settings(text_prompt, semantic_temp=0.7, semantic_top_k=50, semantic_top_p=0.95, coarse_temp=0.7, coarse_top_k=50, coarse_top_p=0.95, fine_temp=0.5, voice_name=None, use_semantic_history_prompt=True, use_coarse_history_prompt=True, use_fine_history_prompt=True, output_full=False):\n", 94 | " # generation with more control\n", 95 | " x_semantic = generate_text_semantic(\n", 96 | " text_prompt,\n", 97 | " history_prompt=voice_name if use_semantic_history_prompt else None,\n", 98 | " temp=semantic_temp,\n", 99 | " top_k=semantic_top_k,\n", 100 | " top_p=semantic_top_p,\n", 101 | " )\n", 102 | "\n", 103 | " x_coarse_gen = generate_coarse(\n", 104 | " x_semantic,\n", 105 | " history_prompt=voice_name if use_coarse_history_prompt else None,\n", 106 | " temp=coarse_temp,\n", 107 | " top_k=coarse_top_k,\n", 108 | " top_p=coarse_top_p,\n", 109 | " )\n", 110 | " x_fine_gen = generate_fine(\n", 111 | " x_coarse_gen,\n", 112 | " history_prompt=voice_name if use_fine_history_prompt else None,\n", 113 | " temp=fine_temp,\n", 114 | " )\n", 115 | "\n", 116 | " if output_full:\n", 117 | " full_generation = {\n", 118 | " 'semantic_prompt': x_semantic,\n", 119 | " 'coarse_prompt': x_coarse_gen,\n", 120 | " 'fine_prompt': x_fine_gen,\n", 121 | " }\n", 122 | " return full_generation, codec_decode(x_fine_gen)\n", 123 | " return codec_decode(x_fine_gen)" 124 | ] 125 | }, 126 | { 127 | "cell_type": "code", 128 | "execution_count": null, 129 | "metadata": {}, 130 | "outputs": [], 131 | "source": [ 132 | "# `[laughter]`\n", 133 | "# - `[laughs]`\n", 134 | "# - `[sighs]`\n", 135 | "# - `[music]`\n", 136 | "# - `[gasps]`\n", 137 | "# - `[clears throat]`\n", 138 | "# - `—` or `...` for hesitations\n", 139 | "# - `♪` for song lyrics" 140 | ] 141 | }, 142 | { 143 | "cell_type": "code", 144 | "execution_count": null, 145 | "metadata": {}, 146 | "outputs": [], 147 | "source": [ 148 | "text = \"\"\"The Uncharted Land of Discovery: A Journey Through Time and Space\n", 149 | "[clears throat]\n", 150 | "Chapter 1: The Dawn of Curiosity\n", 151 | "[takes breath]\n", 152 | "Since the dawn of humankind, our species has been driven by a powerful force: curiosity. It is an innate, unquenchable desire to explore, understand, and unravel the mysteries of the world around us. This primal urge has led us on countless adventures, pushing us to the farthest reaches of our planet and beyond.\n", 153 | "\n", 154 | "Early humans, huddled around a flickering fire, gazed up at the night sky and wondered what those twinkling lights were. They had no idea that their curiosity would eventually propel us into the vast, uncharted realm of space. As time progressed, our ancestors began to explore their surroundings, venturing beyond their caves and settlements, driven by the need to discover what lay beyond the horizon.\n", 155 | "\n", 156 | "hapter 2: The Age of Exploration\n", 157 | "\n", 158 | "The Age of Exploration marked a turning point in human history, as brave souls took to the seas in search of new lands, wealth, and knowledge. Pioneers like Christopher Columbus, Vasco da Gama, and Ferdinand Magellan set sail on perilous voyages, pushing the boundaries of what was known and understood.\n", 159 | "[clears throat]\n", 160 | "These intrepid explorers discovered new continents, mapped out previously unknown territories, and encountered diverse cultures. They also established trade routes, allowing for the exchange of goods, ideas, and innovations between distant societies. The Age of Exploration was not without its dark moments, however, as conquest, colonization, and exploitation often went hand in hand with discovery.\n", 161 | "[clears throat]\n", 162 | "Chapter 3: The Scientific Revolution\n", 163 | "[laughs]\n", 164 | "The Scientific Revolution was a period of profound change, as humanity began to question long-held beliefs and seek empirical evidence. Pioneers like Galileo Galilei, Isaac Newton, and Johannes Kepler sought to understand the natural world through observation, experimentation, and reason.\n", 165 | "[sighs]\n", 166 | "Their discoveries laid the foundation for modern science, transforming the way we view the universe and our place within it. New technologies, such as the telescope and the microscope, allowed us to peer deeper into the cosmos and the microscopic world, further expanding our understanding of reality.\n", 167 | "[gasps]\n", 168 | "Chapter 4: The Information Age\n", 169 | "\n", 170 | "The Information Age, sometimes referred to as the Digital Age, has revolutionized the way we communicate, learn, and access knowledge. With the advent of the internet and personal computers, information that was once reserved for the privileged few is now available to the masses.\n", 171 | "...\n", 172 | "This democratization of knowledge has led to an explosion of innovation, as ideas and information are shared across borders and cultures at lightning speed. The Information Age has also brought new challenges, as the rapid pace of technological advancements threatens to outpace our ability to adapt and raises questions about the ethical implications of our increasingly interconnected world.\n", 173 | "[laughter]\n", 174 | "Chapter 5: The Final Frontier\n", 175 | "[clears throat]\n", 176 | "As our knowledge of the universe expands, so too does our desire to explore the cosmos. Space exploration has come a long way since the first successful satellite, Sputnik, was launched in 1957. We have landed humans on the moon, sent probes to the far reaches of our solar system, and even glimpsed distant galaxies through powerful telescopes.\n", 177 | "\n", 178 | "The future of space exploration is filled with possibilities, from establishing colonies on Mars to the search for extraterrestrial life. As we venture further into the unknown, we continue to be driven by the same curiosity that has propelled us throughout history, always seeking to uncover the secrets of the universe and our place within it.\n", 179 | "...\n", 180 | "In conclusion, the human journey is one of discovery, driven by our innate curiosity and desire to understand the world around us. From the dawn of our species to the present day, we have continued to explore, learn, and adapt, pushing the boundaries of what is known and possible. As we continue to unravel the mysteries of the cosmos, our spirit.\"\"\"" 181 | ] 182 | }, 183 | { 184 | "cell_type": "code", 185 | "execution_count": null, 186 | "metadata": {}, 187 | "outputs": [], 188 | "source": [ 189 | "# download and load all models\n", 190 | "preload_models(\n", 191 | " text_use_gpu=True,\n", 192 | " text_use_small=False,\n", 193 | " coarse_use_gpu=True,\n", 194 | " coarse_use_small=False,\n", 195 | " fine_use_gpu=True,\n", 196 | " fine_use_small=False,\n", 197 | " codec_use_gpu=True,\n", 198 | " force_reload=False,\n", 199 | " path=\"models\"\n", 200 | ")" 201 | ] 202 | }, 203 | { 204 | "cell_type": "code", 205 | "execution_count": null, 206 | "metadata": {}, 207 | "outputs": [], 208 | "source": [ 209 | "# Chunk the text into smaller pieces then combine the generated audio\n", 210 | "from time import time\n", 211 | "from tqdm.auto import tqdm\n", 212 | "from IPython.display import Audio\n", 213 | "from scipy.io.wavfile import write as write_wav\n", 214 | "import os\n", 215 | "import numpy as np\n", 216 | "\n", 217 | "# generation settings\n", 218 | "voice_name = 'speaker_4'\n", 219 | "out_filepath = 'audio/audio.wav'\n", 220 | "\n", 221 | "semantic_temp = 0.7\n", 222 | "semantic_top_k = 50\n", 223 | "semantic_top_p = 0.95\n", 224 | "\n", 225 | "coarse_temp = 0.7\n", 226 | "coarse_top_k = 50\n", 227 | "coarse_top_p = 0.95\n", 228 | "\n", 229 | "fine_temp = 0.5\n", 230 | "\n", 231 | "use_semantic_history_prompt = True\n", 232 | "use_coarse_history_prompt = True\n", 233 | "use_fine_history_prompt = True\n", 234 | "\n", 235 | "use_last_generation_as_history = True\n", 236 | "\n", 237 | "texts = split_and_recombine_text(text)\n", 238 | "\n", 239 | "all_parts = []\n", 240 | "for i, text in tqdm(enumerate(texts), total=len(texts)):\n", 241 | " full_generation, audio_array = generate_with_settings(\n", 242 | " text,\n", 243 | " semantic_temp=semantic_temp,\n", 244 | " semantic_top_k=semantic_top_k,\n", 245 | " semantic_top_p=semantic_top_p,\n", 246 | " coarse_temp=coarse_temp,\n", 247 | " coarse_top_k=coarse_top_k,\n", 248 | " coarse_top_p=coarse_top_p,\n", 249 | " fine_temp=fine_temp,\n", 250 | " voice_name=voice_name,\n", 251 | " use_semantic_history_prompt=use_semantic_history_prompt,\n", 252 | " use_coarse_history_prompt=use_coarse_history_prompt,\n", 253 | " use_fine_history_prompt=use_fine_history_prompt,\n", 254 | " output_full=True\n", 255 | " )\n", 256 | " if use_last_generation_as_history:\n", 257 | " # save to npz\n", 258 | " os.makedirs('_temp', exist_ok=True)\n", 259 | " np.savez_compressed(\n", 260 | " '_temp/history.npz',\n", 261 | " semantic_prompt=full_generation['semantic_prompt'],\n", 262 | " coarse_prompt=full_generation['coarse_prompt'],\n", 263 | " fine_prompt=full_generation['fine_prompt'],\n", 264 | " )\n", 265 | " voice_name = '_temp/history.npz'\n", 266 | " all_parts.append(audio_array)\n", 267 | "\n", 268 | "audio_array = np.concatenate(all_parts, axis=-1)\n", 269 | "\n", 270 | "# save audio\n", 271 | "write_wav(out_filepath, SAMPLE_RATE, audio_array)\n", 272 | "\n", 273 | "# play audio\n", 274 | "Audio(audio_array, rate=SAMPLE_RATE)" 275 | ] 276 | } 277 | ], 278 | "metadata": { 279 | "kernelspec": { 280 | "display_name": "Python 3", 281 | "language": "python", 282 | "name": "python3" 283 | }, 284 | "language_info": { 285 | "codemirror_mode": { 286 | "name": "ipython", 287 | "version": 3 288 | }, 289 | "file_extension": ".py", 290 | "mimetype": "text/x-python", 291 | "name": "python", 292 | "nbconvert_exporter": "python", 293 | "pygments_lexer": "ipython3", 294 | "version": "3.10.8" 295 | }, 296 | "orig_nbformat": 4 297 | }, 298 | "nbformat": 4, 299 | "nbformat_minor": 2 300 | } 301 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Bark fine-tuning experiment 2 | 3 | > **Status report, 2023-05-16**: Still in the prototyping phase with the [Serp.ai](https://serp.ai/) team. Bark now takes embedded semantic history for generation, and we have prototyping code for creating a synthetic dataset of audio to token mappings. There's boilerplate for training a simple projection with MSE loss between spaces, to test E2E, but unsurprisingly it didn't work on the first try. Over the next few weeks I'll be working on the actual training: (a) hyperparameter tuning, (b) using a larger HuBERT model for embeddings, (c) making the training objective more sophisticated. Contributions and feedback welcome! Join us at the [SERP Discord](https://serp.ly/@serpai/discord). 4 | 5 | > **Warning** 6 | > 7 | > I'm a junior web dev with a grand total of four months of AI tutorials, so I could be totally "Bark"-ing up the wrong tree! Please don't hesitate to give suggestions, contribute, or correct me, that's what open source is for! 8 | 9 | This repo attempts to enable converting ground-truth audio to Bark semantic tokens (or their input embeddings). If successful, this will add the missing piece to Serp.ai's voice cloning fork, which solved coarse and fine token conversion, and enable full fine tuning - or at least get some of the way there. **My eventual goal is to merge this fork back into the main Serp.ai voice cloning fork**, if I ever get that far. 10 | 11 | For progress, please see CHANGELOG.md 12 | 13 | ## Why can't Bark be fine-tuned (yet)? 14 | 15 | Under the hood, Bark is essentially the AudioLM model (see [paper](https://arxiv.org/abs/2209.03143), [public GitHub replication](https://github.com/lucidrains/audiolm-pytorch)) + text conditioning. It's three GPTs stacked on top of each other. In AudioLM, just like GPT-3 generates text tokens from a prompt of text tokens, the first GPT takes a prompt of **semantic** tokens, which encode the _content_ of new audio and a bit of the speaker identity (that's `text_to_semantic` in Bark), and generates the "next tokens". Bark adds to this by adding a learned embedding of the text you want to generate. The second and third GPTs, the fine and coarse or `semantic_to_waveform` in Bark, in both Bark and AudioLM handle the **acoustic** tokens, which encode the finer details of the audio. 16 | 17 | ![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiX0MyO_IXk730mCbbJX7LXxBRIxJk2K41Y4leuEk4WQRjz0kgIp9CGHFwLePaKt3qEcCK8fvhAxjJ7J_sXH05q7xnsMbjZZFDDLPIlVyaKr3yYo77oT2KBqe9gw4MFuUZnUfxFprP67ExPzr2RNxduB0SruUGjJXghihHSoxvMtlG3YNtHHesZOJzY/s960/image2.png) 18 | 19 | So how do you turn real audio into token prompts for these models? Mercifully, the acoustic tokens are a predefined open-source format: lower and upper layers of Facebook's [Encodec](https://github.com/facebookresearch/encodec) neural compressed encoding for audio. Serp.ai's voice cloning fork successfully converts coarse and fine token prompts this way. Unfortunately, the audio to semantic token conversion requires Bark's proprietary model, which is only used during training and not at inference. Suno has repeatedly refused to open-source this model despite many community requests including from Serp.ai, in order to ~~make money by using an unconfigurable Bark as a giant advertisement for their future proprietary platform, which guards cloning behind a paid API~~ "prevent online harms and misinformation". Instead, Suno gives out their own predefined prompts. This approach is quite similar to how the Tortoise TTS developer "de-weaponized" it for the first year of its existence: see Sherman Chann's blog post [Why can't Tortoise be fine-tuned?](https://152334h.github.io/blog/tortoise-fine-tuning/) for a writeup. 20 | 21 | Serp.ai's voice cloning fork deals with this limitation by generating semantic tokens prompted only by text, but supplying the fine and coarse prompts from the ground-truth audio. Serp's approach gets pretty far; fine and coarse are enough to get major details like speaker gender and tone of voice pretty close. However, sadly this isn't enough to nail speaker identity. Check out the `notebooks/ablation.ipynb` notebook for an informal demonstration of how much difference semantic and acoustic prompts make to the output. 22 | 23 | ## Reverse engineering the semantic token codebook 24 | 25 | Sherman Chann's blog post on Tortoise goes on to suggest "baseless speculation" on how to reverse-engineer the Tortoise codebook. By definition, the model outputs are the audio from the new semantic tokens, and mercifully, the length specified by the 50hz semantic tokens is the length of the audio. So we can generate a large, diverse dataset of voice lines and save the semantic tokens for them, then train a small model to map generated audio to source tokens. Chann never ended up having to do this, since the Tortoise author foolishly left the original semantic token encoder in a not-actually-deleted HuggingFace branch. Sadly, the Bark community isn't so lucky; we'll have to do it the hard way. 26 | 27 | The `notebooks/create_dataset` is a naive attempt to generate a dataset of synthetic audio to semantic tokens, in [Fairseq's](https://github.com/facebookresearch/fairseq) dataset format, so we can feed our generated audio easily into Fairseq's HuBERT implementation and get the sixth-layer embeddings. The key thing here is to generate as large and diverse a dataset as possible, but for prototyping purposes, I'm solely doing this for English using voice prompts from [Mozilla CommonVoice](https://commonvoice.mozilla.org/en/datasets) (NOT the actual audio). (As a side note, I would really appreciate someone getting the `validated.tsv` voice lines from other languages in CommonVoice, like Hindi; I don't want to download all that audio just to get the tsv and not use the audio at all). 28 | 29 | The original AudioLM paper creates the audio to semantic token mapping as follows: 30 | - Take an encoder transformer BERT-like model that encodes audio to embeddings (for tasks like speaker recognition). AudioLM and Google use the closed-source wav2vec-BERT, but the open-source AudioLM repo uses [HuBERT](https://huggingface.co/docs/transformers/model_doc/hubert). 31 | - Run a bunch of source audio through HuBERT and take the embeddings from the sixth layer. HuBERT runs at 50 embeddings / second of audio. 32 | - Run k-means clusters on the embeddings to essentially produce k "groups" of kinds of input audio. For example, AudioLM uses ~500, and in a [GitHub statement](https://github.com/lucidrains/audiolm-pytorch/discussions/170), the Bark devs say they use a similar approach but with 10k groups. In what I am sure is a complete coincidence, Bark semantic tokens are 49.9hz, roughly the same as HuBERT's 50hz. 33 | - When adding new audio, run k-means to find out "what group" the new audio is in. 34 | 35 | So can't we just do this semantic token codebook generation ourselves? No; as Chann points out, there's no guarantee that our own training process will generate the same groups. Instead, similar to [Mini-GPT-4](https://arxiv.org/abs/2304.10592), we're training a linear projection from embeddings from frozen HuBERT to Bark's input embeddings for the semantic tokens, and enabling generation from embedded semantic history. 36 | 37 | Other stuff that probably needs to be done later: 38 | - Add batch inference mode for Bark, to speed up dataset generation and enable use cases like mass audiobook conversion 39 | - Write an eval harness, so we can gauge performance better than training objective loss or "playing it by ear" 40 | 41 | ------------------------------------------------------------------- 42 | # Original README.md 43 | 44 | 45 | [![Twitter](https://img.shields.io/twitter/url/https/twitter.com/OnusFM.svg?style=social&label=@OnusFM)](https://twitter.com/OnusFM) 46 | [![](https://dcbadge.vercel.app/api/server/J2B2vsjKuE?compact=true&style=flat&)](https://discord.gg/J2B2vsjKuE) 47 | 48 | 49 | [Examples](https://suno-ai.notion.site/Bark-Examples-5edae8b02a604b54a42244ba45ebc2e2) | [Model Card](./model-card.md) | [Playground Waitlist](https://3os84zs17th.typeform.com/suno-studio) 50 | 51 | Bark is a transformer-based text-to-audio model created by [Suno](https://suno.ai). Bark can generate highly realistic, multilingual speech as well as other audio - including music, background noise and simple sound effects. The model can also produce nonverbal communications like laughing, sighing and crying. To support the research community, we are providing access to pretrained model checkpoints ready for inference. 52 | 53 |

54 | 55 |

56 | 57 | ## 🔊 Demos 58 | 59 | [![Open in Spaces](https://img.shields.io/badge/🤗-Open%20In%20Spaces-blue.svg)](https://huggingface.co/spaces/suno/bark) 60 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1eJfA2XUa-mXwdMy7DoYKVYHI1iTd9Vkt?usp=sharing) 61 | 62 | ## 🤖 Usage 63 | 64 | ```python 65 | from bark import SAMPLE_RATE, generate_audio, preload_models 66 | from IPython.display import Audio 67 | 68 | # download and load all models 69 | preload_models() 70 | 71 | # generate audio from text 72 | text_prompt = """ 73 | Hello, my name is Suno. And, uh — and I like pizza. [laughs] 74 | But I also have other interests such as playing tic tac toe. 75 | """ 76 | audio_array = generate_audio(text_prompt) 77 | 78 | # play text in notebook 79 | Audio(audio_array, rate=SAMPLE_RATE) 80 | ``` 81 | 82 | [pizza.webm](https://user-images.githubusercontent.com/5068315/230490503-417e688d-5115-4eee-9550-b46a2b465ee3.webm) 83 | 84 | 85 | To save `audio_array` as a WAV file: 86 | 87 | ```python 88 | from scipy.io.wavfile import write as write_wav 89 | 90 | write_wav("/path/to/audio.wav", SAMPLE_RATE, audio_array) 91 | ``` 92 | 93 | ### 🌎 Foreign Language 94 | 95 | Bark supports various languages out-of-the-box and automatically determines language from input text. When prompted with code-switched text, Bark will attempt to employ the native accent for the respective languages. English quality is best for the time being, and we expect other languages to further improve with scaling. 96 | 97 | ```python 98 | text_prompt = """ 99 | Buenos días Miguel. Tu colega piensa que tu alemán es extremadamente malo. 100 | But I suppose your english isn't terrible. 101 | """ 102 | audio_array = generate_audio(text_prompt) 103 | ``` 104 | 105 | [miguel.webm](https://user-images.githubusercontent.com/5068315/230684752-10baadfe-1e7c-46a2-8323-43282aef2c8c.webm) 106 | 107 | ### 🎶 Music 108 | 109 | Bark can generate all types of audio, and, in principle, doesn't see a difference between speech and music. Sometimes Bark chooses to generate text as music, but you can help it out by adding music notes around your lyrics. 110 | 111 | ```python 112 | text_prompt = """ 113 | ♪ In the jungle, the mighty jungle, the lion barks tonight ♪ 114 | """ 115 | audio_array = generate_audio(text_prompt) 116 | ``` 117 | 118 | [lion.webm](https://user-images.githubusercontent.com/5068315/230684766-97f5ea23-ad99-473c-924b-66b6fab24289.webm) 119 | 120 | ### 🎤 Voice Presets and Voice/Audio Cloning 121 | 122 | Bark has the capability to fully clone voices - including tone, pitch, emotion and prosody. The model also attempts to preserve music, ambient noise, etc. from input audio. However, to mitigate misuse of this technology, we limit the audio history prompts to a limited set of Suno-provided, fully synthetic options to choose from for each language. Specify following the pattern: `{lang_code}_speaker_{0-9}`. 123 | 124 | ```python 125 | text_prompt = """ 126 | I have a silky smooth voice, and today I will tell you about 127 | the exercise regimen of the common sloth. 128 | """ 129 | audio_array = generate_audio(text_prompt, history_prompt="en_speaker_1") 130 | ``` 131 | 132 | 133 | [sloth.webm](https://user-images.githubusercontent.com/5068315/230684883-a344c619-a560-4ff5-8b99-b4463a34487b.webm) 134 | 135 | *Note: since Bark recognizes languages automatically from input text, it is possible to use for example a german history prompt with english text. This usually leads to english audio with a german accent.* 136 | 137 | ### 👥 Speaker Prompts 138 | 139 | You can provide certain speaker prompts such as NARRATOR, MAN, WOMAN, etc. Please note that these are not always respected, especially if a conflicting audio history prompt is given. 140 | 141 | ```python 142 | text_prompt = """ 143 | WOMAN: I would like an oatmilk latte please. 144 | MAN: Wow, that's expensive! 145 | """ 146 | audio_array = generate_audio(text_prompt) 147 | ``` 148 | 149 | [latte.webm](https://user-images.githubusercontent.com/5068315/230684864-12d101a1-a726-471d-9d56-d18b108efcb8.webm) 150 | 151 | 152 | ## 💻 Installation 153 | 154 | ``` 155 | pip install git+https://github.com/suno-ai/bark.git 156 | ``` 157 | 158 | or 159 | 160 | ``` 161 | git clone https://github.com/suno-ai/bark 162 | cd bark && pip install . 163 | ``` 164 | 165 | ## 🛠️ Hardware and Inference Speed 166 | 167 | Bark has been tested and works on both CPU and GPU (`pytorch 2.0+`, CUDA 11.7 and CUDA 12.0). 168 | Running Bark requires running >100M parameter transformer models. 169 | On modern GPUs and PyTorch nightly, Bark can generate audio in roughly realtime. On older GPUs, default colab, or CPU, inference time might be 10-100x slower. 170 | 171 | If you don't have new hardware available or if you want to play with bigger versions of our models, you can also sign up for early access to our model playground [here](https://3os84zs17th.typeform.com/suno-studio). 172 | 173 | ## ⚙️ Details 174 | 175 | Similar to [Vall-E](https://arxiv.org/abs/2301.02111) and some other amazing work in the field, Bark uses GPT-style 176 | models to generate audio from scratch. Different from Vall-E, the initial text prompt is embedded into high-level semantic tokens without the use of phonemes. It can therefore generalize to arbitrary instructions beyond speech that occur in the training data, such as music lyrics, sound effects or other non-speech sounds. A subsequent second model is used to convert the generated semantic tokens into audio codec tokens to generate the full waveform. To enable the community to use Bark via public code we used the fantastic 177 | [EnCodec codec](https://github.com/facebookresearch/encodec) from Facebook to act as an audio representation. 178 | 179 | Below is a list of some known non-speech sounds, but we are finding more every day. Please let us know if you find patterns that work particularly well on [Discord](https://discord.gg/J2B2vsjKuE)! 180 | 181 | - `[laughter]` 182 | - `[laughs]` 183 | - `[sighs]` 184 | - `[music]` 185 | - `[gasps]` 186 | - `[clears throat]` 187 | - `—` or `...` for hesitations 188 | - `♪` for song lyrics 189 | - capitalization for emphasis of a word 190 | - `MAN/WOMAN:` for bias towards speaker 191 | 192 | **Supported Languages** 193 | 194 | | Language | Status | 195 | | --- | --- | 196 | | English (en) | ✅ | 197 | | German (de) | ✅ | 198 | | Spanish (es) | ✅ | 199 | | French (fr) | ✅ | 200 | | Hindi (hi) | ✅ | 201 | | Italian (it) | ✅ | 202 | | Japanese (ja) | ✅ | 203 | | Korean (ko) | ✅ | 204 | | Polish (pl) | ✅ | 205 | | Portuguese (pt) | ✅ | 206 | | Russian (ru) | ✅ | 207 | | Turkish (tr) | ✅ | 208 | | Chinese, simplified (zh) | ✅ | 209 | | Arabic | Coming soon! | 210 | | Bengali | Coming soon! | 211 | | Telugu | Coming soon! | 212 | 213 | ## 🙏 Appreciation 214 | 215 | - [nanoGPT](https://github.com/karpathy/nanoGPT) for a dead-simple and blazing fast implementation of GPT-style models 216 | - [EnCodec](https://github.com/facebookresearch/encodec) for a state-of-the-art implementation of a fantastic audio codec 217 | - [AudioLM](https://github.com/lucidrains/audiolm-pytorch) for very related training and inference code 218 | - [Vall-E](https://arxiv.org/abs/2301.02111), [AudioLM](https://arxiv.org/abs/2209.03143) and many other ground-breaking papers that enabled the development of Bark 219 | 220 | ## © License 221 | 222 | Bark is licensed under a non-commercial license: CC-BY 4.0 NC. The Suno models themselves may be used commercially. However, this version of Bark uses `EnCodec` as a neural codec backend, which is licensed under a [non-commercial license](https://github.com/facebookresearch/encodec/blob/main/LICENSE). 223 | 224 | Please contact us at `bark@suno.ai` if you need access to a larger version of the model and/or a version of the model you can use commercially. 225 | 226 | ## 📱 Community 227 | 228 | - [Twitter](https://twitter.com/OnusFM) 229 | - [Discord](https://discord.gg/J2B2vsjKuE) 230 | 231 | ## 🎧 Suno Studio (Early Access) 232 | 233 | We’re developing a playground for our models, including Bark. 234 | 235 | If you are interested, you can sign up for early access [here](https://3os84zs17th.typeform.com/suno-studio). 236 | 237 | ## FAQ 238 | 239 | #### How do I specify where models are downloaded and cached? 240 | 241 | Use the `XDG_CACHE_HOME` env variable to override where models are downloaded and cached (otherwise defaults to a subdirectory of `~/.cache`). 242 | 243 | #### Bark's generations sometimes differ from my prompts. What's happening? 244 | 245 | Bark is a GPT-style model. As such, it may take some creative liberties in its generations, resulting in higher-variance model outputs than traditional text-to-speech approaches. 246 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Attribution-NonCommercial 4.0 International 3 | 4 | ======================================================================= 5 | 6 | Creative Commons Corporation ("Creative Commons") is not a law firm and 7 | does not provide legal services or legal advice. Distribution of 8 | Creative Commons public licenses does not create a lawyer-client or 9 | other relationship. Creative Commons makes its licenses and related 10 | information available on an "as-is" basis. Creative Commons gives no 11 | warranties regarding its licenses, any material licensed under their 12 | terms and conditions, or any related information. Creative Commons 13 | disclaims all liability for damages resulting from their use to the 14 | fullest extent possible. 15 | 16 | Using Creative Commons Public Licenses 17 | 18 | Creative Commons public licenses provide a standard set of terms and 19 | conditions that creators and other rights holders may use to share 20 | original works of authorship and other material subject to copyright 21 | and certain other rights specified in the public license below. The 22 | following considerations are for informational purposes only, are not 23 | exhaustive, and do not form part of our licenses. 24 | 25 | Considerations for licensors: Our public licenses are 26 | intended for use by those authorized to give the public 27 | permission to use material in ways otherwise restricted by 28 | copyright and certain other rights. Our licenses are 29 | irrevocable. Licensors should read and understand the terms 30 | and conditions of the license they choose before applying it. 31 | Licensors should also secure all rights necessary before 32 | applying our licenses so that the public can reuse the 33 | material as expected. Licensors should clearly mark any 34 | material not subject to the license. This includes other CC- 35 | licensed material, or material used under an exception or 36 | limitation to copyright. More considerations for licensors: 37 | wiki.creativecommons.org/Considerations_for_licensors 38 | 39 | Considerations for the public: By using one of our public 40 | licenses, a licensor grants the public permission to use the 41 | licensed material under specified terms and conditions. If 42 | the licensor's permission is not necessary for any reason--for 43 | example, because of any applicable exception or limitation to 44 | copyright--then that use is not regulated by the license. Our 45 | licenses grant only permissions under copyright and certain 46 | other rights that a licensor has authority to grant. Use of 47 | the licensed material may still be restricted for other 48 | reasons, including because others have copyright or other 49 | rights in the material. A licensor may make special requests, 50 | such as asking that all changes be marked or described. 51 | Although not required by our licenses, you are encouraged to 52 | respect those requests where reasonable. More_considerations 53 | for the public: 54 | wiki.creativecommons.org/Considerations_for_licensees 55 | 56 | ======================================================================= 57 | 58 | Creative Commons Attribution-NonCommercial 4.0 International Public 59 | License 60 | 61 | By exercising the Licensed Rights (defined below), You accept and agree 62 | to be bound by the terms and conditions of this Creative Commons 63 | Attribution-NonCommercial 4.0 International Public License ("Public 64 | License"). To the extent this Public License may be interpreted as a 65 | contract, You are granted the Licensed Rights in consideration of Your 66 | acceptance of these terms and conditions, and the Licensor grants You 67 | such rights in consideration of benefits the Licensor receives from 68 | making the Licensed Material available under these terms and 69 | conditions. 70 | 71 | Section 1 -- Definitions. 72 | 73 | a. Adapted Material means material subject to Copyright and Similar 74 | Rights that is derived from or based upon the Licensed Material 75 | and in which the Licensed Material is translated, altered, 76 | arranged, transformed, or otherwise modified in a manner requiring 77 | permission under the Copyright and Similar Rights held by the 78 | Licensor. For purposes of this Public License, where the Licensed 79 | Material is a musical work, performance, or sound recording, 80 | Adapted Material is always produced where the Licensed Material is 81 | synched in timed relation with a moving image. 82 | 83 | b. Adapter's License means the license You apply to Your Copyright 84 | and Similar Rights in Your contributions to Adapted Material in 85 | accordance with the terms and conditions of this Public License. 86 | 87 | c. Copyright and Similar Rights means copyright and/or similar rights 88 | closely related to copyright including, without limitation, 89 | performance, broadcast, sound recording, and Sui Generis Database 90 | Rights, without regard to how the rights are labeled or 91 | categorized. For purposes of this Public License, the rights 92 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 93 | Rights. 94 | d. Effective Technological Measures means those measures that, in the 95 | absence of proper authority, may not be circumvented under laws 96 | fulfilling obligations under Article 11 of the WIPO Copyright 97 | Treaty adopted on December 20, 1996, and/or similar international 98 | agreements. 99 | 100 | e. Exceptions and Limitations means fair use, fair dealing, and/or 101 | any other exception or limitation to Copyright and Similar Rights 102 | that applies to Your use of the Licensed Material. 103 | 104 | f. Licensed Material means the artistic or literary work, database, 105 | or other material to which the Licensor applied this Public 106 | License. 107 | 108 | g. Licensed Rights means the rights granted to You subject to the 109 | terms and conditions of this Public License, which are limited to 110 | all Copyright and Similar Rights that apply to Your use of the 111 | Licensed Material and that the Licensor has authority to license. 112 | 113 | h. Licensor means the individual(s) or entity(ies) granting rights 114 | under this Public License. 115 | 116 | i. NonCommercial means not primarily intended for or directed towards 117 | commercial advantage or monetary compensation. For purposes of 118 | this Public License, the exchange of the Licensed Material for 119 | other material subject to Copyright and Similar Rights by digital 120 | file-sharing or similar means is NonCommercial provided there is 121 | no payment of monetary compensation in connection with the 122 | exchange. 123 | 124 | j. Share means to provide material to the public by any means or 125 | process that requires permission under the Licensed Rights, such 126 | as reproduction, public display, public performance, distribution, 127 | dissemination, communication, or importation, and to make material 128 | available to the public including in ways that members of the 129 | public may access the material from a place and at a time 130 | individually chosen by them. 131 | 132 | k. Sui Generis Database Rights means rights other than copyright 133 | resulting from Directive 96/9/EC of the European Parliament and of 134 | the Council of 11 March 1996 on the legal protection of databases, 135 | as amended and/or succeeded, as well as other essentially 136 | equivalent rights anywhere in the world. 137 | 138 | l. You means the individual or entity exercising the Licensed Rights 139 | under this Public License. Your has a corresponding meaning. 140 | 141 | Section 2 -- Scope. 142 | 143 | a. License grant. 144 | 145 | 1. Subject to the terms and conditions of this Public License, 146 | the Licensor hereby grants You a worldwide, royalty-free, 147 | non-sublicensable, non-exclusive, irrevocable license to 148 | exercise the Licensed Rights in the Licensed Material to: 149 | 150 | a. reproduce and Share the Licensed Material, in whole or 151 | in part, for NonCommercial purposes only; and 152 | 153 | b. produce, reproduce, and Share Adapted Material for 154 | NonCommercial purposes only. 155 | 156 | 2. Exceptions and Limitations. For the avoidance of doubt, where 157 | Exceptions and Limitations apply to Your use, this Public 158 | License does not apply, and You do not need to comply with 159 | its terms and conditions. 160 | 161 | 3. Term. The term of this Public License is specified in Section 162 | 6(a). 163 | 164 | 4. Media and formats; technical modifications allowed. The 165 | Licensor authorizes You to exercise the Licensed Rights in 166 | all media and formats whether now known or hereafter created, 167 | and to make technical modifications necessary to do so. The 168 | Licensor waives and/or agrees not to assert any right or 169 | authority to forbid You from making technical modifications 170 | necessary to exercise the Licensed Rights, including 171 | technical modifications necessary to circumvent Effective 172 | Technological Measures. For purposes of this Public License, 173 | simply making modifications authorized by this Section 2(a) 174 | (4) never produces Adapted Material. 175 | 176 | 5. Downstream recipients. 177 | 178 | a. Offer from the Licensor -- Licensed Material. Every 179 | recipient of the Licensed Material automatically 180 | receives an offer from the Licensor to exercise the 181 | Licensed Rights under the terms and conditions of this 182 | Public License. 183 | 184 | b. No downstream restrictions. You may not offer or impose 185 | any additional or different terms or conditions on, or 186 | apply any Effective Technological Measures to, the 187 | Licensed Material if doing so restricts exercise of the 188 | Licensed Rights by any recipient of the Licensed 189 | Material. 190 | 191 | 6. No endorsement. Nothing in this Public License constitutes or 192 | may be construed as permission to assert or imply that You 193 | are, or that Your use of the Licensed Material is, connected 194 | with, or sponsored, endorsed, or granted official status by, 195 | the Licensor or others designated to receive attribution as 196 | provided in Section 3(a)(1)(A)(i). 197 | 198 | b. Other rights. 199 | 200 | 1. Moral rights, such as the right of integrity, are not 201 | licensed under this Public License, nor are publicity, 202 | privacy, and/or other similar personality rights; however, to 203 | the extent possible, the Licensor waives and/or agrees not to 204 | assert any such rights held by the Licensor to the limited 205 | extent necessary to allow You to exercise the Licensed 206 | Rights, but not otherwise. 207 | 208 | 2. Patent and trademark rights are not licensed under this 209 | Public License. 210 | 211 | 3. To the extent possible, the Licensor waives any right to 212 | collect royalties from You for the exercise of the Licensed 213 | Rights, whether directly or through a collecting society 214 | under any voluntary or waivable statutory or compulsory 215 | licensing scheme. In all other cases the Licensor expressly 216 | reserves any right to collect such royalties, including when 217 | the Licensed Material is used other than for NonCommercial 218 | purposes. 219 | 220 | Section 3 -- License Conditions. 221 | 222 | Your exercise of the Licensed Rights is expressly made subject to the 223 | following conditions. 224 | 225 | a. Attribution. 226 | 227 | 1. If You Share the Licensed Material (including in modified 228 | form), You must: 229 | 230 | a. retain the following if it is supplied by the Licensor 231 | with the Licensed Material: 232 | 233 | i. identification of the creator(s) of the Licensed 234 | Material and any others designated to receive 235 | attribution, in any reasonable manner requested by 236 | the Licensor (including by pseudonym if 237 | designated); 238 | 239 | ii. a copyright notice; 240 | 241 | iii. a notice that refers to this Public License; 242 | 243 | iv. a notice that refers to the disclaimer of 244 | warranties; 245 | 246 | v. a URI or hyperlink to the Licensed Material to the 247 | extent reasonably practicable; 248 | 249 | b. indicate if You modified the Licensed Material and 250 | retain an indication of any previous modifications; and 251 | 252 | c. indicate the Licensed Material is licensed under this 253 | Public License, and include the text of, or the URI or 254 | hyperlink to, this Public License. 255 | 256 | 2. You may satisfy the conditions in Section 3(a)(1) in any 257 | reasonable manner based on the medium, means, and context in 258 | which You Share the Licensed Material. For example, it may be 259 | reasonable to satisfy the conditions by providing a URI or 260 | hyperlink to a resource that includes the required 261 | information. 262 | 263 | 3. If requested by the Licensor, You must remove any of the 264 | information required by Section 3(a)(1)(A) to the extent 265 | reasonably practicable. 266 | 267 | 4. If You Share Adapted Material You produce, the Adapter's 268 | License You apply must not prevent recipients of the Adapted 269 | Material from complying with this Public License. 270 | 271 | Section 4 -- Sui Generis Database Rights. 272 | 273 | Where the Licensed Rights include Sui Generis Database Rights that 274 | apply to Your use of the Licensed Material: 275 | 276 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 277 | to extract, reuse, reproduce, and Share all or a substantial 278 | portion of the contents of the database for NonCommercial purposes 279 | only; 280 | 281 | b. if You include all or a substantial portion of the database 282 | contents in a database in which You have Sui Generis Database 283 | Rights, then the database in which You have Sui Generis Database 284 | Rights (but not its individual contents) is Adapted Material; and 285 | 286 | c. You must comply with the conditions in Section 3(a) if You Share 287 | all or a substantial portion of the contents of the database. 288 | 289 | For the avoidance of doubt, this Section 4 supplements and does not 290 | replace Your obligations under this Public License where the Licensed 291 | Rights include other Copyright and Similar Rights. 292 | 293 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 294 | 295 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 296 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 297 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 298 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 299 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 300 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 301 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 302 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 303 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 304 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 305 | 306 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 307 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 308 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 309 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 310 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 311 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 312 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 313 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 314 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 315 | 316 | c. The disclaimer of warranties and limitation of liability provided 317 | above shall be interpreted in a manner that, to the extent 318 | possible, most closely approximates an absolute disclaimer and 319 | waiver of all liability. 320 | 321 | Section 6 -- Term and Termination. 322 | 323 | a. This Public License applies for the term of the Copyright and 324 | Similar Rights licensed here. However, if You fail to comply with 325 | this Public License, then Your rights under this Public License 326 | terminate automatically. 327 | 328 | b. Where Your right to use the Licensed Material has terminated under 329 | Section 6(a), it reinstates: 330 | 331 | 1. automatically as of the date the violation is cured, provided 332 | it is cured within 30 days of Your discovery of the 333 | violation; or 334 | 335 | 2. upon express reinstatement by the Licensor. 336 | 337 | For the avoidance of doubt, this Section 6(b) does not affect any 338 | right the Licensor may have to seek remedies for Your violations 339 | of this Public License. 340 | 341 | c. For the avoidance of doubt, the Licensor may also offer the 342 | Licensed Material under separate terms or conditions or stop 343 | distributing the Licensed Material at any time; however, doing so 344 | will not terminate this Public License. 345 | 346 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 347 | License. 348 | 349 | Section 7 -- Other Terms and Conditions. 350 | 351 | a. The Licensor shall not be bound by any additional or different 352 | terms or conditions communicated by You unless expressly agreed. 353 | 354 | b. Any arrangements, understandings, or agreements regarding the 355 | Licensed Material not stated herein are separate from and 356 | independent of the terms and conditions of this Public License. 357 | 358 | Section 8 -- Interpretation. 359 | 360 | a. For the avoidance of doubt, this Public License does not, and 361 | shall not be interpreted to, reduce, limit, restrict, or impose 362 | conditions on any use of the Licensed Material that could lawfully 363 | be made without permission under this Public License. 364 | 365 | b. To the extent possible, if any provision of this Public License is 366 | deemed unenforceable, it shall be automatically reformed to the 367 | minimum extent necessary to make it enforceable. If the provision 368 | cannot be reformed, it shall be severed from this Public License 369 | without affecting the enforceability of the remaining terms and 370 | conditions. 371 | 372 | c. No term or condition of this Public License will be waived and no 373 | failure to comply consented to unless expressly agreed to by the 374 | Licensor. 375 | 376 | d. Nothing in this Public License constitutes or may be interpreted 377 | as a limitation upon, or waiver of, any privileges and immunities 378 | that apply to the Licensor or You, including from the legal 379 | processes of any jurisdiction or authority. 380 | 381 | ======================================================================= 382 | 383 | Creative Commons is not a party to its public 384 | licenses. Notwithstanding, Creative Commons may elect to apply one of 385 | its public licenses to material it publishes and in those instances 386 | will be considered the “Licensor.” The text of the Creative Commons 387 | public licenses is dedicated to the public domain under the CC0 Public 388 | Domain Dedication. Except for the limited purpose of indicating that 389 | material is shared under a Creative Commons public license or as 390 | otherwise permitted by the Creative Commons policies published at 391 | creativecommons.org/policies, Creative Commons does not authorize the 392 | use of the trademark "Creative Commons" or any other trademark or logo 393 | of Creative Commons without its prior written consent including, 394 | without limitation, in connection with any unauthorized modifications 395 | to any of its public licenses or any other arrangements, 396 | understandings, or agreements concerning use of licensed material. For 397 | the avoidance of doubt, this paragraph does not form part of the 398 | public licenses. 399 | 400 | Creative Commons may be contacted at creativecommons.org. 401 | -------------------------------------------------------------------------------- /bark/generation.py: -------------------------------------------------------------------------------- 1 | import contextlib 2 | import gc 3 | import hashlib 4 | import os 5 | import re 6 | 7 | from encodec import EncodecModel 8 | import funcy 9 | import logging 10 | import numpy as np 11 | from scipy.special import softmax 12 | import torch 13 | import torch.nn.functional as F 14 | import tqdm 15 | from transformers import BertTokenizer 16 | from huggingface_hub import hf_hub_download 17 | 18 | from .model import GPTConfig, GPT 19 | from .model_fine import FineGPT, FineGPTConfig 20 | 21 | if ( 22 | torch.cuda.is_available() 23 | and hasattr(torch.cuda, "amp") 24 | and hasattr(torch.cuda.amp, "autocast") 25 | and hasattr(torch.cuda, "is_bf16_supported") 26 | and torch.cuda.is_bf16_supported() 27 | ): 28 | autocast = funcy.partial(torch.cuda.amp.autocast, dtype=torch.bfloat16) 29 | else: 30 | 31 | @contextlib.contextmanager 32 | def autocast(): 33 | yield 34 | 35 | 36 | # hold models in global scope to lazy load 37 | global models 38 | models = {} 39 | 40 | global models_devices 41 | models_devices = {} 42 | 43 | 44 | CONTEXT_WINDOW_SIZE = 1024 45 | 46 | SEMANTIC_RATE_HZ = 49.9 47 | SEMANTIC_VOCAB_SIZE = 10_000 48 | 49 | CODEBOOK_SIZE = 1024 50 | N_COARSE_CODEBOOKS = 2 51 | N_FINE_CODEBOOKS = 8 52 | COARSE_RATE_HZ = 75 53 | 54 | SAMPLE_RATE = 24_000 55 | 56 | 57 | logger = logging.getLogger(__name__) 58 | 59 | 60 | CUR_PATH = os.path.dirname(os.path.abspath(__file__)) 61 | 62 | 63 | default_cache_dir = os.path.join(os.path.expanduser("~"), ".cache") 64 | CACHE_DIR = os.path.join(os.getenv("XDG_CACHE_HOME", default_cache_dir), "suno", "bark_v0") 65 | 66 | 67 | USE_SMALL_MODELS = os.environ.get("SUNO_USE_SMALL_MODELS", False) 68 | GLOBAL_ENABLE_MPS = os.environ.get("SUNO_ENABLE_MPS", False) 69 | OFFLOAD_CPU = os.environ.get("SUNO_OFFLOAD_CPU", False) 70 | 71 | 72 | REMOTE_MODEL_PATHS = { 73 | "text_small": { 74 | "repo_id": "suno/bark", 75 | "file_name": "text.pt", 76 | "checksum": "b3e42bcbab23b688355cd44128c4cdd3", 77 | }, 78 | "coarse_small": { 79 | "repo_id": "suno/bark", 80 | "file_name": "coarse.pt", 81 | "checksum": "5fe964825e3b0321f9d5f3857b89194d", 82 | }, 83 | "fine_small": { 84 | "repo_id": "suno/bark", 85 | "file_name": "fine.pt", 86 | "checksum": "5428d1befe05be2ba32195496e58dc90", 87 | }, 88 | "text": { 89 | "repo_id": "suno/bark", 90 | "file_name": "text_2.pt", 91 | "checksum": "54afa89d65e318d4f5f80e8e8799026a", 92 | }, 93 | "coarse": { 94 | "repo_id": "suno/bark", 95 | "file_name": "coarse_2.pt", 96 | "checksum": "8a98094e5e3a255a5c9c0ab7efe8fd28", 97 | }, 98 | "fine": { 99 | "repo_id": "suno/bark", 100 | "file_name": "fine_2.pt", 101 | "checksum": "59d184ed44e3650774a2f0503a48a97b", 102 | }, 103 | } 104 | 105 | 106 | if not hasattr(torch.nn.functional, "scaled_dot_product_attention") and torch.cuda.is_available(): 107 | logger.warning( 108 | "torch version does not support flash attention. You will get faster" 109 | + " inference speed by upgrade torch to newest nightly version." 110 | ) 111 | 112 | 113 | def _string_md5(s): 114 | m = hashlib.md5() 115 | m.update(s.encode("utf-8")) 116 | return m.hexdigest() 117 | 118 | 119 | def _md5(fname): 120 | hash_md5 = hashlib.md5() 121 | with open(fname, "rb") as f: 122 | for chunk in iter(lambda: f.read(4096), b""): 123 | hash_md5.update(chunk) 124 | return hash_md5.hexdigest() 125 | 126 | 127 | def _get_ckpt_path(model_type, use_small=False, path=None): 128 | model_key = f"{model_type}_small" if use_small or USE_SMALL_MODELS else model_type 129 | model_name = REMOTE_MODEL_PATHS[model_key]["file_name"] 130 | if path is None: 131 | path = CACHE_DIR 132 | return os.path.join(path, f"{model_name}") 133 | 134 | 135 | def _grab_best_device(use_gpu=True): 136 | if torch.cuda.device_count() > 0 and use_gpu: 137 | device = "cuda" 138 | elif torch.backends.mps.is_available() and use_gpu and GLOBAL_ENABLE_MPS: 139 | device = "mps" 140 | else: 141 | device = "cpu" 142 | return device 143 | 144 | 145 | def _download(from_hf_path, file_name, to_local_path): 146 | to_local_path = to_local_path.replace("\\", "/") 147 | path = "/".join(to_local_path.split("/")[:-1]) 148 | os.makedirs(path, exist_ok=True) 149 | hf_hub_download(repo_id=from_hf_path, filename=file_name, local_dir=path) 150 | os.replace(os.path.join(path, file_name), to_local_path) 151 | 152 | 153 | class InferenceContext: 154 | def __init__(self, benchmark=False): 155 | # we can't expect inputs to be the same length, so disable benchmarking by default 156 | self._chosen_cudnn_benchmark = benchmark 157 | self._cudnn_benchmark = None 158 | 159 | def __enter__(self): 160 | self._cudnn_benchmark = torch.backends.cudnn.benchmark 161 | torch.backends.cudnn.benchmark = self._chosen_cudnn_benchmark 162 | 163 | def __exit__(self, exc_type, exc_value, exc_traceback): 164 | torch.backends.cudnn.benchmark = self._cudnn_benchmark 165 | 166 | 167 | if torch.cuda.is_available(): 168 | torch.backends.cuda.matmul.allow_tf32 = True 169 | torch.backends.cudnn.allow_tf32 = True 170 | 171 | 172 | @contextlib.contextmanager 173 | def _inference_mode(): 174 | with InferenceContext(), torch.inference_mode(), torch.no_grad(), autocast(): 175 | yield 176 | 177 | 178 | def _clear_cuda_cache(): 179 | if torch.cuda.is_available(): 180 | torch.cuda.empty_cache() 181 | torch.cuda.synchronize() 182 | 183 | 184 | def clean_models(model_key=None): 185 | global models 186 | model_keys = [model_key] if model_key is not None else models.keys() 187 | for k in model_keys: 188 | if k in models: 189 | del models[k] 190 | _clear_cuda_cache() 191 | gc.collect() 192 | 193 | 194 | def _load_model(ckpt_path, device, use_small=False, model_type="text"): 195 | if model_type == "text": 196 | ConfigClass = GPTConfig 197 | ModelClass = GPT 198 | elif model_type == "coarse": 199 | ConfigClass = GPTConfig 200 | ModelClass = GPT 201 | elif model_type == "fine": 202 | ConfigClass = FineGPTConfig 203 | ModelClass = FineGPT 204 | else: 205 | raise NotImplementedError() 206 | model_key = f"{model_type}_small" if use_small or USE_SMALL_MODELS else model_type 207 | model_info = REMOTE_MODEL_PATHS[model_key] 208 | if os.path.exists(ckpt_path) and _md5(ckpt_path) != model_info["checksum"]: 209 | logger.warning(f"found outdated {model_type} model, removing.") 210 | os.remove(ckpt_path) 211 | if not os.path.exists(ckpt_path): 212 | logger.info(f"{model_type} model not found, downloading into `{CACHE_DIR}`.") 213 | _download(model_info["repo_id"], model_info["file_name"], ckpt_path) 214 | checkpoint = torch.load(ckpt_path, map_location=device) 215 | # this is a hack 216 | model_args = checkpoint["model_args"] 217 | if "input_vocab_size" not in model_args: 218 | model_args["input_vocab_size"] = model_args["vocab_size"] 219 | model_args["output_vocab_size"] = model_args["vocab_size"] 220 | del model_args["vocab_size"] 221 | gptconf = ConfigClass(**checkpoint["model_args"]) 222 | model = ModelClass(gptconf) 223 | state_dict = checkpoint["model"] 224 | # fixup checkpoint 225 | unwanted_prefix = "_orig_mod." 226 | for k, v in list(state_dict.items()): 227 | if k.startswith(unwanted_prefix): 228 | state_dict[k[len(unwanted_prefix) :]] = state_dict.pop(k) 229 | extra_keys = set(state_dict.keys()) - set(model.state_dict().keys()) 230 | extra_keys = set([k for k in extra_keys if not k.endswith(".attn.bias")]) 231 | missing_keys = set(model.state_dict().keys()) - set(state_dict.keys()) 232 | missing_keys = set([k for k in missing_keys if not k.endswith(".attn.bias")]) 233 | if len(extra_keys) != 0: 234 | raise ValueError(f"extra keys found: {extra_keys}") 235 | if len(missing_keys) != 0: 236 | raise ValueError(f"missing keys: {missing_keys}") 237 | model.load_state_dict(state_dict, strict=False) 238 | n_params = model.get_num_params() 239 | val_loss = checkpoint["best_val_loss"].item() 240 | logger.info(f"model loaded: {round(n_params/1e6,1)}M params, {round(val_loss,3)} loss") 241 | model.eval() 242 | model.to(device) 243 | del checkpoint, state_dict 244 | _clear_cuda_cache() 245 | if model_type == "text": 246 | tokenizer = BertTokenizer.from_pretrained("bert-base-multilingual-cased") 247 | return { 248 | "model": model, 249 | "tokenizer": tokenizer, 250 | } 251 | return model 252 | 253 | 254 | def _load_codec_model(device): 255 | model = EncodecModel.encodec_model_24khz() 256 | model.set_target_bandwidth(6.0) 257 | model.eval() 258 | model.to(device) 259 | _clear_cuda_cache() 260 | return model 261 | 262 | 263 | def load_model(use_gpu=True, use_small=False, force_reload=False, model_type="text", path=None): 264 | _load_model_f = funcy.partial(_load_model, model_type=model_type, use_small=use_small) 265 | if model_type not in ("text", "coarse", "fine"): 266 | raise NotImplementedError() 267 | global models 268 | global models_devices 269 | device = _grab_best_device(use_gpu=use_gpu) 270 | model_key = f"{model_type}" 271 | if OFFLOAD_CPU: 272 | models_devices[model_key] = device 273 | device = "cpu" 274 | if model_key not in models or force_reload: 275 | ckpt_path = _get_ckpt_path(model_type, use_small=use_small, path=path) 276 | clean_models(model_key=model_key) 277 | model = _load_model_f(ckpt_path, device) 278 | models[model_key] = model 279 | if model_type == "text": 280 | models[model_key]["model"].to(device) 281 | else: 282 | models[model_key].to(device) 283 | return models[model_key] 284 | 285 | 286 | def load_codec_model(use_gpu=True, force_reload=False): 287 | global models 288 | global models_devices 289 | device = _grab_best_device(use_gpu=use_gpu) 290 | if device == "mps": 291 | # encodec doesn't support mps 292 | device = "cpu" 293 | model_key = "codec" 294 | if OFFLOAD_CPU: 295 | models_devices[model_key] = device 296 | device = "cpu" 297 | if model_key not in models or force_reload: 298 | clean_models(model_key=model_key) 299 | model = _load_codec_model(device) 300 | models[model_key] = model 301 | models[model_key].to(device) 302 | return models[model_key] 303 | 304 | 305 | def preload_models( 306 | text_use_gpu=True, 307 | text_use_small=False, 308 | coarse_use_gpu=True, 309 | coarse_use_small=False, 310 | fine_use_gpu=True, 311 | fine_use_small=False, 312 | codec_use_gpu=True, 313 | force_reload=False, 314 | path=None, 315 | ): 316 | """Load all the necessary models for the pipeline.""" 317 | if _grab_best_device() == "cpu" and ( 318 | text_use_gpu or coarse_use_gpu or fine_use_gpu or codec_use_gpu 319 | ): 320 | logger.warning("No GPU being used. Careful, inference might be very slow!") 321 | _ = load_model( 322 | model_type="text", 323 | use_gpu=text_use_gpu, 324 | use_small=text_use_small, 325 | force_reload=force_reload, 326 | path=path, 327 | ) 328 | _ = load_model( 329 | model_type="coarse", 330 | use_gpu=coarse_use_gpu, 331 | use_small=coarse_use_small, 332 | force_reload=force_reload, 333 | path=path, 334 | ) 335 | _ = load_model( 336 | model_type="fine", 337 | use_gpu=fine_use_gpu, 338 | use_small=fine_use_small, 339 | force_reload=force_reload, 340 | path=path, 341 | ) 342 | _ = load_codec_model(use_gpu=codec_use_gpu, force_reload=force_reload) 343 | 344 | 345 | #### 346 | # Generation Functionality 347 | #### 348 | 349 | 350 | def _tokenize(tokenizer, text): 351 | return tokenizer.encode(text, add_special_tokens=False) 352 | 353 | 354 | def _detokenize(tokenizer, enc_text): 355 | return tokenizer.decode(enc_text) 356 | 357 | 358 | def _normalize_whitespace(text): 359 | return re.sub(r"\s+", " ", text).strip() 360 | 361 | 362 | TEXT_ENCODING_OFFSET = 10_048 363 | SEMANTIC_PAD_TOKEN = 10_000 364 | TEXT_PAD_TOKEN = 129_595 365 | SEMANTIC_INFER_TOKEN = 129_599 366 | 367 | 368 | def generate_text_semantic( 369 | text, 370 | unconditional=False, 371 | history_prompt=None, 372 | temp=0.7, 373 | top_k=None, 374 | top_p=None, 375 | silent=False, 376 | min_eos_p=0.2, 377 | max_gen_duration_s=None, 378 | allow_early_stop=True, 379 | use_kv_caching=False, 380 | ): 381 | """Generate semantic tokens from text.""" 382 | # load models if not yet exist 383 | global models 384 | global models_devices 385 | if "text" not in models: 386 | preload_models() 387 | model_container = models["text"] 388 | model = model_container["model"] 389 | tokenizer = model_container["tokenizer"] 390 | 391 | if not unconditional: 392 | assert isinstance(text, str) 393 | text = _normalize_whitespace(text) 394 | assert len(text.strip()) > 0 395 | if history_prompt is not None: 396 | if history_prompt.endswith(".npz"): 397 | semantic_history = np.load(history_prompt)["semantic_prompt"] 398 | else: 399 | semantic_history = np.load( 400 | os.path.join(CUR_PATH, "assets", "prompts", f"{history_prompt}.npz") 401 | )["semantic_prompt"] 402 | assert isinstance(semantic_history, np.ndarray) and semantic_history.shape[0] > 0 403 | semantic_history_ndim = semantic_history.ndim 404 | assert semantic_history_ndim in [1, 2] 405 | if semantic_history_ndim == 2: 406 | assert semantic_history.shape[1] == model.config.n_embd 407 | else: 408 | semantic_history = None 409 | encoded_text = np.array(_tokenize(tokenizer, text)) + TEXT_ENCODING_OFFSET 410 | if OFFLOAD_CPU: 411 | model.to(models_devices["text"]) 412 | device = next(model.parameters()).device 413 | if len(encoded_text) > 256: 414 | p = round((len(encoded_text) - 256) / len(encoded_text) * 100, 1) 415 | logger.warning(f"warning, text too long, lopping off last {p}%") 416 | encoded_text = encoded_text[:256] 417 | encoded_text = np.pad( 418 | encoded_text, 419 | (0, 256 - len(encoded_text)), 420 | constant_values=TEXT_PAD_TOKEN, 421 | mode="constant", 422 | ) 423 | if history_prompt is not None and semantic_history_ndim == 2: 424 | semantic_history = semantic_history[-256:, :] 425 | 426 | padding_embedding = model.transformer.wte( 427 | torch.from_numpy(np.array(SEMANTIC_PAD_TOKEN).astype(np.int64)).to(device) 428 | ).unsqueeze(0) 429 | emb_pad_length = 256 - semantic_history.shape[0] 430 | padding_tensor = padding_embedding.repeat(emb_pad_length, 1).to(device) 431 | semantic_history = torch.cat( 432 | [torch.from_numpy(semantic_history).to(device), padding_tensor], dim=0 433 | ) 434 | else: 435 | if semantic_history is not None: 436 | semantic_history = semantic_history.astype(np.int64) 437 | # lop off if history is too long, pad if needed 438 | semantic_history = semantic_history[-256:] 439 | semantic_history = np.pad( 440 | semantic_history, 441 | (0, 256 - len(semantic_history)), 442 | constant_values=SEMANTIC_PAD_TOKEN, 443 | mode="constant", 444 | ) 445 | else: 446 | semantic_history = np.array([SEMANTIC_PAD_TOKEN] * 256) 447 | 448 | semantic_history = model.transformer.wte(torch.from_numpy(semantic_history.astype(np.int64)).to(device)) 449 | 450 | encoded_text = torch.from_numpy(encoded_text.astype(np.int64)).to(device) 451 | prompt_history = model.transformer.wte(encoded_text) + semantic_history 452 | end_token = model.transformer.wte( 453 | torch.from_numpy(np.array([SEMANTIC_INFER_TOKEN], dtype=np.int64)).to(device) 454 | ) 455 | 456 | x = torch.cat( 457 | [prompt_history, end_token], 458 | dim=0, 459 | ).unsqueeze(0) 460 | assert x.shape[1] == 256 + 1 461 | with _inference_mode(): 462 | x = x.to(device) 463 | out = torch.empty((1, 0), dtype=torch.int64).to(device) 464 | n_tot_steps = 768 465 | # custom tqdm updates since we don't know when eos will occur 466 | pbar = tqdm.tqdm(disable=silent, total=100) 467 | pbar_state = 0 468 | tot_generated_duration_s = 0 469 | kv_cache = None 470 | for n in range(n_tot_steps): 471 | if use_kv_caching and kv_cache is not None: 472 | x_input = x[:, [-1], :] 473 | else: 474 | x_input = x 475 | logits, kv_cache = model( 476 | None, input_embeds=x_input, use_cache=use_kv_caching, past_kv=kv_cache 477 | ) 478 | relevant_logits = logits[0, 0, :SEMANTIC_VOCAB_SIZE] 479 | if allow_early_stop: 480 | relevant_logits = torch.hstack( 481 | (relevant_logits, logits[0, 0, [SEMANTIC_PAD_TOKEN]]) # eos 482 | ) 483 | if top_p is not None: 484 | # faster to convert to numpy 485 | logits_device = relevant_logits.device 486 | logits_dtype = relevant_logits.type() 487 | relevant_logits = relevant_logits.detach().cpu().type(torch.float32).numpy() 488 | sorted_indices = np.argsort(relevant_logits)[::-1] 489 | sorted_logits = relevant_logits[sorted_indices] 490 | cumulative_probs = np.cumsum(softmax(sorted_logits)) 491 | sorted_indices_to_remove = cumulative_probs > top_p 492 | sorted_indices_to_remove[1:] = sorted_indices_to_remove[:-1].copy() 493 | sorted_indices_to_remove[0] = False 494 | relevant_logits[sorted_indices[sorted_indices_to_remove]] = -np.inf 495 | relevant_logits = torch.from_numpy(relevant_logits) 496 | relevant_logits = relevant_logits.to(logits_device).type(logits_dtype) 497 | if top_k is not None: 498 | v, _ = torch.topk(relevant_logits, min(top_k, relevant_logits.size(-1))) 499 | relevant_logits[relevant_logits < v[-1]] = -float("Inf") 500 | probs = F.softmax(relevant_logits / temp, dim=-1) 501 | # multinomial bugged on mps: shuttle to cpu if necessary 502 | inf_device = probs.device 503 | if probs.device.type == "mps": 504 | probs = probs.to("cpu") 505 | item_next = torch.multinomial(probs, num_samples=1) 506 | probs = probs.to(inf_device) 507 | item_next = item_next.to(inf_device) 508 | if allow_early_stop and ( 509 | item_next == SEMANTIC_VOCAB_SIZE 510 | or (min_eos_p is not None and probs[-1] >= min_eos_p) 511 | ): 512 | # eos found, so break 513 | pbar.update(100 - pbar_state) 514 | break 515 | out = torch.cat((out, item_next[None]), dim=1) 516 | x = torch.cat((x, model.transformer.wte(item_next[None])), dim=1) 517 | tot_generated_duration_s += 1 / SEMANTIC_RATE_HZ 518 | if max_gen_duration_s is not None and tot_generated_duration_s > max_gen_duration_s: 519 | pbar.update(100 - pbar_state) 520 | break 521 | if n == n_tot_steps - 1: 522 | pbar.update(100 - pbar_state) 523 | break 524 | del logits, relevant_logits, probs, item_next 525 | req_pbar_state = np.min([100, int(round(100 * n / n_tot_steps))]) 526 | if req_pbar_state > pbar_state: 527 | pbar.update(req_pbar_state - pbar_state) 528 | pbar_state = req_pbar_state 529 | pbar.close() 530 | out = out.detach().cpu().numpy().squeeze() 531 | if OFFLOAD_CPU: 532 | model.to("cpu") 533 | assert all(0 <= out) and all(out < SEMANTIC_VOCAB_SIZE) 534 | _clear_cuda_cache() 535 | return out 536 | 537 | 538 | def _flatten_codebooks(arr, offset_size=CODEBOOK_SIZE): 539 | assert len(arr.shape) == 2 540 | arr = arr.copy() 541 | if offset_size is not None: 542 | for n in range(1, arr.shape[0]): 543 | arr[n, :] += offset_size * n 544 | flat_arr = arr.ravel("F") 545 | return flat_arr 546 | 547 | 548 | COARSE_SEMANTIC_PAD_TOKEN = 12_048 549 | COARSE_INFER_TOKEN = 12_050 550 | 551 | 552 | def generate_coarse( 553 | x_semantic, 554 | history_prompt=None, 555 | temp=0.7, 556 | top_k=None, 557 | top_p=None, 558 | silent=False, 559 | max_coarse_history=630, # min 60 (faster), max 630 (more context) 560 | sliding_window_len=60, 561 | use_kv_caching=False, 562 | ): 563 | """Generate coarse audio codes from semantic tokens.""" 564 | assert ( 565 | isinstance(x_semantic, np.ndarray) 566 | and len(x_semantic.shape) == 1 567 | and len(x_semantic) > 0 568 | and x_semantic.min() >= 0 569 | and x_semantic.max() <= SEMANTIC_VOCAB_SIZE - 1 570 | ) 571 | assert 60 <= max_coarse_history <= 630 572 | assert max_coarse_history + sliding_window_len <= 1024 - 256 573 | semantic_to_coarse_ratio = COARSE_RATE_HZ / SEMANTIC_RATE_HZ * N_COARSE_CODEBOOKS 574 | max_semantic_history = int(np.floor(max_coarse_history / semantic_to_coarse_ratio)) 575 | if history_prompt is not None: 576 | if history_prompt.endswith(".npz"): 577 | x_history = np.load(history_prompt) 578 | else: 579 | x_history = np.load( 580 | os.path.join(CUR_PATH, "assets", "prompts", f"{history_prompt}.npz") 581 | ) 582 | x_semantic_history = x_history["semantic_prompt"] 583 | x_coarse_history = x_history["coarse_prompt"] 584 | x_semantic_history_n_entries = x_semantic_history.shape[0] 585 | assert ( 586 | isinstance(x_semantic_history, np.ndarray) 587 | and len(x_semantic_history.shape) in [1, 2] 588 | and x_semantic_history.shape[0] > 0 589 | ) 590 | 591 | assert ( 592 | isinstance(x_coarse_history, np.ndarray) 593 | and len(x_coarse_history.shape) == 2 594 | and x_coarse_history.shape[0] == N_COARSE_CODEBOOKS 595 | and x_coarse_history.shape[-1] >= 0 596 | and x_coarse_history.min() >= 0 597 | and x_coarse_history.max() <= CODEBOOK_SIZE - 1 598 | and ( 599 | round(x_coarse_history.shape[-1] / len(x_semantic_history), 1) 600 | == round(semantic_to_coarse_ratio / N_COARSE_CODEBOOKS, 1) 601 | ) 602 | ) 603 | x_coarse_history = _flatten_codebooks(x_coarse_history) + SEMANTIC_VOCAB_SIZE 604 | # trim histories correctly 605 | n_semantic_hist_provided = np.min( 606 | [ 607 | max_semantic_history, 608 | x_semantic_history_n_entries - x_semantic_history_n_entries % 2, 609 | int(np.floor(len(x_coarse_history) / semantic_to_coarse_ratio)), 610 | ] 611 | ) 612 | n_coarse_hist_provided = int(round(n_semantic_hist_provided * semantic_to_coarse_ratio)) 613 | x_semantic_history = x_semantic_history[-n_semantic_hist_provided:, ...].astype(np.int32) 614 | x_coarse_history = x_coarse_history[-n_coarse_hist_provided:].astype(np.int32) 615 | # TODO: bit of a hack for time alignment (sounds better) 616 | x_coarse_history = x_coarse_history[:-2] 617 | else: 618 | x_semantic_history = np.array([], dtype=np.int32) 619 | x_semantic_history_n_entries = x_semantic_history.shape[0] 620 | x_coarse_history = np.array([], dtype=np.int32) 621 | # load models if not yet exist 622 | global models 623 | global models_devices 624 | if "coarse" not in models: 625 | preload_models() 626 | model = models["coarse"] 627 | if OFFLOAD_CPU: 628 | model.to(models_devices["coarse"]) 629 | device = next(model.parameters()).device 630 | # start loop 631 | n_steps = int( 632 | round( 633 | np.floor(len(x_semantic) * semantic_to_coarse_ratio / N_COARSE_CODEBOOKS) 634 | * N_COARSE_CODEBOOKS 635 | ) 636 | ) 637 | assert n_steps > 0 and n_steps % N_COARSE_CODEBOOKS == 0 638 | # pre-embed! 639 | x_semantic = model.transformer.wte(torch.tensor(x_semantic).to(device)) 640 | x_semantic_history = torch.tensor(x_semantic_history).to(device) 641 | if x_semantic_history.ndim == 1: 642 | x_semantic_history = model.transformer.wte(x_semantic_history) 643 | x_semantic = torch.cat((x_semantic_history, x_semantic)) 644 | x_coarse = torch.from_numpy(x_coarse_history.astype(np.int32)).to(device) 645 | x_coarse = model.transformer.wte(x_coarse) 646 | base_semantic_idx = x_semantic_history_n_entries 647 | with _inference_mode(): 648 | # x_semantic_in = torch.from_numpy(x_semantic)[None].to(device) 649 | x_semantic_in = x_semantic[None] 650 | x_coarse_in = x_coarse[None] 651 | n_window_steps = int(np.ceil(n_steps / sliding_window_len)) 652 | out = torch.empty((1, 0), dtype=torch.int64).to(device) 653 | n_step = 0 654 | for _ in tqdm.tqdm(range(n_window_steps), total=n_window_steps, disable=silent): 655 | semantic_idx = base_semantic_idx + int(round(n_step / semantic_to_coarse_ratio)) 656 | # pad from right side 657 | x_in = x_semantic_in[:, max([0, semantic_idx - max_semantic_history]) :, :] 658 | x_in = x_in[:, :256, :] 659 | semantic_pad = model.transformer.wte(torch.tensor([COARSE_SEMANTIC_PAD_TOKEN]).to(device)) 660 | # Calculate the padding size 661 | padding_size = 256 - x_in.shape[1] 662 | 663 | if padding_size > 0: 664 | # Create a tensor filled with the semantic_pad tensor 665 | pad_tensor = semantic_pad.repeat(1, padding_size, 1) 666 | 667 | # Concatenate the pad_tensor along the second axis 668 | x_in = torch.cat((x_in, pad_tensor), dim=1) 669 | 670 | infer_embed = model.transformer.wte(torch.tensor([COARSE_INFER_TOKEN]).to(device))[None] 671 | x_in = torch.hstack( 672 | [ 673 | x_in, 674 | infer_embed, 675 | x_coarse_in[:, -max_coarse_history:, :], 676 | ] 677 | ) 678 | kv_cache = None 679 | for _ in range(sliding_window_len): 680 | if n_step >= n_steps: 681 | continue 682 | is_major_step = n_step % N_COARSE_CODEBOOKS == 0 683 | 684 | if use_kv_caching and kv_cache is not None: 685 | x_input = x_in[:, [-1], :] 686 | else: 687 | x_input = x_in 688 | 689 | logits, kv_cache = model( 690 | None, input_embeds=x_input, use_cache=use_kv_caching, past_kv=kv_cache 691 | ) 692 | logit_start_idx = SEMANTIC_VOCAB_SIZE + (1 - int(is_major_step)) * CODEBOOK_SIZE 693 | logit_end_idx = SEMANTIC_VOCAB_SIZE + (2 - int(is_major_step)) * CODEBOOK_SIZE 694 | relevant_logits = logits[0, 0, logit_start_idx:logit_end_idx] 695 | if top_p is not None: 696 | # faster to convert to numpy 697 | logits_device = relevant_logits.device 698 | logits_dtype = relevant_logits.type() 699 | relevant_logits = relevant_logits.detach().cpu().type(torch.float32).numpy() 700 | sorted_indices = np.argsort(relevant_logits)[::-1] 701 | sorted_logits = relevant_logits[sorted_indices] 702 | cumulative_probs = np.cumsum(softmax(sorted_logits)) 703 | sorted_indices_to_remove = cumulative_probs > top_p 704 | sorted_indices_to_remove[1:] = sorted_indices_to_remove[:-1].copy() 705 | sorted_indices_to_remove[0] = False 706 | relevant_logits[sorted_indices[sorted_indices_to_remove]] = -np.inf 707 | relevant_logits = torch.from_numpy(relevant_logits) 708 | relevant_logits = relevant_logits.to(logits_device).type(logits_dtype) 709 | if top_k is not None: 710 | v, _ = torch.topk(relevant_logits, min(top_k, relevant_logits.size(-1))) 711 | relevant_logits[relevant_logits < v[-1]] = -float("Inf") 712 | probs = F.softmax(relevant_logits / temp, dim=-1) 713 | # multinomial bugged on mps: shuttle to cpu if necessary 714 | inf_device = probs.device 715 | if probs.device.type == "mps": 716 | probs = probs.to("cpu") 717 | item_next = torch.multinomial(probs, num_samples=1) 718 | probs = probs.to(inf_device) 719 | item_next = item_next.to(inf_device) 720 | item_next += logit_start_idx 721 | out = torch.cat((out, item_next[None]), dim=1) 722 | item_next_emb = model.transformer.wte(item_next) 723 | x_coarse_in = torch.cat((x_coarse_in, item_next_emb[None]), dim=1) 724 | x_in = torch.cat((x_in, item_next_emb[None]), dim=1) 725 | del logits, relevant_logits, probs, item_next, item_next_emb 726 | n_step += 1 727 | del x_in 728 | del x_semantic_in 729 | print(n_step) 730 | if OFFLOAD_CPU: 731 | model.to("cpu") 732 | gen_coarse_arr = out.detach().cpu().numpy().squeeze() 733 | del out, x_coarse_in 734 | print(f"Generated coarse tokens: {len(gen_coarse_arr)}, predicted: {n_steps}") 735 | assert len(gen_coarse_arr) == n_steps 736 | gen_coarse_audio_arr = gen_coarse_arr.reshape(-1, N_COARSE_CODEBOOKS).T - SEMANTIC_VOCAB_SIZE 737 | for n in range(1, N_COARSE_CODEBOOKS): 738 | gen_coarse_audio_arr[n, :] -= n * CODEBOOK_SIZE 739 | _clear_cuda_cache() 740 | return gen_coarse_audio_arr 741 | 742 | 743 | def generate_fine( 744 | x_coarse_gen, 745 | history_prompt=None, 746 | temp=0.5, 747 | silent=True, 748 | ): 749 | """Generate full audio codes from coarse audio codes.""" 750 | assert ( 751 | isinstance(x_coarse_gen, np.ndarray) 752 | and len(x_coarse_gen.shape) == 2 753 | and 1 <= x_coarse_gen.shape[0] <= N_FINE_CODEBOOKS - 1 754 | and x_coarse_gen.shape[1] > 0 755 | and x_coarse_gen.min() >= 0 756 | and x_coarse_gen.max() <= CODEBOOK_SIZE - 1 757 | ) 758 | if history_prompt is not None: 759 | if history_prompt.endswith(".npz"): 760 | x_fine_history = np.load(history_prompt)["fine_prompt"] 761 | else: 762 | x_fine_history = np.load( 763 | os.path.join(CUR_PATH, "assets", "prompts", f"{history_prompt}.npz") 764 | )["fine_prompt"] 765 | assert ( 766 | isinstance(x_fine_history, np.ndarray) 767 | and len(x_fine_history.shape) == 2 768 | and x_fine_history.shape[0] == N_FINE_CODEBOOKS 769 | and x_fine_history.shape[1] >= 0 770 | and x_fine_history.min() >= 0 771 | and x_fine_history.max() <= CODEBOOK_SIZE - 1 772 | ) 773 | else: 774 | x_fine_history = None 775 | n_coarse = x_coarse_gen.shape[0] 776 | # load models if not yet exist 777 | global models 778 | global models_devices 779 | if "fine" not in models: 780 | preload_models() 781 | model = models["fine"] 782 | if OFFLOAD_CPU: 783 | model.to(models_devices["fine"]) 784 | device = next(model.parameters()).device 785 | # make input arr 786 | in_arr = np.vstack( 787 | [ 788 | x_coarse_gen, 789 | np.zeros((N_FINE_CODEBOOKS - n_coarse, x_coarse_gen.shape[1])) 790 | + CODEBOOK_SIZE, # padding 791 | ] 792 | ).astype(np.int32) 793 | # prepend history if available (max 512) 794 | if x_fine_history is not None: 795 | x_fine_history = x_fine_history.astype(np.int32) 796 | in_arr = np.hstack( 797 | [ 798 | x_fine_history[:, -512:].astype(np.int32), 799 | in_arr, 800 | ] 801 | ) 802 | n_history = x_fine_history[:, -512:].shape[1] 803 | else: 804 | n_history = 0 805 | n_remove_from_end = 0 806 | # need to pad if too short (since non-causal model) 807 | if in_arr.shape[1] < 1024: 808 | n_remove_from_end = 1024 - in_arr.shape[1] 809 | in_arr = np.hstack( 810 | [ 811 | in_arr, 812 | np.zeros((N_FINE_CODEBOOKS, n_remove_from_end), dtype=np.int32) + CODEBOOK_SIZE, 813 | ] 814 | ) 815 | # we can be lazy about fractional loop and just keep overwriting codebooks 816 | n_loops = np.max([0, int(np.ceil((x_coarse_gen.shape[1] - (1024 - n_history)) / 512))]) + 1 817 | with _inference_mode(): 818 | in_arr = torch.tensor(in_arr.T).to(device) 819 | for n in tqdm.tqdm(range(n_loops), disable=silent): 820 | start_idx = np.min([n * 512, in_arr.shape[0] - 1024]) 821 | start_fill_idx = np.min([n_history + n * 512, in_arr.shape[0] - 512]) 822 | rel_start_fill_idx = start_fill_idx - start_idx 823 | in_buffer = in_arr[start_idx : start_idx + 1024, :][None] 824 | for nn in range(n_coarse, N_FINE_CODEBOOKS): 825 | logits = model(nn, in_buffer) 826 | if temp is None: 827 | relevant_logits = logits[0, rel_start_fill_idx:, :CODEBOOK_SIZE] 828 | codebook_preds = torch.argmax(relevant_logits, -1) 829 | else: 830 | relevant_logits = logits[0, :, :CODEBOOK_SIZE] / temp 831 | probs = F.softmax(relevant_logits, dim=-1) 832 | # multinomial bugged on mps: shuttle to cpu if necessary 833 | inf_device = probs.device 834 | if probs.device.type == "mps": 835 | probs = probs.to("cpu") 836 | codebook_preds = torch.hstack( 837 | [ 838 | torch.multinomial(probs[nnn], num_samples=1).to(inf_device) 839 | for nnn in range(rel_start_fill_idx, 1024) 840 | ] 841 | ) 842 | in_buffer[0, rel_start_fill_idx:, nn] = codebook_preds 843 | del logits, codebook_preds 844 | # transfer over info into model_in and convert to numpy 845 | for nn in range(n_coarse, N_FINE_CODEBOOKS): 846 | in_arr[ 847 | start_fill_idx : start_fill_idx + (1024 - rel_start_fill_idx), nn 848 | ] = in_buffer[0, rel_start_fill_idx:, nn] 849 | del in_buffer 850 | gen_fine_arr = in_arr.detach().cpu().numpy().squeeze().T 851 | del in_arr 852 | if OFFLOAD_CPU: 853 | model.to("cpu") 854 | gen_fine_arr = gen_fine_arr[:, n_history:] 855 | if n_remove_from_end > 0: 856 | gen_fine_arr = gen_fine_arr[:, :-n_remove_from_end] 857 | assert gen_fine_arr.shape[-1] == x_coarse_gen.shape[-1] 858 | _clear_cuda_cache() 859 | return gen_fine_arr 860 | 861 | 862 | def codec_decode(fine_tokens): 863 | """Turn quantized audio codes into audio array using encodec.""" 864 | # load models if not yet exist 865 | global models 866 | global models_devices 867 | if "codec" not in models: 868 | preload_models() 869 | model = models["codec"] 870 | if OFFLOAD_CPU: 871 | model.to(models_devices["codec"]) 872 | device = next(model.parameters()).device 873 | arr = torch.from_numpy(fine_tokens)[None] 874 | arr = arr.to(device) 875 | arr = arr.transpose(0, 1) 876 | emb = model.quantizer.decode(arr) 877 | out = model.decoder(emb) 878 | audio_arr = out.detach().cpu().numpy().squeeze() 879 | del arr, emb, out 880 | if OFFLOAD_CPU: 881 | model.to("cpu") 882 | return audio_arr 883 | -------------------------------------------------------------------------------- /notebooks/fake_classifier.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "id": "e330c1de", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "import torchaudio\n", 11 | "from transformers import HubertModel\n", 12 | "from sklearn.metrics import PrecisionRecallDisplay" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": null, 18 | "id": "2ac3dd88", 19 | "metadata": {}, 20 | "outputs": [], 21 | "source": [ 22 | "# use hubert from HF for feature embedding\n", 23 | "model = HubertModel.from_pretrained(\"facebook/hubert-base-ls960\")\n", 24 | "arr, sr = torchaudio.load(\"my_audio.wav\")\n", 25 | "if sr != 16_000:\n", 26 | " arr = torchaudio.functional.resample(arr, sr, 16_000)\n", 27 | "# use intermediate layer\n", 28 | "hidden_state = model(arr[None], output_hidden_states=True).hidden_states[6]\n", 29 | "# take mean over time\n", 30 | "feats = hidden_state.detach().cpu().numpy().squeeze().mean(0)" 31 | ] 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": null, 36 | "id": "03a602e0", 37 | "metadata": {}, 38 | "outputs": [], 39 | "source": [ 40 | "# load sk-learn classifier from here: https://dl.suno-models.io/bark/models/v0/classifier.pkl\n", 41 | "with open(\"classifier.pkl\", \"rb\") as f:\n", 42 | " clf = pickle.load(f)" 43 | ] 44 | }, 45 | { 46 | "cell_type": "markdown", 47 | "id": "8e423794", 48 | "metadata": {}, 49 | "source": [ 50 | "### Precision-recall curve on test set" 51 | ] 52 | }, 53 | { 54 | "attachments": { 55 | "image.png": { 56 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAjcAAAHFCAIAAACB+E92AAAMPmlDQ1BJQ0MgUHJvZmlsZQAASImVVwdYU8kWnltSIbQAAlJCb4JIDSAlhBZAercRkgChxBgIKnZkUcG1oGIBG7oqothpdsTOotj7YkFFWRcLduVNCui6r3xvvm/u/PefM/85c+7MvXcAUD/OFYtzUQ0A8kQFktiQAEZySiqD9BTggAyogAKMuLx8MSs6OgLAMtj+vby7DhBZe8VBpvXP/v9aNPmCfB4ASDTE6fx8Xh7EBwDAq3liSQEARBlvPqVALMOwAm0JDBDiBTKcqcDVMpyuwHvkNvGxbIjbACCrcrmSTADULkGeUcjLhBpqfRA7ifhCEQDqDIh98/Im8SFOg9gG2oghlukz03/QyfybZvqQJpebOYQVc5EXcqAwX5zLnfZ/puN/l7xc6aAPK1hVsyShsbI5w7zdzJkULsOqEPeK0iOjINaC+IOQL7eHGKVmSUMTFPaoIS+fDXMGdCF24nMDwyE2hDhYlBsZoeTTM4TBHIjhCkGnCgs48RDrQbxAkB8Up7TZKJkUq/SFNmRI2Cwlf5YrkfuV+bovzUlgKfVfZwk4Sn1MrSgrPgliKsQWhcLESIjVIHbMz4kLV9qMLspiRw7aSKSxsvgtII4ViEICFPpYYYYkOFZpX5aXPzhfbGOWkBOpxPsKsuJDFfnB2nhcefxwLtglgYiVMKgjyE+OGJwLXxAYpJg79kwgSohT6nwQFwTEKsbiVHFutNIeNxPkhsh4M4hd8wvjlGPxxAK4IBX6eIa4IDpeESdelM0Ni1bEgy8FEYANAgEDSGFNB5NANhB29Db2wjtFTzDgAgnIBALgoGQGRyTJe0TwGgeKwJ8QCUD+0LgAea8AFEL+6xCruDqADHlvoXxEDngCcR4IB7nwXiofJRrylggeQ0b4D+9cWHkw3lxYZf3/nh9kvzMsyEQoGemgR4b6oCUxiBhIDCUGE21xA9wX98Yj4NUfVmeci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gAgAEAAAAAQAAAjegAwAEAAAAAQAAAcUAAAAAljFVdgAAQABJREFUeAHtnQeYFMW6hg8sOecoOUiSICgCoqIIAhKMoChBUNGjJEUJAoICogJKRgVRjygq4FEEFEUBRUBAESRJzjnnZZf7Ql3r9DMzO9O7O7M7O/v19XCrq6srvD1bX/9Vf1eluXz58r90iIAIiIAIiEBYEkgblrVSpURABERABETgCgGplH4HIiACIiAC4UtAKhW+z0Y1EwEREAERkErpNyACIiACIhC+BKRS4ftsVDMREAEREAGplH4DIiACIiAC4UtAKhW+z0Y1EwEREAERkErpNyACIiACIhC+BKRS4ftsVDMREAEREAGplH4D8SOwYMGCxx57rEKFClmzZi1atGjLli1XrlwZvywcqV9++eU0adI4IkIevO222yjRHJkzZ65Wrdpbb70VGxsbioIphQYGzDnUEP5p7pX/nyNHjrp1637yyScBa5X4BB7tgjxH4rNVDqmNgFQqtT3xxLZ3woQJ27dv79at25w5c95+++2DBw/edNNNSFdi803C+0uXLv3r1WP69OkIbY8ePfr06ROK8imkc+fOAXMmDSkDJktMgvvvv58ilixZMnHixJMnTz788MPTpk1LTIa6VwSSjEC6JCtJBUUGgXHjxhUoUMC25a677ipbtuzQoUNvv/12GxnmAUwolNVUskmTJtiFY8eOffXVV9OnT++sOUtcnj9/nsTOyHiFbSn+77rm6uE/TSKvFixY0FSmTp069erVK1my5KRJk9CqRGYbhrdHR0djMqZLp54tDB9OAqskWyqB4FLtbU6JAkK2bNkqVaq0a9cu/0DmzZt3xx135MyZM0uWLBUrVhw2bJjP9Bg3jRo1Kly4MNpAst69e585c8am3Lp1a5s2bYoUKZIxY0a6XTL8448/zFWMOUaT8ubNy43Fixe/7777zp49a2/0E0CZatasSeJDhw6RjA7umWeeweCgdEr54IMPiPz777/p0Gk4McSj084Mjx8//txzz2GfcZU0TZs23bBhg0lAbnbEjyKef/75UqVKZcqUKU+ePLVq1bLDbh4jYww/vv7662inybBdu3a7d++2JdLMKlWq/Pbbb/Xr1wcm5b722mvxGrEsUaJ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rUBEQAREQAVcEpFKuMCmRCIiACIhAshCQSiULdhUqAiIgAiLgioBUyhUmJRIBERABEUgWAlKpZMGuQkVABERABFwRkEq5wqREIiACIiACyUJAKpUs2FWoCIiACIiAKwJSKVeYlEgEREAERCBZCEilkgW7ChUBERABEXBFQCrlCpMSiYAIiIAIJAsBqVSyYFehIiACIiACrghIpVxhUiIREAEREIFkIRBylRo/fnypUqUyZcpUs2bNxYsX+2zkuHHjKlasmDlz5muvvfbDDz/0mUaRIiACIiACqZBAupC2efr06d27d0eo6tWrN2nSpCZNmqxbt6548eLOQidMmNCnT5933333hhtuWL58+eOPP547d+7mzZs70ygsAiIgAiKQOgmE1pYaOXJkp06dOnfujKn01ltvFStWDE3yAP3RRx89+eSTrVu3Ll26dJs2bUg/fPhwjzQ6FQEREAERSJ0EQqhSFy9eXLlyZaNGjSxZwkuWLLGnJnDhwgXGA20k435YVNHR0TbGJjvpODyu6lQEREAERCAiCYRQpQ4fPhwTE1OwYEELjvD+/fvtqQk0btz4vffeQ88uX768YsWKKVOmIFHc65Fs2LBhOf85sMk8rupUBERABEQgIgmEUKUMrzRp0lhw6JDz1MT379+f+aqbbropffr0LVu27NChA/FRUVH2LhNg7urEP8euXbs8rupUBERABEQgIgmEUKXy5cuH2DiNp4MHDzpNKwOUIT7sp7Nnz27fvn3nzp0lS5bMnj0793rgzpgxYw7H4XFVpyIgAiIgAhFJIIQqlSFDBrzP58+fb8ERrlu3rj11BjCkrrnmGlTt008/vfvuu9OmDWHFnOUqLAIiIAIiEM4EQuuJ3rNnz0cffbRWrVp16tR55513MJW6dOkCDobv9uzZYz6N2rRpE+4StWvXPnbsGD6Ba9eu/eCDD8IZmeomAiIgAiKQZARCq1L4lx85cmTw4MH79u2rUqXKnDlzSpQoQds4RbFMI/GwGDFixMaNGzGnGjRogBMgg35J1n4VJAIiIAIiEM4E0uDREM7181k3PNJx98OXgokqnwkUKQIiIAIiEHQCbd9b+svmI2+3qd6yetFgZR6wP9f0T7BQKx8REAEREIHgE5BKBZ+pchQBERABEQgWAalUsEgqHxEQAREQgeATkEoFn6lyFAEREAERCBYBVz5+eFgsXLiQfTf48JbPb/Pnz1+jRo2GDRtqpaJgPQblIwIiIAIi4JNAAFvq3LlzQ4cORY1YxOibb745fvw4H95u3rx54MCB7BrVtGnTpUuX+sxXkSIgAiIgAiKQeAIBbKny5cvzve3EiRNZE5bvmZzl7dixY9q0aXwR9dJLL7EplPOSwiIgAiIgAiIQFAIBvpdiJQi+xvVTEttzIFflypXzkybolwL61we9RGUoAiIgAiJQsvc3BsKrrao8ctOVJRoSfwTszwOM+PmXKOrHYn1JLFGJh6IcREAEREAEEkNgzpp9ibk9XvcGUCk/eZ05c2bRokV+EuiSCIiACIhAJBH4pfftBbJnTOIWJVyl8KFg2b0krq6KEwEREAERSC4CRXNl7tesYhKXnnCVSuKKqjgREAEREIFUSCCAjx9E8uTJ45MLa5n7jFekCIiACIiACASLQGCVunDhwlNPPXXdddd5FIlr36BBgzwidSoCIiACIiACQSQQWKWqV6/OV73t27f3KHX16tVSKQ8mOhUBERABEQgugcDzUs2aNWPJCe9SGQls166dd7xiREAEREAERCBYBALbUn379vVZGAbW+++/7/OSIkVABERABEQgKAQC21JBKUaZiIAIiIAIiEACCEilEgBNt4iACIiACCQRAalUEoFWMSIgAiIgAgkgIJVKADTdIgIiIAIikEQEpFJJBFrFiIAIiIAIJICAVCoB0HSLCIiACIhAEhGIh0o99thj/fr1s/XCQ50Ye6qACIiACIiACASdQODvpWyR27Zti42Ntad79uzZtWuXPVVABERABERABIJOIB4q9eOPPzqL/+CDD5ynCouACIiACIhA0AnEY8Qv6GUrQxEQAREQARHwTyCALfXVV1/5v79Fixb+E+iqCIiACIiACCSYQACVatWqlZ+s06RJo12m/PDRJREQAREQgUQSCKBSTneJRJak20VABERABEQgvgTiPS91/vz5+Jah9CIgAiIgAiKQMAJuVYqRvVdeeaVo0aLZsmXbunUrhfXv33/y5MkJK1V3iYAIiIAIiIAbAm5VasiQIVOnTn399d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9InUqAiIgAiIgAkEhEEClmJRi/0N26c2VK5edlDIFG38KJqiCUg9lIgIiIAIiIALeBAKo1IIFC4wj348//uh9s2JEQAREQAREIKQEAqjUrbfeaoq3gZDWRpmLgAiIgAiIgJOA2++l5s2b9/PPP5s7x40bV7169Ycffpgde515KSwCIiACIiACwSXgVqV69eqFJwVlr1mzpmfPnuzYu3XrVgLBrY1yEwEREAEREAEngQAjfjYpq81WqlSJ0xkzZjRv3nzo0KGrVq1Cq2wCBURABERABEQg6ATc2lJ8xmtWm/3+++8bNWpEPfCqMNZV0OukDEVABERABETAEHBrS918882M79WrV2/58uVsLc/NmzZtuuaaa8RRBERABERABEJHwK0tNXbs2HTp0n3xxRcTJkwoWrQoFZo7d+5dd90VupopZxEQAREQARFwa0sVL1589uzZTl4+d+91JlBYBERABERABBJJwK1KUQzLTHz55Zfr169nEYqKFSu2bNkyKioqkcXrdhEQAREQARHwQ8CtSm3evBmPvj179lx77bWsjcSkVLFixb755psyZcr4yV2XREAEREAERCAxBNzOS3Xt2hVB2rVrFw7ov//++86dO1klncjElK17RUAEREAERMA/Abe21MKFC5cuXWo3582bN+9rr72Gy5//3HVVBERABERABBJDwK0tlTFjxlOnTjlLYq9ePqJyxigsAiIgAiIgAsEl4Fal7r777ieeeGLZsmVMSnFgV7GdfIsWLYJbG+UmAiIgAiIgAk4CblVq9OjRzEuxhXymqwdjfWXLln377bedeSksAiIgAiIgAsEl4HZeil0Q//vf/+Lphyc6thRr+qFSwa2KchMBERABERABDwKBVSo2NnbEiBF8KRUdHd2wYcMBAwZgTXnkolMREAEREAERCAWBwCN+w4cP7927d9asWQsXLjxy5Eh5n4fiMShPERABERABnwQCq9TUqVPHjBnz3XffMeKHRfXhhx8y4uczL0WKgAiIgAiIQHAJBFapHTt24OBnSm3cuDEStXfv3uBWQrmJgAiIgAiIgE8CgVXq4sWLmTNnNjezgh/fSF24cMFnXooUAREQAREQgeASCOw9QXn9+/fPkiWLKRjRGjJkSM6cOc0pM1XBrZBy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wiv76Vy586dJ0+eyCau1omACIiACIQbAbfeE6+88sqAAQPOnj0bbg1QfURABERABCKYgNt5qREjRmzZsgU/8pIlS6ZPn94SWbVqlQ0rIAIiIAIiIALBJeBWpeL62Da4tVFuIiACIiACIuAk4FalBg4c6LxNYREQAREQARFIAgJuVcpUhdVj169fjyd6pUqV2GIqCeqnIkRABERABFIzAbcqxce8bMv7008/4ZLOakZ84dSgQYNPP/00f/78qRmf2i4CIiACIhBSAm59/J599lm+Uvrrr7+OHj167NixtWvXctq1a9eQVk6Zi4AIiIAIpHICbm2pefPmff/992xjaHgx4jdu3Djn3lGpnKOaLwIiIAIiEAoCbm0p1u5zOqBTFU6dC/qFonLKUwREQAREIJUTcKtSt99+e7du3fbu3Wt4sVZsjx497rjjjlSOT80XAREQAREIKQG3KjV27NhTp07xSW+ZMmXKli1bqlQpTseMGRPSyilzERABERCBVE7A7bwU2+OyzAQbRG3YsAEfP+alGjZsmMrZqfkiIAIiIAKhJuBWpUw97rx6hLpOyl8EREAEREAEDIEAKjV69OgnnngiU6ZMBHwikzO6TyyKFAEREAERCAqBACo1atSotm3bolIEvMtjEQqplDcWxYiACIiACASLQACV2rZtmynJBoJVsPIRAREQAREQgYAE3Pr4OTOKiYn5448/WIHCGamwCIiACIiACASdgFuV6t69++TJkykeibrllluuv/56vP5Y1i/oFVKGIiACIiACImAJuFWpL774olq1atz29ddfb9++HX90dKtfv342IwVEQAREQAREIOgE3KrU4cOHCxUqRPFz5sx54IEHypcv36lTpzVr1gS9QspQBERABERABCwBtyrFXvLr1q1juI9lZ833vGfPno2KirIZKSACIiACIiACQScQwMfPltexY8cHH3ywcOHCeJ/zaS/xy5Ytq1Chgk2ggAiIgAiIgAgEnYBblXr55ZerVKmya9cuhvsyZsxIPTCkevfuHfQKKUMREAEREAERsATcqhQ33H///fY2Au3bt3eeKiwCIiACIiACQScQQKW0QlLQiStDERABERAB9wQCqJRWSHKPUilFQAREQASCTiCAStmFkWwg6DVQhiIgAiIgAiIQFwG3nuhx3a94ERABERABEQgdAbcqhevEa6+95qzHG2+8gb+fM0ZhERABERABEQguAbcqtXDhwmbNmjnLvuuuuxYtWuSMUVgEREAEREAEgkvArUqdPn06Q4YMzrLTp09/8uRJZ4zCIiACIiACIhBcAm5Vik96p0+f7iz7008/rVSpkjNGYREQAREQAREILoEAPn62sP79+993331btmy5/fbbifzhhx8++eSTzz//3CZQQAREQAREQASCTsCtSrVo0eLLL78cOnQoW3hkzpy5atWq33///a233hr0CilDERABERABEbAE3KoUN+A94eFAYXNRQAREQAREQARCQcDtvBRlHz9+/L333uvbt+/Ro0c5XbVq1Z49e0JRJ+UpAiIgAiIgAoaAW1vqzz//ZFupnDlzslFv586d8+TJM2vWrB07dnz44YdCKQIiIAIiIAIhIuDWlurZs2eHDh3+/vvvTJkymao0adJE30uF6KkoWxEQAREQAUPArUr99ttvTz75pJNa0aJF9+/f74xRWAREQAREQASCS8CtSmFCeXzDu3Hjxvz58we3NspNBERABERABJwE3KpUy5YtBw8eHB0dzc1sKr9z50426uULKmdeCouACIiACIhAcAm4Vak333zz0KFDBQoUOHfuHJ9JlS1bNnv27EOGDAlubZSbCIiACIiACDgJuPXxy5Ejx88//7xgwQIc0GNjY6+//npc/pwZKSwCIiACIiACQSfgSqUuXbrEvNQff/zB8khmhaSg10MZioAIiIAIiIA3AVcjfunSpStRokRMTIz3/YoRAREQAREQgdARcKVSFP/SSy/16dPHrDoRutooZxEQAREQARFwEnA14scNo0eP3rx5c5EiRTCqsmbNarNgmsqGFRABERABERCB4BJwq1J4ouOAHtyylZsIiIAIiIAI+CfgVqVefvll/xnpqgiIgAiIgAgEnUDgeamzZ8/++9//Zj0kPpZ6+OGHDx8+HPRKKEMREAEREAER8EkgsEoNHDhw6tSp7CzVpk2b+fPnP/XUUz4zUqQIiIAIiIAIBJ1A4BG/mTNnTp48GYmi7EceeaRevXq4pEdFRQW9KspQBERABERABDwIBLaldu3aVb9+fXPbjTfeyLdTe/fu9chFpyIgAiIgAiIQCgKB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0KpVq6DU+bfffnviiSf8ZOUhY61bt960aZOf9Fy67bbbDHDcTMqUKdOnT58LFy74vyWJrzK/iLtmlSpVglXuO++8U6JEiXr16jkzBCzuNp9++qkz8uWXXzZwuEQ1OnfujAOCM0GCwzNmzKhUqVLGjBn5d9asWXHl89lnn1WvXp3pVSr8xhtvOJONGzeuYsWKzDZde+21H374ob30wgsvvP/++3hJ2BgFRCBiCIRWpaZPn969e/d+/fr9/vvv9evXb9Kkyc6dO32y27hxI72SOfBH8pkmdUbmz58/Xv4gdGEFChQIyOrxxx+H9ubNm19//XX6PrrmgLe4ScCXaviwuEnpPw0KUahQIb718Z/M/dUxY8agN870fLHA77NXr16TJ092xhOuXLkycPitTpgw4euvv27Xrp1HggSc/vrrr7xAPProo6tXr+bfBx98cNmyZd75zJ07t23btl26dFm7di1veCNHjhw7dqxJRmV4n+BJ/fXXX4MGDfr3v/9N3cwlnnijRo0mTpzonaFiRCDFE8BdNXTHjTfeyN+bzb9ChQq9e/e2pybw448/AvHYsWMe8X5OT5w4wS3860xz7ty5devW8a8zMrnC7du3b9mypXNaaf8AABwUSURBVHfpGI433HADFgxd8IsvvhgdHW3SnDx58uGHH0aNiKdjuvXWW7t162Yu8UI9atQoEx44cCBv99zOFzDPPvsskaR0/gSJ4Z06Z86cJj3//ve//8WK5f09b96899xzj4l35k/Mvffee/3115tLaMzw4cON+Vu1atXPP//cxPMvWTFohlmMKca4on1qpkR6TF7zUZetW7dimdH780kALeI3wCM2mTCOd/fddzMgSTz2xDfffEP80aNHaXu+fPnImfynTJlCpDELeLkxN8bFjYbAgbJy585dsGBB+Jj0Hv+uXLkSJwKPHwxNuOmmm44fP46uU5y9hUyqVatmT1999VXuRdJsTMICyNJdd91l723cuHGbNm3sqQ089NBD999/vz3l0V9zzTU8FGLq1KnDyJ69xC8E09Ce0hx+G/bUBsLq78LWSoHIIPDXnhMlXpx9w6vzE9Mcn/25M8MQ2lLMBNA78Ipnu1HCS5YssafOQI0aNeh577jjDiNazksm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NsEAEEU7akCIgCBNPzP40ejUxEQAf8EsB5YzofhKWwj/yl11T0BnBVRXzTPzLS5v1EpI5uA5qUi+/mqdSEhgNM2sziMazk/ZgpJSakpU3wvMcgkUanpmbtqq2wpV5iUSAREQAREIFkIaLwiWbCrUBEQAREQAVcEpFKuMCmRCIiACIhAshCQSiULdhUqAiIgAiLgioBUyhUmJRIBERABEUgWAlKpZMGuQkVABERABFwRkEq5wqREIiACIiACyUJAKpUs2FWoCIiACIiAKwJSKVeYlEgEREAERCBZCEilkgW7ChUBERABEXBF4P8AuRwuVEedncgAAAAASUVORK5CYII=" 57 | } 58 | }, 59 | "cell_type": "markdown", 60 | "id": "e1486424", 61 | "metadata": {}, 62 | "source": [ 63 | "![image.png](attachment:image.png)" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": null, 69 | "id": "668856bf", 70 | "metadata": {}, 71 | "outputs": [], 72 | "source": [] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": null, 77 | "id": "c87326bd", 78 | "metadata": {}, 79 | "outputs": [], 80 | "source": [] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": null, 85 | "id": "decdbf09", 86 | "metadata": {}, 87 | "outputs": [], 88 | "source": [] 89 | } 90 | ], 91 | "metadata": { 92 | "kernelspec": { 93 | "display_name": "Python 3 (ipykernel)", 94 | "language": "python", 95 | "name": "python3" 96 | }, 97 | "language_info": { 98 | "codemirror_mode": { 99 | "name": "ipython", 100 | "version": 3 101 | }, 102 | "file_extension": ".py", 103 | "mimetype": "text/x-python", 104 | "name": "python", 105 | "nbconvert_exporter": "python", 106 | "pygments_lexer": "ipython3", 107 | "version": "3.8.15" 108 | } 109 | }, 110 | "nbformat": 4, 111 | "nbformat_minor": 5 112 | } 113 | --------------------------------------------------------------------------------