Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-download models from HF #26

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Next-generation TTS model using flow-matching and DiT, inspired by [Stable Diffu

As the first open-source TTS model that tried to combine flow-matching and DiT, **StableTTS** is a fast and lightweight TTS model for chinese, english and japanese speech generation. It has 31M parameters.

✨ **Huggingface demo:** [🤗](https://huggingface.co/spaces/KdaiP/StableTTS1.1)
✨ **Hugging Face demo:** [🤗](https://huggingface.co/spaces/KdaiP/StableTTS1.1)

## News

Expand All @@ -36,7 +36,7 @@ As the first open-source TTS model that tried to combine flow-matching and DiT,

### Text-To-Mel model

Download and place the model in the `./checkpoints` directory, it is ready for inference, finetuning and webui.
By default, the inference scripts will automatically download the pretrained models from Hugging Face. For training, download the models and place them in the `checkpoints` directory.

| Model Name | Task Details | Dataset | Download Link |
|:----------:|:------------:|:-------------:|:-------------:|
Expand Down
6 changes: 4 additions & 2 deletions api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from datas.dataset import intersperse
from utils.audio import load_and_resample_audio

from cached_path import cached_path

def get_vocoder(model_path, model_name='ffgan') -> nn.Module:
if model_name == 'ffgan':
# training or changing ffgan config is not supported in this repo
Expand Down Expand Up @@ -83,8 +85,8 @@ def get_params(self):

if __name__ == '__main__':
device = 'cuda' if torch.cuda.is_available() else 'cpu'
tts_model_path = './checkpoints/checkpoint_0.pt'
vocoder_model_path = './vocoders/pretrained/vocos.pt'
tts_model_path = str(cached_path('hf://KdaiP/StableTTS1.1/StableTTS/checkpoint_0.pt'))
vocoder_model_path = str(cached_path('hf://KdaiP/StableTTS1.1/vocoders/vocos.pt'))

model = StableTTSAPI(tts_model_path, vocoder_model_path, 'vocos')
model.to(device)
Expand Down
5 changes: 3 additions & 2 deletions inference.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
"import torch\n",
"\n",
"from api import StableTTSAPI\n",
"from cached_path import cached_path\n",
"\n",
"device = 'cuda' if torch.cuda.is_available() else 'cpu'\n",
"\n",
"tts_model_path = './checkpoints/checkpoint_0.pt' # path to StableTTS checkpoint\n",
"vocoder_model_path = './vocoders/pretrained/firefly-gan-base-generator.ckpt' # path to vocoder checkpoint\n",
"tts_model_path = str(cached_path('hf://KdaiP/StableTTS1.1/StableTTS/checkpoint_0.pt')) # or path to StableTTS checkpoint\n",
"vocoder_model_path = str(cached_path('hf://KdaiP/StableTTS1.1/vocoders/firefly-gan-base-generator.ckpt')) # or path to vocoder checkpoint\n",
"vocoder_type = 'ffgan' # ffgan or vocos\n",
"\n",
"# vocoder_model_path = './vocoders/pretrained/vocos.pt'\n",
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ soundfile # to make sure that torchaudio has at least one valid backend

tensorboard

cached_path

# for monotonic_align
numba

Expand Down
6 changes: 4 additions & 2 deletions webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@

from api import StableTTSAPI

from cached_path import cached_path

device = 'cuda' if torch.cuda.is_available() else 'cpu'

tts_model_path = './checkpoints/checkpoint_0.pt'
vocoder_model_path = './vocoders/pretrained/firefly-gan-base-generator.ckpt'
tts_model_path = str(cached_path('hf://KdaiP/StableTTS1.1/StableTTS/checkpoint_0.pt'))
vocoder_model_path = str(cached_path('hf://KdaiP/StableTTS1.1/vocoders/firefly-gan-base-generator.ckpt'))
vocoder_type = 'ffgan'

model = StableTTSAPI(tts_model_path, vocoder_model_path, vocoder_type).to(device)
Expand Down