Skip to content
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
98845ca
* Added route to upload sample into speakers folder, so you can uploa…
Jun 11, 2024
9f783f6
Merge pull request #1 from daswer123/main
abeiro Sep 2, 2024
1e7a025
* Added XTTSv2_AIFF.ipynb
abeiro Sep 12, 2024
47d3568
Merge branch 'main' of https://github.com/abeiro/xtts-api-server
abeiro Sep 12, 2024
571c4f2
* Added default Narrator voice
abeiro Nov 26, 2024
f10207f
* Fixed versions to avoid future breakages
abeiro Jan 8, 2025
5e310e0
* Added ddistro files
May 6, 2025
65dfd1c
word changs for install
RANGROO May 10, 2025
f720b33
CHIM XTTS install conf.sh
RANGROO May 10, 2025
0e9f827
standarized conf.sh
RANGROO May 10, 2025
e7faea6
fix typo
RANGROO May 10, 2025
c9e67cf
Update ddistro_install.sh
abeiro May 13, 2025
f1e8c39
Update ddistro_install.sh
abeiro May 13, 2025
c388e1d
Added CUDA 12.8 to PATH if exists
abeiro May 16, 2025
38f8dfa
tourchcodec added
RANGROO Aug 23, 2025
2570806
pytorch download changes
RANGROO Aug 23, 2025
dd9c688
path fixes
RANGROO Aug 23, 2025
19a1f69
Update ddistro_install.sh
abeiro Aug 27, 2025
c5de028
update instructions for xtts install
RANGROO Aug 31, 2025
1d412ea
typo fix
RANGROO Aug 31, 2025
5c1a35f
Specify PyTorch and related package versions (2.7.0)
abeiro Oct 16, 2025
241dd37
Enhance CUDA installation process in ddistro_install.sh
abeiro Oct 17, 2025
ae57177
Create requirements5.txt with project dependencies
abeiro Oct 17, 2025
bf46de0
Add LD_LIBRARY_PATH for DeepSpeed execution
abeiro Oct 17, 2025
f51038b
Add LD_LIBRARY_PATH for NVIDIA libraries
abeiro Oct 17, 2025
0218c48
Set LD_LIBRARY_PATH for Python TTS
abeiro Oct 17, 2025
b8a1ca0
Chnaged deepspeed version to 0.18.1
abeiro Oct 27, 2025
05b5812
Add conditional CUDA path setup in start-deepspeed.sh
abeiro Oct 28, 2025
5cf3f7e
Add NVIDIA CUDA 13 DEV packages to requirements
abeiro Oct 28, 2025
33efb27
Enhance ddistro_install.sh for CUDA setup
abeiro Oct 28, 2025
8164e94
Clean previous deepspeed cache before installation
abeiro Oct 28, 2025
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
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
dist
venv
speakers
output
test
models
xtts_api_server/models
*.pyc
xtts_api_server/RealtimeTTS/engines/coqui_engine_old.py
xtts_models
modules-xtts.txt
modules-xtts.txt
116 changes: 116 additions & 0 deletions XTTSv2_AIFF.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"gpuType": "T4"
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "markdown",
"source": [
"**Run next block, restart session when asked and run same block until everything installs.**\n",
"\n",
"Last message should be like this (yes, ignore ERROR)\n",
"\n",
"\n",
"```\n",
"ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n",
"torchvision 0.19.0+cu121 requires torch==2.4.0, but you have torch 2.1.1+cu121 which is incompatible\n",
"Successfully installed torch-2.1.1+cu121 torchaudio-2.1.1+cu121 triton-2.1.0\n",
"\n",
"```\n",
"\n"
],
"metadata": {
"id": "FmMMJppi2-Gh"
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "lT4ieCTnr_L7"
},
"outputs": [],
"source": [
"!apt-get update && apt-get install --no-install-recommends -y sox libsox-fmt-all curl wget gcc git git-lfs build-essential libaio-dev libsndfile1 ssh ffmpeg sshpass portaudio19-dev libportaudio2\n",
"!git clone https://github.com/abeiro/xtts-api-server\n",
"%cd xtts-api-server\n",
"!python3 -m pip install --upgrade pip wheel ninja virtualenv\n",
"!pip install setuptools==68.1.2\n",
"!pip install deepspeed\n",
"!pip install -r requirements.txt\n",
"!pip install torch==2.1.1+cu121 torchaudio==2.1.1+cu121 --index-url https://download.pytorch.org/whl/cu121"
]
},
{
"cell_type": "markdown",
"source": [
"**Run this once to get model downloaded and deepspeed compiled. Once uvicorn starts, stop and proceed to next block**\n",
"\n",
"\n",
"\n"
],
"metadata": {
"id": "u1Ir_s5U3ZcT"
}
},
{
"cell_type": "code",
"source": [
"!python3 -m xtts_api_server --listen --deepspeed"
],
"metadata": {
"id": "Xs5dXNL43VFB"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"**Run and note cloudflare address. Wait for message:**\n",
"\n",
"```\n",
"INFO: Uvicorn running on http://0.0.0.0:8020 (Press CTRL+C to quit)\n",
"\n",
"```\n",
"\n",
"Use http://generated-domain-name:80 in AI-FF conf.\n",
"\n"
],
"metadata": {
"id": "xOowr61z3nT2"
}
},
{
"cell_type": "code",
"source": [
"#Run\n",
"!rm nohup.out\n",
"!wget -c https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -O cloudflared-linux-amd64\n",
"!chmod +x cloudflared-linux-amd64\n",
"!nohup ./cloudflared-linux-amd64 tunnel --url http://localhost:8020 &\n",
"!sleep 8\n",
"!cat nohup.out\n",
"!python3 -m xtts_api_server --listen --deepspeed"
],
"metadata": {
"id": "xuLmVnEW2PYM"
},
"execution_count": null,
"outputs": []
}
]
}
65 changes: 65 additions & 0 deletions conf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash
clear
cat << EOF
CHIM XTTS

This will install CHIM XTTS. This is a high quality TTS service that works with Skyrim voices.
You can also generate your own voices.
However it will require around 4GB of VRAM!

Options:
* deepseed = Uses more VRAM but faster
* lowvram = Uses less VRAM but slower
* regular = Middle ground of both options above

If you are not sure use lowvram.

EOF

if [ ! -d /home/dwemer/python-tts ]; then
exit "XTTSv2 not installed"
fi
Comment on lines +19 to +21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix invalid use of exit with a string.
exit only accepts numeric status codes. Use echo to print the message and then exit 1.

- if [ ! -d /home/dwemer/python-tts ]; then
-     exit "XTTSv2 not installed"
+ if [ ! -d /home/dwemer/python-tts ]; then
+     echo "Error: XTTSv2 not installed" >&2
+     exit 1
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ ! -d /home/dwemer/python-tts ]; then
exit "XTTSv2 not installed"
fi
if [ ! -d /home/dwemer/python-tts ]; then
echo "Error: XTTSv2 not installed" >&2
exit 1
fi
🧰 Tools
🪛 Shellcheck (0.10.0)

[error] 21-21: Can only exit with status 0-255. Other data should be written to stdout/stderr.

(SC2242)


mapfile -t files < <(find /home/dwemer/xtts-api-server/ -name "start-*.sh")
# Check if any files were found

if [ ${#files[@]} -eq 0 ]; then
echo "No files found matching the pattern."
exit 1
fi

# Display the files in a numbered list
echo -e "Select a an option from the list:\n\n"
for i in "${!files[@]}"; do
echo "$((i+1)). ${files[$i]}"
done

echo "0. Disable service";
echo

Comment on lines +31 to +39
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix typos in user-facing text (“deepseed” → “deepspeed”; “Select a an” → “Select an”).

User-visible messages should be correct and professional.

-echo -e "Select a an option from the list:\n\n"
+echo -e "Select an option from the list:\n\n"
@@
-* deepseed = Uses more VRAM but faster
+* deepspeed = Uses more VRAM but faster
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Display the files in a numbered list
echo -e "Select a an option from the list:\n\n"
for i in "${!files[@]}"; do
echo "$((i+1)). ${files[$i]}"
done
echo "0. Disable service";
echo
# Display the files in a numbered list
echo -e "Select an option from the list:\n\n"
for i in "${!files[@]}"; do
echo "$((i+1)). ${files[$i]}"
done
echo "0. Disable service";
echo
🤖 Prompt for AI Agents
In conf.sh around lines 31 to 39, fix typos in user-facing strings: change
"Select a an option from the list:" to "Select an option from the list:" and
replace any occurrences of "deepseed" with the correct "deepspeed" in the file
so all displayed messages are spelled correctly and professional.

# Prompt the user to make a selection
read -p "Select an option by picking the matching number: " selection

# Validate the input

if [ "$selection" -eq "0" ]; then
echo "Disabling service. Run this again to enable"
rm /home/dwemer/xtts-api-server/start.sh &>/dev/null
exit 0
fi

if ! [[ "$selection" =~ ^[0-9]+$ ]] || [ "$selection" -lt 1 ] || [ "$selection" -gt ${#files[@]} ]; then
echo "Invalid selection."
exit 1
fi
Comment on lines +45 to +54
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Reorder input validation to prevent comparison errors
Using -eq on a non-numeric string will cause a runtime error. Check for numeric input first or use string comparison for the zero case. For example:

- if [ "$selection" -eq "0" ]; then
+ # Check for zero before numeric comparison
+ if [ "$selection" = "0" ]; then
     echo "Disabling service. Run this again to enable"
     rm /home/dwemer/xtts-api-server/start.sh &>/dev/null
     exit 0
  fi

- if ! [[ "$selection" =~ ^[0-9]+$ ]] || [ "$selection" -lt 1 ] || [ "$selection" -gt ${#files[@]} ]; then
+ if ! [[ "$selection" =~ ^[0-9]+$ ]] || [ "$selection" -lt 1 ] || [ "$selection" -gt ${#files[@]} ]; then
     echo "Invalid selection."
     exit 1
  fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ "$selection" -eq "0" ]; then
echo "Disabling service. Run this again to enable"
rm /home/dwemer/xtts-api-server/start.sh &>/dev/null
exit 0
fi
if ! [[ "$selection" =~ ^[0-9]+$ ]] || [ "$selection" -lt 1 ] || [ "$selection" -gt ${#files[@]} ]; then
echo "Invalid selection."
exit 1
fi
# Check for zero before numeric comparison
if [ "$selection" = "0" ]; then
echo "Disabling service. Run this again to enable"
rm /home/dwemer/xtts-api-server/start.sh &>/dev/null
exit 0
fi
if ! [[ "$selection" =~ ^[0-9]+$ ]] || [ "$selection" -lt 1 ] || [ "$selection" -gt ${#files[@]} ]; then
echo "Invalid selection."
exit 1
fi


# Get the selected file
selected_file="${files[$((selection-1))]}"

echo "You selected: $selected_file"

ln -sf $selected_file /home/dwemer/xtts-api-server/start.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Quote path variables in ln -sf
Always quote expansions to handle paths containing spaces or special characters:

- ln -sf $selected_file /home/dwemer/xtts-api-server/start.sh
+ ln -sf "$selected_file" "/home/dwemer/xtts-api-server/start.sh"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ln -sf $selected_file /home/dwemer/xtts-api-server/start.sh
ln -sf "$selected_file" "/home/dwemer/xtts-api-server/start.sh"





54 changes: 54 additions & 0 deletions ddistro_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

cd /home/dwemer/xtts-api-server
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Ensure cd command is checked.
If the directory change fails, the rest of the script will run in the wrong context. Wrap it with an exit on failure:

- cd /home/dwemer/xtts-api-server
+ cd /home/dwemer/xtts-api-server || { echo "Error: cannot cd to xtts-api-server"; exit 1; }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cd /home/dwemer/xtts-api-server
cd /home/dwemer/xtts-api-server || { echo "Error: cannot cd to xtts-api-server"; exit 1; }
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 2-2: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

(SC2164)

Comment on lines +2 to +3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add shebang and strict error handling.
There is no shebang at the top, and failures won't be caught. Prepend these lines:

+ #!/bin/bash
+ set -euo pipefail
🧰 Tools
🪛 Shellcheck (0.10.0)

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

(SC2148)


[warning] 2-2: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

(SC2164)

python3 -m venv /home/dwemer/python-tts
source /home/dwemer/python-tts/bin/activate
Comment on lines +3 to +5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Parameterize paths to improve reusability.

Hard-coding /home/dwemer and the venv path makes the script user- and environment-specific. Consider:

BASE_DIR="${BASE_DIR:-$HOME/xtts-api-server}"
VENV_DIR="${VENV_DIR:-$HOME/python-tts}"

cd "$BASE_DIR" || exit 1
python3 -m venv "$VENV_DIR"
source "$VENV_DIR/bin/activate"

This allows users to override paths without editing the script.

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 2-2: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

(SC2164)


echo "This will take a while so please wait."

# Ask user about GPU
read -p "Are you using a GT10XX series GPU? (yes/no): " gpu_answer
if [[ "$gpu_answer" =~ ^[Yy][Ee][Ss]$ || "$gpu_answer" =~ ^[Yy]$ ]]; then
cu_tag="cu118"
torch_url="https://download.pytorch.org/whl/${cu_tag}"
torch_ver="2.2.2"
torchaudio_ver="2.2.2"
else
cu_tag="cu124"
torch_url="https://download.pytorch.org/whl/${cu_tag}"
torch_ver="2.4.0"
torchaudio_ver="2.4.0"
fi

python3 -m pip install --upgrade pip wheel ninja virtualenv
pip install setuptools==68.1.2
# Install app requirements without auto-pulling torch/torchaudio from deps
pip install --no-deps -r requirements.txt
# Pin to stable, CUDA-tagged PyTorch/Torchaudio that do not require TorchCodec
pip cache purge || true
pip uninstall -y torch torchaudio torchcodec torchvision || true
pip install --no-deps --no-cache-dir --index-url "$torch_url" "torch==${torch_ver}+${cu_tag}" "torchaudio==${torchaudio_ver}+${cu_tag}"
pip check || true
# Ensure fallback audio loader is available
pip install --no-cache-dir soundfile
#pip install xtts-api-server #Fails

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify xtts_api_server is importable before trying to run it.

requirements.txt install doesn’t show how xtts_api_server is provided (editable install, local package, etc.). Ensure it exists to avoid runtime failure.

Run this script to check for the module/package presence in the repo and potential entry-points:

Also applies to: 52-52


🏁 Script executed:

#!/bin/bash
# Search for a Python package/module named xtts_api_server
rg -nP -C2 '\bxtts_api_server\b' --type py

# Look for a setup.cfg/pyproject with "xtts_api_server" or console_scripts entrypoints
fd -H 'pyproject.toml' -x rg -nP -C2 'xtts_api_server|console_scripts'
fd -H 'setup.cfg' -x rg -nP -C2 'xtts_api_server|console_scripts'

Length of output: 1773


Ensure the xtts_api_server package is installed and importable before invoking it
It looks like you have a local xtts_api_server/ module (so xtts_api_server is importable in the repo), but there’s no editable or regular install step in ddistro_install.sh, nor is there a console‐script entrypoint defined in your packaging. Without installing the package (or defining a CLI entrypoint), attempts to run xtts-api-server will fail.

• ddistro_install.sh (lines 34–35): replace the commented-out pip install line with a local install, for example:

pip install -e .      # installs the local xtts_api_server package

(or pip install . if you prefer a non-editable install) before you try to invoke the server.
• Alternatively, add a CLI entrypoint in your pyproject.toml so that pip install . also installs an executable:

[project.scripts]
xtts-api-server = "xtts_api_server.__main__:main"

Then pip install . (or pip install -e .) will provide a xtts-api-server command.

🤖 Prompt for AI Agents
In ddistro_install.sh around lines 34-35, the script currently comments out
installing the local xtts_api_server package which means the xtts-api-server
command won’t be available; replace that commented line with a local install
(e.g., run pip install -e . or pip install .) before invoking the server, or
alternatively add a console-script entrypoint in pyproject.toml (project.scripts
mapping to xtts_api_server.__main__:main) so pip install . will create the
xtts-api-server executable.

sed -i 's/checkpoint = load_fsspec(model_path, map_location=torch.device("cpu"))\["model"\]/checkpoint = load_fsspec(model_path, map_location=torch.device("cpu"), weights_only=False)["model"]/' /home/dwemer/python-tts/lib/python3.11/site-packages/TTS/tts/models/xtts.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Stop hard-coding the Python 3.11 site-packages path.

Line [46] assumes the venv lives under .../python3.11/..., but python3 -m venv will follow whatever interpreter version is installed (3.10, 3.12, etc.). On anything but 3.11 the sed command fails, the patch is never applied, and the setup is silently broken. Resolve the path at runtime:

-sed -i 's/checkpoint = load_fsspec(model_path, map_location=torch.device("cpu"))\["model"\]/checkpoint = load_fsspec(model_path, map_location=torch.device("cpu"), weights_only=False)["model"]/' /home/dwemer/python-tts/lib/python3.11/site-packages/TTS/tts/models/xtts.py
+model_file="$(
+  python - <<'PY'
+import sysconfig, pathlib
+print(pathlib.Path(sysconfig.get_path("purelib")) / "TTS/tts/models/xtts.py")
+PY
+)"
+if [[ ! -f "$model_file" ]]; then
+  echo "Error: xtts.py not found at $model_file"
+  exit 1
+fi
+sed -i 's/checkpoint = load_fsspec(model_path, map_location=torch.device("cpu"))\["model"\]/checkpoint = load_fsspec(model_path, map_location=torch.device("cpu"), weights_only=False)["model"]/' "$model_file"
🤖 Prompt for AI Agents
In ddistro_install.sh around line 46, the sed command hard-codes a python3.11
site-packages path which will fail for other interpreter versions; change it to
resolve the site-packages directory at runtime by invoking the target Python
interpreter to print its site-packages/purelib path and use that value in the
sed command so the replacement operates on the correct venv path (ensure the
python invocation matches the venv/interpreter you created and properly
quote/escape the resolved path when passing it to sed).


cp /home/dwemer/TheNarrator.wav speakers/TheNarrator.wav
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Check file existence before copying speaker sample.

Copying /home/dwemer/TheNarrator.wav without verifying it exists will fail silently or with an unclear error. Add a guard:

if [[ ! -f "$SAMPLE_PATH" ]]; then
  echo "Error: sample file not found at $SAMPLE_PATH"
  exit 1
fi
cp "$SAMPLE_PATH" "${BASE_DIR}/speakers/"


source /home/dwemer/python-tts/bin/activate

./conf.sh

echo
echo "This will start CHIM XTTS to download the selected model"
echo "Wait for the message 'Uvicorn running on http://0.0.0.0:8020 (Press CTRL+C to quit)'"
echo "Then close this window. Press ENTER to continue"
read

echo "please wait...."

python -m xtts_api_server --listen

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use the venv’s Python interpreter to launch the server.

Relying on system python may bypass the virtual environment. Switch to python3 (or $VENV_DIR/bin/python):

- python -m xtts_api_server --listen
+ python3 -m xtts_api_server --listen
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
python -m xtts_api_server --listen
-python -m xtts_api_server --listen
+python3 -m xtts_api_server --listen

echo "Press Enter"
Loading