{"id":19900364,"url":"https://github.com/x-lance/unicats-ctx-vec2wav","last_synced_at":"2026-03-04T13:32:06.702Z","repository":{"id":189585320,"uuid":"680918884","full_name":"X-LANCE/UniCATS-CTX-vec2wav","owner":"X-LANCE","description":"[AAAI 2024] Code for CTX-vec2wav in UniCATS","archived":false,"fork":false,"pushed_at":"2024-06-11T15:36:24.000Z","size":1026,"stargazers_count":129,"open_issues_count":7,"forks_count":16,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-08-14T20:45:47.059Z","etag":null,"topics":["self-supervised-speech","semantic-token","speech-synthesis","unicats","vocoder","vocoding"],"latest_commit_sha":null,"homepage":"https://cpdu.github.io/unicats/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/X-LANCE.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-20T20:27:46.000Z","updated_at":"2025-06-11T17:11:28.000Z","dependencies_parsed_at":"2023-08-20T21:38:33.113Z","dependency_job_id":"5c2cfa5b-1be6-4abe-9b4f-30e2d674607d","html_url":"https://github.com/X-LANCE/UniCATS-CTX-vec2wav","commit_stats":null,"previous_names":["cantabile-kwok/ctx-vec2wav","cantabile-kwok/unicats-ctx-vec2wav","x-lance/unicats-ctx-vec2wav"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/X-LANCE/UniCATS-CTX-vec2wav","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/X-LANCE%2FUniCATS-CTX-vec2wav","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/X-LANCE%2FUniCATS-CTX-vec2wav/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/X-LANCE%2FUniCATS-CTX-vec2wav/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/X-LANCE%2FUniCATS-CTX-vec2wav/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/X-LANCE","download_url":"https://codeload.github.com/X-LANCE/UniCATS-CTX-vec2wav/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/X-LANCE%2FUniCATS-CTX-vec2wav/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30081428,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T13:22:36.021Z","status":"ssl_error","status_checked_at":"2026-03-04T13:20:45.750Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["self-supervised-speech","semantic-token","speech-synthesis","unicats","vocoder","vocoding"],"created_at":"2024-11-12T20:12:03.881Z","updated_at":"2026-03-04T13:32:06.665Z","avatar_url":"https://github.com/X-LANCE.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CTX-vec2wav, the Acoustic Context-Aware Vocoder\n\n\u003e This is the official implementation of **CTX-vec2wav** vocoder in the AAAI-2024 paper [UniCATS: A Unified Context-Aware Text-to-Speech Framework with Contextual VQ-Diffusion and Vocoding](https://arxiv.org/abs/2306.07547).\n\n\u003cimg width=\"1187\" alt=\"image-20230926140022539\" src=asset/main.png\u003e\n\nSee also: [The official implementation of CTX-txt2vec](https://github.com/X-LANCE/UniCATS-CTX-txt2vec), the acoustic model with contextual VQ-diffusion, proposed in the paper.\n## Environment Setup\n\nThis repo is tested on **python 3.9** on Linux. You can set up the environment with conda\n```shell\n# Install required packages\nconda create -n ctxv2w python=3.9  # or any name you like\nconda activate ctxv2w\npip install -r requirements.txt\n\n# Then, set PATH and PYTHONPATH\nsource path.sh  # change the env name if you don't use \"ctxv2w\"\n```\nThe scripts in `utils/` should be executable. You can run `chmod +x utils/*` to ensure this.\n\nThe following process will also need `bash` and `perl` commands in your Linux environment.\n\n\n## Inference (Vocoding with acoustic context)\nFor utterances that are already registered in `data/`, the inference (VQ index + acoustic prompt) can be done by\n```shell\nbash run.sh --stage 3 --stop_stage 3\n# You can specify the dataset to be constructed by \"--eval_set $which_set\", i.e. \"--eval_set dev_all\"\n```\nYou can also create a subset can perform inference on it by\n```shell\nsubset_data_dir.sh data/eval_all 200 data/eval_subset  # randomly select 200 utts from data/eval_all\nbash run.sh --stage 3 --stop_stage 3 --eval_set \"eval_subset\"\n```\nThe program loads the latest checkpoint in the experiment dir `exp/train_all_ctxv2w.v1/*pkl`.\n\n\n💡Note: the stage 3 in `run.sh` automatically selects the prompt for each utterance by random (see `local/build_prompt_feat.py`).\nYou can customize this process and perform inference yourself:\n1. Prepare a `feats.scp` that specifies each utterance (for inference) with its VQ index sequence in `(L, 2)` shape.\n2. Run `feat-to-len.py scp:/path/to/feats.scp \u003e /path/to/utt2num_frames`.\n3. Prepare a `prompt.scp` that specifies each utterance with its acoustic (mel) prompt in `(L', 80)` shape.\n4. Run inference via\n    ```shell\n    # might change sampling rate.\n    decode.py \\\n        --sampling-rate 16000 \\\n        --feats-scp /path/to/feats.scp \\\n        --prompt-scp /path/to/prompt.scp \\\n        --num-frames /path/to/utt2num_frames \\\n        --config /path/to/config.yaml \\\n        --vq-codebook /path/to/codebook.npy \\\n        --checkpoint /path/to/checkpoint \\\n        --outdir /path/to/output/wav\n    ```\n\n## Training\n\nFirst, you need to properly construct `data` and `feats` directory. Please check out [data_prep](data_prep.md) for details.\n\u003e 💡Note: here we provide the 16kHz version of model and data. Meanwhile, the original paper uses 24kHz data, which was accomplished by using the features extracted in 16kHz and increasing the `upsample_scales` in the config yaml.\n\n\nThen, training on LibriTTS (all training partitions) can be done by\n```shell\nbash run.sh --stage 2 --stop_stage 2 \n# You can provide different config file by --conf $your_config\n# Checkout run.sh for all the parameters. You can specify every bash variable there as \"--key value\" in CLI. \n```\nThis will create `exp/train_all_ctxv2w.v1` for logging. The script **automatically handles multi-GPU training** if you specify the $CUDA_VISIBLE_DEVICES env variable.\n\n## Pre-trained model parameters\nWe release two versions of model parameters (generator) on LibriTTS train-all set. These refer to two sampling rates of the target waveforms. \nNote that the acoustic features (fbank+ppe) are all extracted from 16k waveform. The only difference is the upsample rate in the HifiGAN generator.\n* 16k: [link](https://huggingface.co/cantabile-kwok/ctx_vec2wav_libritts_all/resolve/main/ctx_v2w.pkl?download=true)\n* 24k: [link](https://huggingface.co/cantabile-kwok/ctx_vec2wav_libritts_all/resolve/main/ctx_v2w_24k.pkl?download=true) with the corresponding config file `conf/ctxv2w.24k.yaml`.\n\nThe usage is the same as the \"Inference\" section. Feel free to use these checkpoints for vocoding!\n\n**CMVN file**: in order to perform inference on out-of-set utterances, we provide the `cmvn.ark` file [here](https://huggingface.co/cantabile-kwok/ctx_vec2wav_libritts_all/resolve/main/cmvn.ark). You should extract mel-spectrogram, normalize by that file (computed on LibriTTS), and then feed the model.\n\n## Acknowledgement\nDuring the development, the following repositories were referred to:\n* [ESPnet](https://github.com/espnet/espnet), for most network modules in `ctx_vec2wav/models/conformer`.\n* [Kaldi](https://github.com/kaldi-asr/kaldi), for most utility scripts in `utils/`.\n* [ParallelWaveGAN](https://github.com/kan-bayashi/ParallelWaveGAN), whose training and decoding pipeline is adopted.  \n\n## Citation\n```\n@article{du2023unicats,\n  title={UniCATS: A Unified Context-Aware Text-to-Speech Framework with Contextual VQ-Diffusion and Vocoding},\n  author={Du, Chenpeng and Guo, Yiwei and Shen, Feiyu and Liu, Zhijun and Liang, Zheng and Chen, Xie and Wang, Shuai and Zhang, Hui and Yu, Kai},\n  journal={arXiv preprint arXiv:2306.07547},\n  year={2023}\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fx-lance%2Funicats-ctx-vec2wav","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fx-lance%2Funicats-ctx-vec2wav","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fx-lance%2Funicats-ctx-vec2wav/lists"}