Skip to content

Commit c088b20

Browse files
committed
0.2.5
Fix model loading
1 parent 5a74261 commit c088b20

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

README.md

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
# A simple FastAPI Server to run XTTSv2
1+
# A simple FastAPI Server to run XTTSv2
22

33
The project is inspired by [silero-api-server](https://github.com/ouoertheo/silero-api-server)
44
repo uses [XTTSv2](https://github.com/coqui-ai/TTS)
55

6-
TODO: This is will be to serve the TTS extension in [SillyTavern](https://github.com/Cohee1207/SillyTavern) soon. The TTS module or server can be used any way you wish.
7-
UPD: There's already a result
6+
Created a PR for SillyTavern: [here](https://github.com/SillyTavern/SillyTavern/pull/1383)
7+
8+
The TTS module or server can be used any way you wish.
89

910
## Installation
11+
1012
`pip install xtts-api-server`
1113

12-
I strongly recommend installing pytorch with CUDA so that the entire process is on the video card
14+
I strongly recommend installing pytorch with CUDA so that the entire process is on the video card
1315

1416
`pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118`
1517

1618
## Starting Server
17-
`python -m xtts-api-server` will run on default ip and port (localhost:8020)
19+
20+
`python -m xtts-api-server` will run on default ip and port (0.0.0.0:8020)
1821

1922
```
2023
usage: xtts-api-server [-h] [-o HOST] [-p PORT] [-sf SPEAKER_FOLDER] [-o OUTPUT]
@@ -33,13 +36,17 @@ The first time you run or generate, you may need to confirm that you agree to us
3336
The model will be loaded into memory after the first generation.
3437

3538
# API Docs
39+
3640
API Docs can be accessed from [http://localhost:8020/docs](http://localhost:8020/docs)
3741

3842
# Voice Samples
43+
3944
You can find the sample in this repository, also by default samples will be saved to `/output/output.wav` or you can change this, more details in the API documentation
4045

4146
# Selecting Folder
47+
4248
You can change the folders for speakers and the folder for output via the API.
4349

4450
# Get Speakers
51+
4552
Once you have at least one file in your speakers folder, you can get its name via API and then you only need to specify the file name.

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "xtts-api-server"
7-
version = "0.2"
7+
version = "0.2.5"
88
authors = [
99
{ name="daswer123", email="daswerq123@gmail.com" },
1010
]

xtts_api_server/server.py

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
app = FastAPI()
2424
XTTS = TTSWrapper(OUTPUT_FOLDER,SPEAKER_FOLDER)
2525

26+
# Load model
27+
logger.info("The model starts to load, wait about a minute")
28+
XTTS.load_model()
29+
2630
# Add CORS middleware
2731
origins = ["*"]
2832
app.add_middleware(

xtts_api_server/tts_funcs.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def __init__(self,output_folder = "./output", speaker_folder="./speakers"):
3535
self.output_folder = output_folder
3636

3737
self.create_directories()
38+
# self.load_model()
3839

3940
def load_model(self):
4041
self.model = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(self.device)
@@ -101,9 +102,6 @@ def list_languages(self):
101102

102103
def process_tts_to_file(self, text, speaker_name_or_path, language, file_name_or_path="out.wav"):
103104
try:
104-
# Load the model if it's not already loaded
105-
if not hasattr(self, "model"):
106-
self.load_model()
107105
# Check if the speaker path is a .wav file or just the name
108106
if speaker_name_or_path.endswith('.wav'):
109107
if os.path.isabs(speaker_name_or_path):

0 commit comments

Comments
 (0)