GPT-SoVITS-FastInference
A streamlined Python wrapper for fast inference with GPT-SoVITS, based on the fast_inference_ branch of the original GPT-SoVITS project, with significant contributions from ChasonJiang.
This fork is designed solely for inference purposes and does not include the full features present in the original GPT-SoVITS project.
Introduction
GPT-SoVITS-FastInference offers a simplified wrapper for utilizing the powerful few-shot voice conversion and text-to-speech capabilities of GPT-SoVITS. It's ideal for scenarios where quick and efficient inference is required without the need for a graphical interface.
Features
- Efficient Inference: Benefit from fast inference capabilities optimized for quick processing.
- Python Wrapper: Intuitive Python interface for seamless integration into your projects.
Getting Started
Installation
To install GPT-SoVITS-FastInference, simply follow the setup instructions below:
- Install Anaconda or Miniconda, create and active an environment, then run the following commands:
conda install cmake -y
conda install -c conda-forge gcc -y
conda install -c conda-forge gxx -y
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia -y
conda install ffmpeg -y
pip install gpt_sovits_python[all]
Usage
Initialize the configuration and specify the path of the pretrained models
from gpt_sovits import TTS, TTS_Config
soviets_configs = {
"default": {
"device": "cuda", # ["cpu", "cuda"]
"is_half": True, # Set 'False' if you will use cpu
"t2s_weights_path": "pretrained_models/s1bert25hz-2kh-longer-epoch=68e-step=50232.ckpt",
"vits_weights_path": "pretrained_models/s2G488k.pth",
"cnhuhbert_base_path": "pretrained_models/chinese-hubert-base",
"bert_base_path": "pretrained_models/chinese-roberta-wwm-ext-large"
}
}
tts_config = TTS_Config(soviets_configs)
Load the models
tts_pipeline = TTS(tts_config)
Configure the parameters you need
params = {
"text": "", # str.(required) text to be synthesized
"text_lang": "en", # str.(required) language of the text to be synthesized [, "en", "zh", "ja", "all_zh", "all_ja"]
"ref_audio_path": "", # str.(required) reference audio path
"prompt_text": "", # str.(optional) prompt text for the reference audio
"prompt_lang": "", # str.(required) language of the prompt text for the reference audio
"top_k": 5, # int. top k sampling
"top_p": 1, # float. top p sampling
"temperature": 1, # float. temperature for sampling
"text_split_method": "cut5", # str. text split method, see gpt_sovits_python\TTS_infer_pack\text_segmentation_method.py for details.
"batch_size": 1, # int. batch size for inference
"batch_threshold": 0.75, # float. threshold for batch splitting.
"split_bucket": True, # bool. whether to split the batch into multiple buckets.
"speed_factor": 1.0, # float. control the speed of the synthesized audio.
"fragment_interval": 0.3, # float. to control the interval of the audio fragment.
"seed": -1, # int. random seed for reproducibility.
"media_type": "wav", # str. media type of the output audio, support "wav", "raw", "ogg", "aac".
"streaming_mode": False, # bool. whether to return a streaming response.
"parallel_infer": True, # bool.(optional) whether to use parallel inference.
"repetition_penalty": 1.35 # float.(optional) repetition penalty for T2S model.
}
Perform inference
tts_generator = tts_pipeline.run(params)
sr, audio_data = next(tts_generator)
The output is a NumPy array, and you can save or play with it in a notebook.
Save
import scipy
scipy.io.wavfile.write("out_from_text.wav", rate=sr, data=audio_data)
License
This project is licensed under the MIT License, same as the original GPT-SoVITS project.
Disclaimer
This software is provided for educational and research purposes only. The authors and contributors of this project do not endorse or encourage any misuse or unethical use of this software. Any use of this software for purposes other than those intended is solely at the user's own risk. The authors and contributors shall not be held responsible for any damages or liabilities arising from the use of this software inappropriately.
Acknowledgments
Original GPT-SoVITS project contributors ChasonJiang for significant code contributions
Metadata
Release files for gpt-sovits-python 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gpt_sovits_python-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for gpt_sovits_python-1.0.0-py3-none-any.whl |
Release files / gpt_sovits_python-1.0.0-py3-none-any.whl
| Download URL | gpt_sovits_python-1.0.0-py3-none-any.whl |
|---|---|
| Size | 3.3 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
314959ebcb9d801d7fd193ba173d25727c474c4e575b78e1ed2040afed72ff02
|
|
BLAKE2b-256 checksum How to use checksums |
59779ab71745f7ba81ff38b87bd1e3960a2fb40eaa4bc9f6d503a8ebf1163593
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.13
|
Security for gpt-sovits-python 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.