Skip to content

Conversation

@abeiro
Copy link

@abeiro abeiro commented Jun 11, 2024

  • Added route to upload sample into speakers folder, so you can upload new speakers using API
  • Added python-multipart to requirements

Summary by CodeRabbit

  • New Features

    • Three service start modes (DeepSpeed, Low VRAM, Regular) with background launch and logging.
    • Interactive configuration utility to pick and enable the active start mode.
    • Installer to automate environment setup, GPU/runtime selection, and service startup.
  • Chores

    • Added a local file to ignore in version control.
    • Bulk update and reorganization of Python dependencies (new pinned dependency set).

…d new speakers using API

* Added python-multipart to requirements
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 11, 2024

Walkthrough

Adds modules-xtts.txt to .gitignore, replaces requirements.txt with a large, pinned dependency set and adds requirements5.txt, and introduces installer/configuration scripts plus three mode-specific start scripts to configure and run the XTTSv2 FastAPI TTS service.

Changes

Cohort / File(s) Change Summary
Git ignore
\.gitignore
Added modules-xtts.txt to the ignore list.
Dependencies
requirements.txt, requirements5.txt
requirements.txt extensively revised with many pinned packages added/removed/updated; added requirements5.txt with a CUDA-tagged, pinned dependency set.
Configuration selector
conf.sh
New interactive Bash script to enumerate start-*.sh files and create/remove /home/dwemer/xtts-api-server/start.sh symlink based on user selection.
Installer / environment
ddistro_install.sh
New installer script: creates/activates venv at /home/dwemer/python-tts, prompts for GPU/CUDA options, installs tooling and wheels (handles Torch wheel selection), applies a small code patch, copies assets, invokes conf.sh, and starts the server.
Start scripts (modes)
start-deepspeed.sh, start-lowvram.sh, start-regular.sh
Three new mode-specific start scripts that set PATH/LD_LIBRARY_PATH, activate venv, and launch xtts_api_server with corresponding flags (--deepspeed, --lowvram, or regular), logging to log.txt and running in background.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Conf as conf.sh
    participant FS as Filesystem

    User->>Conf: run conf.sh
    Conf->>FS: check /home/dwemer/python-tts exists
    Conf->>FS: list /home/dwemer/xtts-api-server/start-*.sh
    Conf->>User: show numbered menu (0 = disable)
    User->>Conf: select option
    Conf->>FS: create/update or remove symlink /home/dwemer/xtts-api-server/start.sh
    Conf->>User: confirm selection / exit on error
Loading
sequenceDiagram
    participant User
    participant Installer as ddistro_install.sh
    participant Venv as PythonEnv
    participant FS as Filesystem
    participant Conf as conf.sh
    participant Server as xtts_api_server

    User->>Installer: run installer
    Installer->>FS: cd to server dir
    Installer->>Venv: create & activate venv (/home/dwemer/python-tts)
    Installer->>User: prompt for GPU/CUDA choice
    User->>Installer: choose GPU/CUDA option
    Installer->>Venv: install tooling & requirements (select Torch wheel), apply file patch
    Installer->>FS: copy assets (e.g., TheNarrator.wav)
    Installer->>Conf: invoke conf.sh to set start.sh symlink
    Installer->>Server: start xtts_api_server (--listen, optional --deepspeed) and tail logs
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Review focus:
    • Large dependency changes in requirements.txt and consistency with requirements5.txt.
    • Safety, idempotence and error handling in ddistro_install.sh (wheel selection, symlinks, in-place edits).
    • Input validation and symlink manipulation in conf.sh.
    • Environment activation and LD_LIBRARY_PATH / CUDA path handling in start-*.sh.

Poem

I hopped through folders, twitching my nose,
I hid a file where quiet modules doze.
I pinned the packages, tidy and neat,
Wrote scripts to wake the server on its feet.
Select a mode — the rabbit hums, ready to greet. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The pull request title states "Add /upload_sample route to allow upload new speakers using Web API," which claims the primary change is the implementation of a new API route. However, examining the raw_summary reveals that the actual changes consist primarily of infrastructure and configuration updates: modifications to .gitignore, additions to requirements files (including python-multipart), and several new shell scripts for service management and environment setup. While the python-multipart package addition supports the stated objective, the actual /upload_sample route implementation is not shown in the provided changeset summary. This creates a disconnect between what the title promises (a new route implementation) and what the changeset actually contains (infrastructure and dependency updates). The title should be adjusted to more accurately reflect the actual changes in the changeset. Consider revising the title to something like "Add infrastructure and dependencies for speaker upload feature" or "Update dependencies and configuration for file upload support," which would better represent the infrastructure-focused changes shown in the raw_summary. Alternatively, verify that the actual route implementation file is included in the pull request and ensure it appears in the changeset summary.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Outside diff range and nitpick comments (2)
xtts_api_server/server.py (2)

Line range hint 195-195: Improve exception handling by using exception chaining.

- raise HTTPException(status_code=400, detail=str(e))
+ raise HTTPException(status_code=400, detail=str(e)) from e

Also applies to: 204-204, 224-224, 233-233, 298-298, 329-329, 353-353

Tools
Ruff

1-1: TTS.api.TTS imported but unused (F401)

Remove unused import: TTS.api.TTS


Line range hint 150-150: Avoid redefining the get_speakers function.

- @app.get("/speakers")
+ @app.get("/special_speakers")
  def get_speakers_special():
Tools
Ruff

1-1: TTS.api.TTS imported but unused (F401)

Remove unused import: TTS.api.TTS

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8285ecd and 98845ca.

Files selected for processing (2)
  • requirements.txt (1 hunks)
  • xtts_api_server/server.py (2 hunks)
Files skipped from review due to trivial changes (1)
  • requirements.txt
Additional context used
Ruff
xtts_api_server/server.py

1-1: TTS.api.TTS imported but unused (F401)

Remove unused import: TTS.api.TTS


10-10: time imported but unused (F401)

Remove unused import: time


12-12: shutil imported but unused (F401)

Remove unused import: shutil


14-14: argparse.ArgumentParser imported but unused (F401)

Remove unused import: argparse.ArgumentParser


15-15: Redefinition of unused Path from line 11 (F811)

Remove definition: Path


150-150: Redefinition of unused get_speakers from line 145 (F811)


195-195: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling (B904)


204-204: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling (B904)


207-207: Do not perform function call File in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable (B008)


224-224: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling (B904)


233-233: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling (B904)


298-298: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling (B904)


329-329: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling (B904)


353-353: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling (B904)

@@ -1,5 +1,5 @@
from TTS.api import TTS
from fastapi import BackgroundTasks, FastAPI, HTTPException, Request, Query
from fastapi import BackgroundTasks, FastAPI, HTTPException, Request, Query, File, UploadFile
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove unused imports to clean up the code.

- from TTS.api import TTS
- import time
- import shutil
- from argparse import ArgumentParser
- from pathlib import Path

Committable suggestion was skipped due to low confidence.

raise HTTPException(status_code=400, detail=str(e))

@app.post("/upload_sample")
async def upload_sample(wavFile: UploadFile = File(...)):
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid using File(...) as a default argument.

- async def upload_sample(wavFile: UploadFile = File(...)):
+ async def upload_sample(wavFile: UploadFile = None):
+     if wavFile is None:
+         wavFile = File(...)
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
async def upload_sample(wavFile: UploadFile = File(...)):
async def upload_sample(wavFile: UploadFile = None):
if wavFile is None:
wavFile = File(...)
Tools
Ruff

207-207: Do not perform function call File in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable (B008)

@daswer123
Copy link
Owner

Great, thanks, I'll take a look tomorrow.
I've been trying to add it myself but haven't had the time )

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
requirements.txt (1)

1-169: Consider reducing dependency bloat

The requirements file includes many packages that seem unnecessary for the upload_sample route functionality:

  • Multiple TTS engines (coqui-tts, pyttsx3)
  • Various language processing tools (gruut, spacy, stanza)
  • Multiple audio processing libraries

Consider maintaining separate requirement files:

  • requirements.txt for core dependencies
  • requirements-dev.txt for development dependencies
  • requirements-optional.txt for optional features

Example structure:

# requirements.txt (core dependencies)
fastapi==0.109.0
python-multipart==0.0.20
python-dotenv==1.0.1
uvicorn==0.34.0

# requirements-optional.txt (TTS-specific dependencies)
coqui-tts==0.24.1
librosa==0.10.2.post1
torch==2.5.1
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 571c4f2 and f10207f.

📒 Files selected for processing (1)
  • requirements.txt (1 hunks)
🔇 Additional comments (3)
requirements.txt (3)

122-122: LGTM! Required package for file upload functionality

The addition of python-multipart is necessary for handling file uploads in FastAPI.


38-38: Update FastAPI to the latest stable version

The current FastAPI version (0.115.6) is outdated and may have security vulnerabilities.

Run this script to check for security advisories:


88-99: Verify CUDA compatibility with the system

The inclusion of CUDA 12.x dependencies suggests GPU usage. Ensure these versions are compatible with:

  1. The installed NVIDIA drivers
  2. The GPU hardware
  3. The operating system

Run this script to check CUDA compatibility:

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Nitpick comments (5)
start-deepspeed.sh (1)

7-7: Optionally capture and log the server PID.
Storing the background process PID can help with service management (stopping, monitoring). For example:

- python -m xtts_api_server --deepspeed --listen &> log.txt &
+ python -m xtts_api_server --deepspeed --listen &> log.txt &
+ echo $! > server.pid
start-regular.sh (1)

1-10: Consider consolidating start scripts to reduce duplication.
All three start scripts follow the same pattern differing only by the flag (--listen, --lowvram, --deepspeed). You could merge them into a single start.sh that accepts a mode parameter (e.g., ./start.sh lowvram), reducing maintenance overhead.

🧰 Tools
🪛 Shellcheck (0.10.0)

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

(SC2164)

conf.sh (2)

1-2: Enable strict error handling for robustness.
Add set -euo pipefail after the shebang to catch failures early and avoid undefined variables.

#!/bin/bash
+ set -euo pipefail
 clear

48-48: Quote variable expansions in file operations.
Unquoted paths can break if they contain spaces or special characters. Wrap expansions in quotes.

- rm /home/dwemer/xtts-api-server/start.sh &>/dev/null
+ rm "/home/dwemer/xtts-api-server/start.sh" &>/dev/null
...
- ln -sf $selected_file /home/dwemer/xtts-api-server/start.sh
+ ln -sf "$selected_file" "/home/dwemer/xtts-api-server/start.sh"

Also applies to: 62-62

ddistro_install.sh (1)

19-19: Remove redundant virtual environment activation.
The script sources the same venv twice (lines 4 and here). Dropping the second source will simplify the flow.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f10207f and 5e310e0.

📒 Files selected for processing (5)
  • conf.sh (1 hunks)
  • ddistro_install.sh (1 hunks)
  • start-deepspeed.sh (1 hunks)
  • start-lowvram.sh (1 hunks)
  • start-regular.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
conf.sh

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

(SC2242)

ddistro_install.sh

[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)

start-deepspeed.sh

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

(SC2164)

start-lowvram.sh

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

(SC2164)

start-regular.sh

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

(SC2164)

🔇 Additional comments (1)
ddistro_install.sh (1)

15-15: Verify the complex sed substitution.
This in-place edit is brittle and may break if upstream formatting changes. Please test this sed invocation against the target file or consider using a more robust approach (e.g., a Python script with clearer parsing).

Comment on lines +3 to +5
cd /home/dwemer/xtts-api-server/

source /home/dwemer/python-tts/bin/activate
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 error handling to directory change and dynamic path resolution.
Using a hard-coded cd without checking its success can lead to silent failures. Also, absolute paths reduce portability.
Apply this diff:

- cd /home/dwemer/xtts-api-server/
+ BASE_DIR="$(dirname "$0")"
+ cd "${BASE_DIR}" || { echo "Error: failed to change directory to ${BASE_DIR}"; exit 1; }
🧰 Tools
🪛 Shellcheck (0.10.0)

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

(SC2164)

Comment on lines +3 to +5
cd /home/dwemer/xtts-api-server/

source /home/dwemer/python-tts/bin/activate
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 succeeds and use script-relative paths.
The cd command should exit on failure to prevent subsequent commands from running in an unexpected directory. Also, deriving the path dynamically makes the script more portable.

- cd /home/dwemer/xtts-api-server/
+ BASE_DIR="$(dirname "$0")"
+ cd "${BASE_DIR}" || { echo "Error: could not enter ${BASE_DIR}"; 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/
source /home/dwemer/python-tts/bin/activate
BASE_DIR="$(dirname "$0")"
cd "${BASE_DIR}" || { echo "Error: could not enter ${BASE_DIR}"; exit 1; }
source /home/dwemer/python-tts/bin/activate
🧰 Tools
🪛 Shellcheck (0.10.0)

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

(SC2164)

Comment on lines +3 to +5
cd /home/dwemer/xtts-api-server/

source /home/dwemer/python-tts/bin/activate
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 error checking on directory change and derive path from script location.
This prevents silent failures if the directory is missing and makes the script agnostic of a fixed install path.

- cd /home/dwemer/xtts-api-server/
+ BASE_DIR="$(dirname "$0")"
+ cd "${BASE_DIR}" || { echo "Error: failed to change directory to ${BASE_DIR}"; 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/
source /home/dwemer/python-tts/bin/activate
BASE_DIR="$(dirname "$0")"
cd "${BASE_DIR}" || { echo "Error: failed to change directory to ${BASE_DIR}"; exit 1; }
source /home/dwemer/python-tts/bin/activate
🧰 Tools
🪛 Shellcheck (0.10.0)

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

(SC2164)

Comment on lines +20 to +22
if [ ! -d /home/dwemer/python-tts ]; then
exit "XTTSv2 not installed"
fi
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)

@@ -0,0 +1,34 @@

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 +1 to +2

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

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)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (2)
ddistro_install.sh (2)

1-1: Add shebang and strict mode at the top of the script.

Without a shebang and strict error settings, the script’s behavior is undefined and errors may not be caught early. Add at the top:

#!/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)


2-2: Guard directory change with error handling.

If the cd fails, subsequent commands will execute in the wrong context. Update to:

- 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)

🧹 Nitpick comments (2)
ddistro_install.sh (2)

8-10: Combine pip installation steps for clarity and performance.

Instead of multiple invocations, you can group upgrades and requirements:

- python3 -m pip install --upgrade pip wheel ninja virtualenv
- pip install setuptools==68.1.2
- pip install -r requirements.txt
+ pip install --upgrade pip wheel ninja virtualenv setuptools==68.1.2
+ pip install -r requirements.txt

This reduces overhead and improves readability.


19-19: Remove redundant virtual environment activation.

The venv is already activated at line 4. Activating it again is unnecessary and could mask activation failures.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5e310e0 and 65dfd1c.

📒 Files selected for processing (1)
  • ddistro_install.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
ddistro_install.sh

[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)


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

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/"

Comment on lines +2 to +4
cd /home/dwemer/xtts-api-server
python3 -m venv /home/dwemer/python-tts
source /home/dwemer/python-tts/bin/activate
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)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
conf.sh (1)

21-23: Fix invalid use of exit with a string.

exit only accepts numeric status codes. Use echo to print the error message and then exit 1. This matches the ShellCheck hint (SC2242) and the previous review feedback.

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

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

(SC2242)

🧹 Nitpick comments (4)
conf.sh (4)

34-34: Correct the menu prompt typo.

There's a duplicated article in the prompt. Update "Select a an option" to "Select an option".

-echo -e "Select a an option from the list:\n\n"
+echo -e "Select an option from the list:\n\n"

47-51: Avoid numeric comparison on unvalidated input.

Using -eq on a non-numeric selection can cause an error if the user inputs a non-integer. Either validate that selection is numeric before this check, or switch to string comparison (== "0").

-if [ "$selection" -eq "0" ]; then
+if [[ "$selection" == "0" ]]; then

Optionally, you can move this block after the numeric-validation block at lines 53–56.


63-63: Quote variables in ln invocation.

Unquoted paths can break if $selected_file contains spaces or special characters. Wrap both source and target in quotes.

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

21-26: Use variables for installation paths.

Hard-coded /home/dwemer/... paths reduce portability. Consider defining variables at the top (e.g., BASE_DIR and TTS_DIR) or using $HOME:

+BASE_DIR="${HOME}/xtts-api-server"
+TTS_DIR="${HOME}/python-tts"
 
 if [ ! -d /home/dwemer/python-tts ]; then
-    echo "Error: XTTSv2 not installed" >&2
-    exit 1
+    echo "Error: XTTSv2 not installed" >&2
+    exit 1
 fi
 
-mapfile -t files < <(find /home/dwemer/xtts-api-server/ -name "start-*.sh")
+mapfile -t files < <(find "$BASE_DIR" -name "start-*.sh")
🧰 Tools
🪛 Shellcheck (0.10.0)

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

(SC2242)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 65dfd1c and f720b33.

📒 Files selected for processing (1)
  • conf.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
conf.sh

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

(SC2242)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
conf.sh (1)

19-21: ⚠️ Potential issue

Fix invalid use of exit with a string
The exit built-in only accepts integer status codes. Writing an error message to stderr and then exiting with a non-zero code will correctly signal failure.

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

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

(SC2242)

🧹 Nitpick comments (1)
conf.sh (1)

61-61: Quote the variable in the ln command
Unquoted variables can break if the path contains whitespace or glob characters.

-ln -sf $selected_file /home/dwemer/xtts-api-server/start.sh
+ln -sf "$selected_file" /home/dwemer/xtts-api-server/start.sh
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f720b33 and 0e9f827.

📒 Files selected for processing (1)
  • conf.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
conf.sh

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

(SC2242)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
conf.sh (1)

19-21: Fix invalid use of exit with a string
exit only accepts numeric status codes. Errors should be written to stderr and then exit with a non-zero status code.

- 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] 20-20: Can only exit with status 0-255. Other data should be written to stdout/stderr.

(SC2242)

🧹 Nitpick comments (2)
conf.sh (2)

32-32: Typo in the selection prompt
There’s a duplicate article in the prompt "Select a an option...". It should read "Select an option...".

- echo -e "Select a an option from the list:\n\n"
+ echo -e "Select an option from the list:\n\n"

23-23: Avoid hard-coded absolute paths
Consider defining a base directory variable (e.g., XTTS_HOME="${XTTS_HOME:-$HOME/dwemer}") at the top and referencing it throughout. This improves portability and makes future relocations/configurations easier.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0e9f827 and e7faea6.

📒 Files selected for processing (1)
  • conf.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
conf.sh

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

(SC2242)


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"

Comment on lines +45 to +54
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
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

* Added branch for Nvidia GT 10xx users (will use cuda 118)
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (5)
ddistro_install.sh (5)

1-2: Add strict error handling flags
To catch errors and undefined variables early, add set -euo pipefail right after the shebang.

Suggested diff:

#!/bin/bash
+ set -euo pipefail

3-3: Validate cd success
If cd fails, the script will continue in the wrong directory. Append an exit handler to guard against that.

Suggested diff:

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

4-5: Parameterize hard-coded paths
Using fixed paths reduces portability. Introduce BASE_DIR and VENV_DIR variables so users can override them.

Example:

- python3 -m venv /home/dwemer/python-tts
- source /home/dwemer/python-tts/bin/activate
+ BASE_DIR="${BASE_DIR:-$HOME/xtts-api-server}"
+ VENV_DIR="${VENV_DIR:-$HOME/python-tts}"
+
+ python3 -m venv "$VENV_DIR"
+ source "$VENV_DIR/bin/activate"
+ cd "$BASE_DIR" || exit 1

24-24: Avoid brittle in-place sed edits
Patching installed packages with sed can break on updates. Prefer delivering a proper patch or at least guard the file’s existence before editing.

Example check:

FILE="/home/dwemer/python-tts/lib/python3.11/site-packages/TTS/tts/models/xtts.py"
if [[ -f "$FILE" ]]; then
  sed -i 's/.../.../' "$FILE"
else
  echo "Error: $FILE not found"; exit 1
fi

26-26: Ensure speaker sample exists before copying
Copying without checking the source file can fail with an unclear error. Add a guard to verify the path.

Suggested diff:

- cp /home/dwemer/TheNarrator.wav speakers/TheNarrator.wav
+ SAMPLE_PATH="${SAMPLE_PATH:-/home/dwemer/TheNarrator.wav}"
+ if [[ ! -f "$SAMPLE_PATH" ]]; then
+   echo "Error: speaker sample not found at $SAMPLE_PATH"; exit 1
+ fi
+ cp "$SAMPLE_PATH" "speakers/TheNarrator.wav"
🧹 Nitpick comments (4)
ddistro_install.sh (4)

10-15: Handle invalid input in GPU prompt
Currently any response other than “yes” falls back silently to the non-GPU path. Use a loop or case to re-prompt until valid.

Example:

while true; do
  read -p "Do you own a GT10XX series GPU? (yes/no): " ans
  case "$ans" in
    [Yy]|[Yy][Ee][Ss]) torch_url="https://download.pytorch.org/whl/nightly/cu118"; break ;;
    [Nn]|[Nn][Oo])  torch_url="https://download.pytorch.org/whl/nightly/cu128"; break ;;
    *) echo "Please answer yes or no." ;;
  esac
done

17-21: Consistent invocation of pip
Mixing python3 -m pip and bare pip can install into different environments. Stick to one form—prefer python3 -m pip.

Suggested diff:

- pip install setuptools==68.1.2
- pip install -r requirements.txt
- pip uninstall -y torch torchaudio
- pip install --pre -U torch torchaudio --index-url "$torch_url"
+ python3 -m pip install setuptools==68.1.2
+ python3 -m pip install -r requirements.txt
+ python3 -m pip uninstall -y torch torchaudio
+ python3 -m pip install --pre -U torch torchaudio --index-url "$torch_url"

30-30: Verify conf.sh execution
If conf.sh is missing or not executable, the script will error out later. Add a pre-check.

Example:

if [[ ! -x "./conf.sh" ]]; then
  echo "Error: conf.sh not found or not executable"; exit 1
fi
./conf.sh

40-40: Use consistent Python interpreter for server launch
To ensure the correct venv is used, explicitly invoke the venv’s Python.

Suggested diff:

- python -m xtts_api_server --listen
+ "$VENV_DIR/bin/python" -m xtts_api_server --listen
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e7faea6 and c9e67cf.

📒 Files selected for processing (1)
  • ddistro_install.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
ddistro_install.sh

[error] 42-42: Couldn't parse this double quoted string. Fix to allow more checks.

(SC1073)

* Fixed unclosed "
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (5)
ddistro_install.sh (5)

1-2: Enable strict error handling for robustness.

The script currently has a shebang but lacks strict mode, which can lead to silent failures or use of unset variables. Add set -euo pipefail after the shebang to ensure it exits on errors and undefined variables.


3-3: Parameterize and validate the working directory change.

Avoid hard-coding /home/dwemer/xtts-api-server. Introduce a BASE_DIR variable (with a sensible default) and guard the cd:

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

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

(SC2164)


4-5: Refactor virtual environment setup to use configurable paths.

Hard-coded VENV location reduces reusability. Use a VENV_DIR variable and reference it consistently:

- python3 -m venv /home/dwemer/python-tts
- source /home/dwemer/python-tts/bin/activate
+ VENV_DIR="${VENV_DIR:-$HOME/python-tts}"
+ python3 -m venv "$VENV_DIR"
+ source "$VENV_DIR/bin/activate"

24-24: Guard against missing xtts.py before applying in-place patch.

Editing site-packages in place is brittle. At minimum, verify the file exists and consider using a patch file or upstream PR:

+ TTS_MODEL_FILE="$VENV_DIR/lib/python$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')/site-packages/TTS/tts/models/xtts.py"
+ if [[ -f "$TTS_MODEL_FILE" ]]; then
+   sed -i 's/checkpoint = load_fsspec(...)/checkpoint = load_fsspec(..., weights_only=False)/' "$TTS_MODEL_FILE"
+ else
+   echo "Error: $TTS_MODEL_FILE not found" >&2
+   exit 1
+ fi

26-26: Verify speaker sample file existence before copying.

Directly copying /home/dwemer/TheNarrator.wav can fail without a clear message. Parameterize SAMPLE_PATH, ensure the directory exists, and guard the copy:

+ SAMPLE_PATH="${SAMPLE_PATH:-/home/dwemer/TheNarrator.wav}"
+ DEST_DIR="speakers"
+ if [[ ! -f "$SAMPLE_PATH" ]]; then
+   echo "Error: sample file '$SAMPLE_PATH' not found" >&2
+   exit 1
+ fi
+ mkdir -p "$DEST_DIR"
+ cp "$SAMPLE_PATH" "$DEST_DIR/"
🧹 Nitpick comments (3)
ddistro_install.sh (3)

10-15: Enhance GPU selection prompt validation (optional).

The regex handles basic yes/no but doesn’t catch invalid inputs. Consider normalizing to lowercase and using a case statement with a default branch:

read -p "Do you own a GT10XX series GPU? (yes/no): " gpu_answer
gpu_answer="${gpu_answer,,}"
case "$gpu_answer" in
  y|yes) torch_url="https://download.pytorch.org/whl/nightly/cu118" ;;
  n|no)  torch_url="https://download.pytorch.org/whl/nightly/cu128" ;;
  *)     echo "Invalid response: $gpu_answer"; exit 1 ;;
esac

22-22: Remove or fix the commented-out command.

The #pip install xtts-api-server line either needs context (why it fails) or should be removed to keep the script clean.


28-31: Ensure conf.sh execution is validated.

If conf.sh fails or is missing, the script should stop and report an error:

+ if [[ ! -f "./conf.sh" ]]; then
+   echo "Error: conf.sh not found"; exit 1
+ fi
+ ./conf.sh || { echo "Error: conf.sh failed"; exit 1; }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c9e67cf and f1e8c39.

📒 Files selected for processing (1)
  • ddistro_install.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
ddistro_install.sh

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

(SC2164)

Comment on lines 17 to 21
python3 -m pip install --upgrade pip wheel ninja virtualenv
pip install setuptools==68.1.2
pip install -r requirements.txt
pip uninstall -y torch torchaudio
pip install --pre -U torch torchaudio --index-url "$torch_url"
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

Consistently invoke pip via python3 -m pip within the venv.

Mixing bare pip and python3 -m pip can lead to ambiguity about which interpreter is used. Update all install/uninstall commands:

- pip install setuptools==68.1.2
- pip install -r requirements.txt
- pip uninstall -y torch torchaudio
- pip install --pre -U torch torchaudio --index-url "$torch_url"
+ python3 -m pip install setuptools==68.1.2
+ python3 -m pip install -r requirements.txt
+ python3 -m pip uninstall -y torch torchaudio
+ python3 -m pip install --pre -U torch torchaudio --index-url "$torch_url"
📝 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
python3 -m pip install --upgrade pip wheel ninja virtualenv
pip install setuptools==68.1.2
pip install -r requirements.txt
pip uninstall -y torch torchaudio
pip install --pre -U torch torchaudio --index-url "$torch_url"
python3 -m pip install --upgrade pip wheel ninja virtualenv
python3 -m pip install setuptools==68.1.2
python3 -m pip install -r requirements.txt
python3 -m pip uninstall -y torch torchaudio
python3 -m pip install --pre -U torch torchaudio --index-url "$torch_url"

Comment on lines 40 to 41
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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
start-deepspeed.sh (1)

7-7: Ensure cd succeeds and use script-relative paths.

As flagged by ShellCheck (SC2164) and previously noted in past reviews, use the script's directory dynamically and exit if cd fails.

-cd /home/dwemer/xtts-api-server/
+BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.."
+cd "${BASE_DIR}" || { echo "Error: could not change directory to ${BASE_DIR}" >&2; exit 1; }
🧰 Tools
🪛 Shellcheck (0.10.0)

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

(SC2164)

🧹 Nitpick comments (2)
start-deepspeed.sh (2)

1-1: Enable strict mode for safer error handling.

Add set -euo pipefail after the shebang to ensure the script exits on any error, catches unset variables, and fails on pipeline errors.

#!/bin/bash
+ set -euo pipefail

9-9: Avoid hardcoding virtual environment paths.

Make the virtual environment activation path configurable or relative to the script location to improve portability. For example:

-source /home/dwemer/python-tts/bin/activate
+source "${BASE_DIR}/python-tts/bin/activate"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between f1e8c39 and c388e1d.

📒 Files selected for processing (1)
  • start-deepspeed.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
start-deepspeed.sh

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

(SC2164)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (6)
ddistro_install.sh (6)

1-2: Enable strict mode for safer scripting.

Add fail-fast and safer IFS. This prevents subtle errors from continuing unnoticed.

 #!/bin/bash
+
+set -euo pipefail
+# Safer word splitting for arrays/paths
+IFS=$'\n\t'

3-5: Parameterize paths and guard cd; improve portability and reliability.

Avoid hardcoded user paths and ensure directory change succeeds. This also addresses SC2164 from shellcheck.

-cd /home/dwemer/xtts-api-server
-python3 -m venv /home/dwemer/python-tts
-source /home/dwemer/python-tts/bin/activate
+BASE_DIR="${BASE_DIR:-$HOME/xtts-api-server}"
+VENV_DIR="${VENV_DIR:-$HOME/python-tts}"
+cd "$BASE_DIR" || { echo "Error: cannot cd to $BASE_DIR"; exit 1; }
+python3 -m venv "$VENV_DIR"
+# shellcheck disable=SC1091
+source "$VENV_DIR/bin/activate"

17-23: Use the venv interpreter for all pip ops; avoid interpreter ambiguity.

Standardize on python -m pip and keep the current ordering if you intend the nightly torch stack to override any torch specified in requirements.

 python3 -m pip install --upgrade pip wheel ninja virtualenv
-pip install setuptools==68.1.2
-pip install -r requirements.txt
+python3 -m pip install setuptools==68.1.2
+python3 -m pip install -r requirements.txt
 # Ensure fresh installs of PyTorch stack including TorchCodec required by recent torchaudio
-pip uninstall -y torch torchaudio torchcodec
-pip install --pre -U torch torchaudio torchcodec --index-url "$torch_url"
+python3 -m pip uninstall -y torch torchaudio torchcodec || true
+python3 -m pip install --pre -U torch torchaudio torchcodec --index-url "$torch_url"

Optional: If requirements.txt also pins torch/torchaudio, consider removing them there to avoid churn, or install requirements with --no-deps after the torch stack. Please confirm the desired precedence.


25-25: Avoid brittle sed patching of site-packages; compute path dynamically and back up.

Hardcoding Python 3.11 and direct in-place edits are fragile and will break on upgrades or different environments. Prefer a targeted patch with backup based on the actual installed path.

-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
+# Locate installed xtts.py and patch safely
+XTTS_FILE="$(python3 - <<'PY'
+import inspect, TTS.tts.models.xtts as m
+print(inspect.getfile(m))
+PY
+)"
+if [[ -f "$XTTS_FILE" ]]; then
+  cp "$XTTS_FILE" "${XTTS_FILE}.bak"
+  python3 - "$XTTS_FILE" <<'PY'
+import sys, pathlib
+p = pathlib.Path(sys.argv[1])
+s = p.read_text()
+old = 'load_fsspec(model_path, map_location=torch.device("cpu"))["model"]'
+new = 'load_fsspec(model_path, map_location=torch.device("cpu"), weights_only=False)["model"]'
+if old in s and new not in s:
+  p.write_text(s.replace(old, new))
+else:
+  print("Note: expected pattern not found or already patched", file=sys.stderr)
+PY
+else
+  echo "Error: xtts.py not found; cannot patch." >&2
+  exit 1
+fi

Long-term, prefer upstreaming this change or applying a proper patch file rather than mutating installed packages.


27-27: Validate sample file and ensure speakers dir exists before copying.

Prevents confusing failures on missing source file or directory.

-cp /home/dwemer/TheNarrator.wav speakers/TheNarrator.wav
+SAMPLE_PATH="${SAMPLE_PATH:-$HOME/TheNarrator.wav}"
+mkdir -p speakers
+if [[ ! -f "$SAMPLE_PATH" ]]; then
+  echo "Error: sample file not found at $SAMPLE_PATH" >&2
+  exit 1
+fi
+cp "$SAMPLE_PATH" "speakers/TheNarrator.wav"

41-41: Use the venv’s Python interpreter to run the server.

Guarantees the correct environment and dependencies.

-python -m xtts_api_server --listen
+"${VENV_DIR:-$HOME/python-tts}"/bin/python -m xtts_api_server --listen
🧹 Nitpick comments (3)
ddistro_install.sh (3)

10-15: Make CUDA index selection robust; optionally auto-detect GPU capability.

The yes/no prompt works but is brittle. Consider auto-detecting compute capability via nvidia-smi and mapping to the correct CUDA wheel, with a manual fallback.

-read -p "Do you own a GT10XX series GPU? (yes/no): " gpu_answer
-if [[ "$gpu_answer" =~ ^[Yy][Ee][Ss]$ || "$gpu_answer" =~ ^[Yy]$ ]]; then
-    torch_url="https://download.pytorch.org/whl/nightly/cu118"
-else
-    torch_url="https://download.pytorch.org/whl/nightly/cu128"
-fi
+# Try to detect CUDA capability; fall back to prompt
+torch_url=""
+if command -v nvidia-smi >/dev/null 2>&1; then
+  cc="$(nvidia-smi --query-gpu=compute_cap --format=csv,noheader 2>/dev/null | head -n1 || true)"
+  case "$cc" in
+    6.*) torch_url="https://download.pytorch.org/whl/nightly/cu118" ;;  # Pascal
+    7.*|8.*|9.*) torch_url="https://download.pytorch.org/whl/nightly/cu128" ;; # Turing/Ampere+/Blackwell
+  esac
+fi
+if [[ -z "${torch_url}" ]]; then
+  read -r -p "Use CUDA 11.8 wheels? [y/N]: " ans
+  if [[ "$ans" =~ ^[Yy]$ ]]; then torch_url="https://download.pytorch.org/whl/nightly/cu118"; else torch_url="https://download.pytorch.org/whl/nightly/cu128"; fi
+fi
+echo "Using PyTorch nightly index: $torch_url"

Note: Please verify the mapping for your supported GPUs and desired CUDA runtime.


31-31: Ensure conf.sh exists and is executable; fail fast if not.

Avoids silent no-ops or confusing errors later.

-./conf.sh
+if [[ ! -x ./conf.sh ]]; then
+  echo "Error: ./conf.sh missing or not executable" >&2
+  exit 1
+fi
+./conf.sh

43-44: Either remove the trailing prompt or read input.

Right now it only prints “Press Enter” without waiting. If you intend to pause, add a read.

-echo "Press Enter"
+read -r -p "Press ENTER to exit... " _
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c388e1d and 38f8dfa.

📒 Files selected for processing (1)
  • ddistro_install.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
ddistro_install.sh

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

(SC2164)

🔇 Additional comments (1)
ddistro_install.sh (1)

1-44: Confirm PR scope alignment.

PR objectives mention adding a new /upload_sample API route and python-multipart dependency. This script is an installation/startup helper and does not relate to that route. Verify whether this file belongs in this PR or should be split into a separate infra/setup PR to keep changes focused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (8)
ddistro_install.sh (8)

1-1: Add strict/defensive shell options right after the shebang.

Enable fail-fast behavior and safer word-splitting to avoid subtle breakages during long installs.

 #!/bin/bash
+set -euo pipefail
+IFS=$'\n\t'
+# Optional: surface a helpful message on unexpected errors
+trap 'echo "Error on line ${LINENO}. Exiting." >&2' ERR

3-5: Parameterize hard-coded paths for portability.

Make the script reusable across users/machines and easier to override in CI.

- cd /home/dwemer/xtts-api-server || { echo "Error: cannot cd to /home/dwemer/xtts-api-server"; exit 1; }
- python3 -m venv /home/dwemer/python-tts
- source /home/dwemer/python-tts/bin/activate
+ BASE_DIR="${BASE_DIR:-$HOME/xtts-api-server}"
+ VENV_DIR="${VENV_DIR:-$HOME/python-tts}"
+ cd "${BASE_DIR}" || { echo "Error: cannot cd to ${BASE_DIR}"; exit 1; }
+ python3 -m venv "${VENV_DIR}"
+ # shellcheck source=/dev/null
+ source "${VENV_DIR}/bin/activate"
@@
- source /home/dwemer/python-tts/bin/activate
+# shellcheck source=/dev/null
+ source "${VENV_DIR}/bin/activate"

Also applies to: 40-40


36-36: Avoid brittle in-place sed patching of site-packages; compute site-packages dynamically.

The hard-coded Python 3.11 path will break on other Python versions or layouts. Also consider carrying a patch file or upstreaming the change.

-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
+# Derive site-packages path from the active venv
+SITE_PKGS="$(python3 -c 'import site,sys; print((site.getsitepackages() or [site.getusersitepackages()])[0])')"
+TARGET_FILE="${SITE_PKGS}/TTS/tts/models/xtts.py"
+if [[ -f "${TARGET_FILE}" ]]; then
+  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"]/' "${TARGET_FILE}"
+else
+  echo "Warning: ${TARGET_FILE} not found; skip patch." >&2
+fi

If you’d like, I can prepare a minimal patch file and apply it via patch -p0 for better traceability.


38-38: Guard the sample copy with an existence check (and use parameterized paths).

Prevents confusing failures if the file is missing.

-cp /home/dwemer/TheNarrator.wav speakers/TheNarrator.wav
+SAMPLE_PATH="${SAMPLE_PATH:-$HOME/TheNarrator.wav}"
+if [[ ! -f "${SAMPLE_PATH}" ]]; then
+  echo "Error: sample file not found at ${SAMPLE_PATH}" >&2
+  exit 1
+fi
+mkdir -p "${BASE_DIR:-$PWD}/speakers"
+cp "${SAMPLE_PATH}" "${BASE_DIR:-$PWD}/speakers/TheNarrator.wav"

3-3: Check the result of cd to prevent running in the wrong directory.

If cd fails, later operations will patch/modify the wrong environment.

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

23-33: Use the venv’s interpreter for all pip actions; avoid mixing with bare pip.

Prevents accidental use of system pip/interpreter and ambiguity.

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

44-52: Fix contradictory prompts and start the server with the venv’s Python.

Current messaging asks users to wait for Uvicorn output before you actually start the server and tells them to close the window (which kills the server). Start immediately after the confirmation and remove the “close this window” instruction.

-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
+echo
+echo "Press ENTER to start CHIM XTTS and download the selected model."
+echo "After startup, look for: 'Uvicorn running on http://0.0.0.0:8020 (Press CTRL+C to quit)'."
+echo "Keep this terminal open to keep the server running."
+read -r
+echo "Starting server, please wait..."
+"${VENV_DIR:-$HOME/python-tts}"/bin/python -m xtts_api_server --listen

If you need the server to persist after logout, consider adding a systemd unit, or use tmux/screen.


52-52: Launch with the venv’s interpreter to avoid escaping the environment.

Using system python may miss installed deps in the venv.

-python -m xtts_api_server --listen
+"${VENV_DIR:-$HOME/python-tts}"/bin/python -m xtts_api_server --listen
🧹 Nitpick comments (4)
ddistro_install.sh (4)

10-21: Harden yes/no prompt parsing and avoid backslash escapes eating with read.

Use read -r and a case statement; improves UX and robustness.

-read -p "Are you using a GT10XX series GPU? (yes/no): " gpu_answer
-if [[ "$gpu_answer" =~ ^[Yy][Ee][Ss]$ || "$gpu_answer" =~ ^[Yy]$ ]]; then
+read -r -p "Are you using a GT10XX series GPU? (yes/no): " gpu_answer
+case "${gpu_answer}" in
+  [Yy]|[Yy][Ee][Ss])
     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
+    ;;
+esac

31-31: Don’t mask dependency conflicts with || true.

If pip check fails, the environment is inconsistent and later steps may break at runtime.

-pip check || true
+python3 -m pip check

40-41: Second venv activation is redundant.

You already activated earlier; re-sourcing is unnecessary unless you intentionally deactivated.

-source /home/dwemer/python-tts/bin/activate
+# (Redundant) already active; remove unless deliberately re-activating after a subshell.

54-55: Align the final prompt with intended behavior.

If you expect a pause, add a read; otherwise, remove the dangling prompt.

-echo "Press Enter"
+echo "Setup complete."
+# If you want a pause here:
+# read -r -p "Press ENTER to exit..."
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 38f8dfa and 2570806.

📒 Files selected for processing (1)
  • ddistro_install.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
ddistro_install.sh

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

(SC2164)

Comment on lines 34 to 35
#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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (5)
start-regular.sh (1)

8-8: Add error checking on cd and derive base path from script location.

Prevents silent failures and avoids hardcoded user-specific paths.

- cd /home/dwemer/xtts-api-server/
+ BASE_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
+ cd "${BASE_DIR}" || { echo "Error: failed to change directory to ${BASE_DIR}" >&2; exit 1; }
start-lowvram.sh (1)

8-8: Add error handling on cd and avoid hardcoded absolute path.

Use script location for portability; exit on failure.

- cd /home/dwemer/xtts-api-server/
+ BASE_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
+ cd "${BASE_DIR}" || { echo "Error: failed to change directory to ${BASE_DIR}" >&2; exit 1; }
conf.sh (3)

19-21: Fix invalid use of exit with a string.

exit only accepts numeric codes; print message then exit with non-zero.

-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
 fi

45-54: Reorder and harden input validation to avoid integer comparison on non-numeric.

-if [ "$selection" -eq "0" ]; then
+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

61-61: Quote variables in ln to handle spaces and special characters.

-ln -sf $selected_file /home/dwemer/xtts-api-server/start.sh
+ln -sf "$selected_file" "/home/dwemer/xtts-api-server/start.sh"
🧹 Nitpick comments (12)
start-regular.sh (4)

10-10: Guard virtualenv activation and fail fast if missing.

If sourcing fails, the script continues and may run system Python with wrong deps.

-source /home/dwemer/python-tts/bin/activate
+VENV_ACTIVATE="/home/dwemer/python-tts/bin/activate"
+if [ -f "$VENV_ACTIVATE" ]; then
+  # shellcheck disable=SC1090
+  source "$VENV_ACTIVATE"
+else
+  echo "Error: venv not found at $VENV_ACTIVATE" >&2
+  exit 1
+fi

1-1: Enable strict mode for safer scripting.

Catch unset vars and early-fail on errors.

 #!/bin/bash
+set -Eeuo pipefail

4-6: Generalize CUDA PATH detection.

Fallback to the default /usr/local/cuda/bin if versioned dir isn’t present.

-if [ -d "/usr/local/cuda-12.8/bin" ]; then
-  export PATH="/usr/local/cuda-12.8/bin:$PATH"
+if [ -d "/usr/local/cuda-12.8/bin" ]; then
+  export PATH="/usr/local/cuda-12.8/bin:$PATH"
+elif [ -d "/usr/local/cuda/bin" ]; then
+  export PATH="/usr/local/cuda/bin:$PATH"
 fi

12-15: Capture PID and optionally harden backgrounding.

Persist the background PID for later management and make logging intent explicit.

-date > log.txt
+date > log.txt

-python -m xtts_api_server --listen &>> log.txt &
+python -m xtts_api_server --listen >> log.txt 2>&1 &
+echo $! > xtts.pid
start-lowvram.sh (4)

1-1: Enable strict mode for resilience.

 #!/bin/bash
+set -Eeuo pipefail

10-10: Validate virtualenv before sourcing.

-source /home/dwemer/python-tts/bin/activate
+VENV_ACTIVATE="/home/dwemer/python-tts/bin/activate"
+if [ -f "$VENV_ACTIVATE" ]; then
+  # shellcheck disable=SC1090
+  source "$VENV_ACTIVATE"
+else
+  echo "Error: venv not found at $VENV_ACTIVATE" >&2
+  exit 1
+fi

4-6: Broaden CUDA PATH detection.

-if [ -d "/usr/local/cuda-12.8/bin" ]; then
-  export PATH="/usr/local/cuda-12.8/bin:$PATH"
+if [ -d "/usr/local/cuda-12.8/bin" ]; then
+  export PATH="/usr/local/cuda-12.8/bin:$PATH"
+elif [ -d "/usr/local/cuda/bin" ]; then
+  export PATH="/usr/local/cuda/bin:$PATH"
 fi

12-15: Persist PID and make logging explicit.

-date > log.txt
+date > log.txt

-python -m xtts_api_server --listen --lowvram &>> log.txt &
+python -m xtts_api_server --listen --lowvram >> log.txt 2>&1 &
+echo $! > xtts.pid
conf.sh (4)

23-29: Make file discovery deterministic and constrained to top-level files.

Limit depth, ensure regular files, and sort results for stable menus.

-mapfile -t files < <(find /home/dwemer/xtts-api-server/ -name "start-*.sh")
+mapfile -t files < <(find /home/dwemer/xtts-api-server/ -maxdepth 1 -type f -name "start-*.sh" | sort)

33-35: Display basenames in the menu for readability; keep full path for linking.

-for i in "${!files[@]}"; do
-    echo "$((i+1)). ${files[$i]}"
-done
+for i in "${!files[@]}"; do
+    echo "$((i+1)). $(basename -- "${files[$i]}")"
+done
@@
-echo "You selected: $selected_file"
+echo "You selected: $(basename -- "$selected_file")"

Also applies to: 59-61


1-1: Enable strict mode to catch errors early.

 #!/bin/bash
+set -Eeuo pipefail

23-23: Avoid hardcoded absolute paths; derive repository root from script location.

Improves portability across environments and usernames.

-mapfile -t files < <(find /home/dwemer/xtts-api-server/ -maxdepth 1 -type f -name "start-*.sh" | sort)
+SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
+REPO_DIR="$SCRIPT_DIR"
+mapfile -t files < <(find "$REPO_DIR" -maxdepth 1 -type f -name "start-*.sh" | sort)
@@
-ln -sf "$selected_file" "/home/dwemer/xtts-api-server/start.sh"
+ln -sf "$selected_file" "$REPO_DIR/start.sh"
@@
-chmod +x /home/dwemer/xtts-api-server/start-*.sh 2>/dev/null || true
+chmod +x "$REPO_DIR"/start-*.sh 2>/dev/null || true

Also applies to: 61-66

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2570806 and dd9c688.

📒 Files selected for processing (3)
  • conf.sh (1 hunks)
  • start-lowvram.sh (1 hunks)
  • start-regular.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
conf.sh

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

(SC2242)

start-lowvram.sh

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

(SC2164)

start-regular.sh

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

(SC2164)

Comment on lines +31 to +39
# 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

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.

Moved cu124 to cu128
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (8)
ddistro_install.sh (8)

4-5: Parameterize hard-coded paths (BASE_DIR, VENV_DIR)
Make the script reusable across hosts and users.

-python3 -m venv /home/dwemer/python-tts
-source /home/dwemer/python-tts/bin/activate
+BASE_DIR="${BASE_DIR:-$HOME/xtts-api-server}"
+VENV_DIR="${VENV_DIR:-$HOME/python-tts}"
+python3 -m venv "$VENV_DIR"
+source "$VENV_DIR/bin/activate"
@@
-source /home/dwemer/python-tts/bin/activate
+source "$VENV_DIR/bin/activate"

Also applies to: 49-49


1-1: Enable strict mode to fail fast
Add robust shell options right after the shebang.

 #!/bin/bash
+set -euo pipefail
+IFS=$'\n\t'

3-3: Check cd failure
Guard against running in the wrong directory.

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

16-26: Consistently use the venv’s pip; avoid mixing pip invocations
Avoid ambiguity about interpreter and environment.

-    python3 -m pip install --upgrade pip wheel ninja virtualenv
-    pip install setuptools==68.1.2
+    python3 -m pip install --upgrade pip wheel ninja virtualenv
+    python3 -m pip install setuptools==68.1.2
@@
-    pip install --no-deps -r requirements.txt
+    python3 -m pip install --no-deps -r requirements.txt
@@
-    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
+    python3 -m pip cache purge || true
+    python3 -m pip uninstall -y torch torchaudio torchcodec torchvision || true
+    python3 -m pip install --no-deps --no-cache-dir --index-url "$torch_url" "torch==${torch_ver}+${cu_tag}" "torchaudio==${torchaudio_ver}+${cu_tag}"
+    python3 -m pip check || true
@@
-    python3 -m pip install --upgrade pip wheel ninja virtualenv
-    pip install setuptools==68.1.2
+    python3 -m pip install --upgrade pip wheel ninja virtualenv
+    python3 -m pip install setuptools==68.1.2
@@
-    pip install --no-deps -r requirements.txt
+    python3 -m pip install --no-deps -r requirements.txt
@@
-    pip cache purge || true
-    pip uninstall -y torch torchaudio torchcodec torchvision || true
-    pip install --index-url "$torch_url" torch torchaudio torchcodec torchvision 
-    pip check || true
+    python3 -m pip cache purge || true
+    python3 -m pip uninstall -y torch torchaudio torchcodec torchvision || true
+    python3 -m pip install --index-url "$torch_url" torch torchaudio torchcodec torchvision
+    python3 -m pip check || true
@@
-    pip install --no-cache-dir soundfile
+    python3 -m pip install --no-cache-dir soundfile

Also applies to: 31-41


45-45: Avoid brittle sed patch and hard-coded Python 3.11 site-packages path
This will break across Python versions and TTS releases. Resolve site-packages dynamically and fail if the target pattern isn’t found.

-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
+SITE_PKGS="$("$VENV_DIR/bin/python" -c 'import site,sys; print(next(p for p in site.getsitepackages()+[site.getusersitepackages()] if p.endswith("site-packages")))')"
+XTTS_PY="${SITE_PKGS}/TTS/tts/models/xtts.py"
+if ! grep -q 'weights_only=False' "$XTTS_PY"; then
+  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"]/' "$XTTS_PY"
+fi

Prefer shipping a proper patch file or upstreaming the change.


47-47: Check sample exists; ensure speakers dir
Prevent confusing failures when the WAV is missing and ensure the target directory exists.

-cp /home/dwemer/TheNarrator.wav speakers/TheNarrator.wav
+SAMPLE_PATH="${SAMPLE_PATH:-/home/dwemer/TheNarrator.wav}"
+mkdir -p speakers
+if [[ ! -f "$SAMPLE_PATH" ]]; then
+  echo "Error: sample file not found at $SAMPLE_PATH" >&2
+  exit 1
+fi
+cp "$SAMPLE_PATH" "speakers/TheNarrator.wav"

53-61: Fix contradictory prompts and start the server using the venv interpreter
The script asks users to wait for server output before actually starting it and uses system python.

-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
+echo
+echo "Press ENTER to start CHIM XTTS and download the selected model."
+echo "After startup, look for: 'Uvicorn running on http://0.0.0.0:8020 (Press CTRL+C to quit)'."
+read -r
+echo "Starting server, please wait..."
+"$VENV_DIR/bin/python" -m xtts_api_server --listen

Consider documenting how to keep it running (systemd/tmux/screen) instead of “close this window”.


61-61: Ensure xtts_api_server is installed/importable before invoking
Install the local package (editable or regular) so the module is available.

-"$VENV_DIR/bin/python" -m xtts_api_server --listen
+# Ensure local package is installed (adjust if packaged differently)
+"$VENV_DIR/bin/python" -m pip install -e .
+"$VENV_DIR/bin/python" -m xtts_api_server --listen
🧹 Nitpick comments (5)
ddistro_install.sh (5)

10-10: Use read -r to avoid backslash escapes
Small robustness improvement for user prompts.

-read -p "Are you using a GT10XX series GPU? (yes/no): " gpu_answer
+read -r -p "Are you using a GT10XX series GPU? (yes/no): " gpu_answer
@@
-read
+read -r

Also applies to: 57-57


28-39: CUDA index choice looks OK; consider pinning versions for cu128 too
cu128 wheels exist for recent PyTorch (e.g., 2.7.1 GA/test, nightly 2.8), so the index is valid. Still pin torch/torchaudio versions for reproducibility like you did for cu118.

You can set TORCH_VER/TORCHAUDIO_VER defaults and allow overrides:

-    cu_tag="cu128"
+    cu_tag="cu128"
+    torch_ver="${TORCH_VER:-2.7.1}"
+    torchaudio_ver="${TORCHAUDIO_VER:-2.7.1}"
@@
-    python3 -m pip install --index-url "$torch_url" torch torchaudio torchcodec torchvision 
+    python3 -m pip install --no-deps --no-cache-dir --index-url "$torch_url" "torch==${torch_ver}+${cu_tag}" "torchaudio==${torchaudio_ver}+${cu_tag}"
+    python3 -m pip install --no-cache-dir --index-url "$torch_url" torchvision torchcodec

Citations: PyTorch announces cu128 wheels for 2.7.1 and shows nightly cu128 wheels. (dev-discuss.pytorch.org, github.com, huggingface.co)


51-51: Validate conf.sh before executing
Fail fast if missing or not executable.

-./conf.sh
+if [[ ! -x ./conf.sh ]]; then
+  echo "Error: conf.sh not found or not executable" >&2
+  exit 1
+fi
+./conf.sh

63-63: Stray prompt
Either remove it or actually read input.

-echo "Press Enter"
+# echo "Press Enter"
+# read -r

21-24: Don’t mask dependency issues with || true
Let pip failures fail the script in strict mode.

-    python3 -m pip cache purge || true
+    python3 -m pip cache purge
@@
-    python3 -m pip check || true
+    python3 -m pip check
@@
-    python3 -m pip cache purge || true
+    python3 -m pip cache purge
@@
-    python3 -m pip check || true
+    python3 -m pip check

Also applies to: 36-39

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between dd9c688 and 19a1f69.

📒 Files selected for processing (1)
  • ddistro_install.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
ddistro_install.sh

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

(SC2164)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (4)
conf.sh (4)

10-14: Correct user-facing typos (“deepseed” → “deepspeed”; “Select a an” → “Select an”).

 Options:
-* deepseed = Uses more VRAM but it is faster. Does not work with 50xx series GPUs.
+* deepspeed = Uses more VRAM but it is faster. Does not work with 50xx series GPUs.
@@
-echo -e "Select a an option from the list:\n\n"
+echo -e "Select an option from the list:\n\n"

Also applies to: 31-33


61-61: Quote path variables in ln -sf.

Prevents issues with spaces or special chars.

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

19-21: Fix invalid use of exit with a string.

Use echo to print the error, then exit with a non-zero code.

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

45-54: Reorder/adjust validation to avoid integer-expression errors.

Using -eq before confirming numeric can crash on non-numeric input.

-if [ "$selection" -eq "0" ]; then
+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
🧹 Nitpick comments (6)
conf.sh (6)

47-47: Also quote the path in rm.

-    rm /home/dwemer/xtts-api-server/start.sh &>/dev/null
+    rm "/home/dwemer/xtts-api-server/start.sh" &>/dev/null

41-41: Use read -r to avoid backslash escapes.

-read -p "Select an option by picking the matching number: " selection
+read -r -p "Select an option by picking the matching number: " selection

23-23: Deterministic, safer file discovery.

Quote the path, restrict depth/type, and sort for stable menus.

-mapfile -t files < <(find /home/dwemer/xtts-api-server/ -name "start-*.sh")
+mapfile -t files < <(find "/home/dwemer/xtts-api-server/" -maxdepth 1 -type f -name "start-*.sh" | sort)

6-8: Clarify message: this script configures, not installs.

Avoid confusing users about its purpose.

-This will install CHIM XTTS. This is a high quality TTS service that works with Skyrim voices. 
+This configures CHIM XTTS start mode. CHIM XTTS is a high quality TTS service that works with Skyrim voices.

64-65: Ensure executability before linking (order).

Make start-*.sh executable before creating/refreshing the symlink.

-# Ensure all start scripts are executable
-chmod +x /home/dwemer/xtts-api-server/start-*.sh 2>/dev/null || true
+# Ensure all start scripts are executable before linking
+chmod +x /home/dwemer/xtts-api-server/start-*.sh 2>/dev/null || true

Consider moving these two lines above the ln -sf step.


1-1: Harden the script.

Enable strict mode for safer failures.

 #!/bin/bash
+set -Eeuo pipefail
+IFS=$'\n\t'
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 19a1f69 and 1d412ea.

📒 Files selected for processing (1)
  • conf.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
conf.sh

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

(SC2242)

Updated PyTorch installation to specific versions with CUDA support.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (3)
ddistro_install.sh (3)

3-3: Handle cd failure to avoid running in the wrong directory.

If the cd on Line [3] fails (typo, permissions, missing repo), the rest of the script keeps running and starts installing into whatever directory the caller happened to be in. Add an explicit guard so we fail fast.

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

48-48: Check the sample file exists before copying.

If /home/dwemer/TheNarrator.wav is missing, the cp on Line [48] prints an error and the script keeps going, leaving the install half-baked. Guard it:

-cp /home/dwemer/TheNarrator.wav speakers/TheNarrator.wav
+sample_src=/home/dwemer/TheNarrator.wav
+if [[ ! -f "$sample_src" ]]; then
+  echo "Error: sample file not found at $sample_src"
+  exit 1
+fi
+cp "$sample_src" speakers/TheNarrator.wav

54-62: Fix the contradictory startup prompts.

Lines [55-62] still tell users to “wait for” Uvicorn output and “close this window” before the server even starts, yet the server only launches after the read. This blocks automation, confuses users, and the “close this window” instruction kills the server outright. Rework the flow so pressing ENTER starts the server immediately and drop the advice to close the terminal:

-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
-
-echo "Press Enter"
+echo "Press ENTER to start CHIM XTTS and download the selected model."
+echo "Watch for: 'Uvicorn running on http://0.0.0.0:8020 (Press CTRL+C to quit)'."
+echo "Leave this terminal open (or run under tmux/screen/systemd) to keep the server alive."
+read -r
+echo "Starting server, please wait..."
+python -m xtts_api_server --listen
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1d412ea and 5c1a35f.

📒 Files selected for processing (1)
  • ddistro_install.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.11.0)
ddistro_install.sh

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

(SC2164)

#pip install xtts-api-server #Fails
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"]/' /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).

Updated CUDA version handling and installation process for PyTorch and related packages. Added user prompt for CUDA version selection and modified installation commands accordingly.
Added a comprehensive list of dependencies for the project.
Add LD_LIBRARY_PATH for NVIDIA libraries
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
start-regular.sh (1)

8-10: Add error handling to the cd command (unresolved from previous review).

The directory change lacks error handling. If the directory doesn't exist, the script will silently continue and execute subsequent commands in the wrong context, leading to activation of the venv from an unexpected location.

Apply this diff to add error handling:

-cd /home/dwemer/xtts-api-server/
+cd /home/dwemer/xtts-api-server/ || { echo "Error: failed to change directory"; exit 1; }
🧹 Nitpick comments (1)
start-regular.sh (1)

4-5: Consider making CUDA version configurable.

The CUDA version (12.8) is hardcoded. This may cause issues if the installed CUDA version differs. Consider allowing this to be overridden via an environment variable or auto-detected.

-if [ -d "/usr/local/cuda-12.8/bin" ]; then
-  export PATH="/usr/local/cuda-12.8/bin:$PATH"
+CUDA_VERSION="${CUDA_VERSION:-12.8}"
+CUDA_PATH="${CUDA_PATH:-/usr/local/cuda-${CUDA_VERSION}}"
+if [ -d "${CUDA_PATH}/bin" ]; then
+  export PATH="${CUDA_PATH}/bin:$PATH"
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f51038b and 0218c48.

📒 Files selected for processing (1)
  • start-regular.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.11.0)
start-regular.sh

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

(SC2164)

🔇 Additional comments (1)
start-regular.sh (1)

8-8: Partial review comment is incorrect — line 12 does not contain the hardcoded nvidia path cited.

The hardcoded paths at lines 8 and 10 in start-regular.sh are correctly identified and should be made portable. However, the review incorrectly claims line 12 contains /home/dwemer/python-tts/lib/python3.11/site-packages/nvidia/cu13/lib/ — line 12 is date > log.txt, which is not a hardcoded path.

The nvidia CUDA library path does exist in other scripts (start-lowvram.sh:14, start-deepspeed.sh:10, ddistro_install.sh:83), but not in start-regular.sh. The "Also applies to: 10-10, 12-12" statement is partially incorrect.

Lines 8 and 10 warrant fixes; line 12 does not apply to this script.

Likely an incorrect or invalid review comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
requirements5.txt (1)

1-177: Document the purpose and scope of requirements5.txt relative to other requirements files.

The file contains 177 strictly pinned dependencies spanning ML/NLP/TTS ecosystems (transformers, spacy, coqui-tts, stanza, gruut, torch + CUDA stack, etc.). This appears to be a complete environment setup, not a minimal set for an upload API route.

Please clarify:

  • What is the rationale for creating a separate requirements5.txt?
  • Is this intended to replace or supplement existing requirements.txt?
  • Are all 177 dependencies necessary for the /upload_sample feature, or is this a broader environment manifest?
  • Why include extensive ML tooling (e.g., spacy, coqui-tts-trainer, deepspeed) for a file upload endpoint?

Consider adding a comment block at the top of the file documenting its purpose, deployment target, and relationship to other requirements files in the repository.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0218c48 and b8a1ca0.

📒 Files selected for processing (1)
  • requirements5.txt (1 hunks)
🔇 Additional comments (3)
requirements5.txt (3)

1-177: Mismatch between PR objectives and file content—verify scope.

The PR objectives describe adding a /upload_sample route to the Web API, but the file under review is a comprehensive requirements manifest containing 177 dependencies. The AI summary differs significantly from the PR objectives. Please clarify:

  1. Are the main code changes (the /upload_sample route handler) included in a separate file not shown here?
  2. Is requirements5.txt intentionally separate from requirements.txt, and what is its purpose?
  3. Why does a new upload route warrant such an extensive dependency set?

126-126: Now I'll verify the compatibility between these versions:

Verify version compatibility: all three packages are compatible and current.

FastAPI requires python-multipart >=0.0.18. python-multipart 0.0.20 was released Dec 16, 2024 and satisfies this requirement. All three versions—python-multipart 0.0.20, FastAPI 0.115.6, and uvicorn 0.34.0—are recent stable releases from December 2024 with no known compatibility issues between them.


172-175: Based on the verification, the original review comment contains a factual error. Local version identifiers are PEP 440 compliant and follow the scheme: <public version identifier>[+<local version label>]. The +cu130 notation is therefore not "non-PEP 440 versioning" as claimed.

However, the underlying concern about installation practices is worth addressing. PyPI does not allow uploading packages with local version identifiers, and while PyTorch publishes wheels with this notation, the official guidance (from the earlier web search) indicates that using --index-url https://download.pytorch.org/whl/cu130 is the primary recommended approach rather than pinning +cu130 suffixes in requirements files.


Reconsider pinning strategy for CUDA-specific PyTorch wheels.

The +cu130 suffix is PEP 440-compliant local version notation. However, PyTorch's official installation guidance recommends using the --index-url flag (e.g., https://download.pytorch.org/whl/cu130) rather than pinning CUDA variants in requirements.txt. This ensures better reproducibility and compatibility.

Consider:

  • Adding --index-url https://download.pytorch.org/whl/cu130 to your pip install command, or
  • Documenting the exact pip command needed to install these requirements with the correct PyTorch index

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
start-deepspeed.sh (2)

7-7: Replace hardcoded paths with script-relative or environment-aware paths.

Absolute paths like /home/dwemer/... are not portable across development, test, and production environments. Use relative paths or environment variables to make this script reusable.

Consider parameterizing critical paths:

+#!/bin/bash
+# Configuration
+PROJECT_DIR="${PROJECT_DIR:-$(dirname "$0")}"
+VENV_PATH="${VENV_PATH:-${PROJECT_DIR}/../python-tts}"
+CUDA_PATH="${CUDA_PATH:-/usr/local/cuda-12.8}"
 
-if [ -d "/usr/local/cuda-12.8/bin" ]; then
-  export PATH="/usr/local/cuda-12.8/bin:$PATH"
+if [ -d "${CUDA_PATH}/bin" ]; then
+  export PATH="${CUDA_PATH}/bin:$PATH"
 fi
 
-cd /home/dwemer/xtts-api-server/ || exit 1
+cd "${PROJECT_DIR}" || { echo "Error: Failed to change directory to ${PROJECT_DIR}"; exit 1; }
 
-source /home/dwemer/python-tts/bin/activate || exit 1
+source "${VENV_PATH}/bin/activate" || { echo "Error: Failed to activate venv at ${VENV_PATH}"; exit 1; }
 
-if [ -d "/home/dwemer/python-tts/lib/python3.11/site-packages/nvidia/cu13/lib/" ];
+if [ -d "${VENV_PATH}/lib/python3.11/site-packages/nvidia/cu13/lib/" ];
 then
-  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/dwemer/python-tts/lib/python3.11/site-packages/nvidia/cu13/lib/
-  export PATH=/home/dwemer/python-tts/lib/python3.11/site-packages/nvidia/cu13/bin:$PATH
-  export CUDA_HOME=/home/dwemer/python-tts/lib/python3.11/site-packages/nvidia/cu13
+  export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${VENV_PATH}/lib/python3.11/site-packages/nvidia/cu13/lib/"
+  export PATH="${VENV_PATH}/lib/python3.11/site-packages/nvidia/cu13/bin:${PATH}"
+  export CUDA_HOME="${VENV_PATH}/lib/python3.11/site-packages/nvidia/cu13"
 fi

This approach allows users to override paths via environment variables or symlinks without editing the script.

Also applies to: 9-9, 14-14, 15-15, 16-16


19-19: Consider capturing process PID when launching background task.

Running the server with & creates a background process, but the PID is not captured. This can make graceful shutdown or health monitoring difficult.

Consider storing the PID for lifecycle management:

-python -m xtts_api_server --deepspeed --listen &> log.txt &
+python -m xtts_api_server --deepspeed --listen &> log.txt &
+echo $! > .xtts_server.pid

This allows other scripts to query or terminate the server by reading the PID from .xtts_server.pid.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b8a1ca0 and 5cf3f7e.

📒 Files selected for processing (2)
  • requirements5.txt (1 hunks)
  • start-deepspeed.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.11.0)
start-deepspeed.sh

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

(SC2164)

Comment on lines +177 to +180
nvidia-cuda-nvcc
nvidia-cuda-profiler-api-cu13
nvidia-cuda-profiler-api

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 | 🔴 Critical

Fix incomplete package specifications.

Lines 177–179 lack version constraints, and line 180 contains malformed data. These prevent reproducible builds and may cause installation failures.

Apply this diff to fix the incomplete entries:

-nvidia-cuda-nvcc
-nvidia-cuda-profiler-api-cu13
-nvidia-cuda-profiler-api
-+
+nvidia-cuda-nvcc==13.0.39
+nvidia-cuda-profiler-api-cu13==0.0.0a0
+nvidia-cuda-profiler-api==13.0.39

If the intent is to omit these packages, remove them entirely. If they should truly have no version constraint, consider documenting why.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In requirements5.txt around lines 177 to 180, the three CUDA-related entries are
incomplete (no version constraints) and one line is malformed; update these
lines by either removing the packages entirely if they are not required, or
pinning them to explicit, tested versions (e.g., nvidia-cuda-nvcc==<version>,
nvidia-cuda-profiler-api-cu13==<version>, nvidia-cuda-profiler-api==<version>)
and remove the malformed line; if you intentionally want no pinning, leave them
out of this requirements file and add a comment explaining why unpinned CUDA
packages are acceptable for reproducibility.

export PATH="/usr/local/cuda-12.8/bin:$PATH"
fi

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.

⚠️ Potential issue | 🟠 Major

Add error handling to cd and source commands.

Both commands can fail silently, allowing subsequent lines to execute in an unexpected state. This is a critical failure mode.

Apply this diff to add error handling:

-cd /home/dwemer/xtts-api-server/
+cd /home/dwemer/xtts-api-server/ || { echo "Error: Failed to change directory"; exit 1; }
 
-source /home/dwemer/python-tts/bin/activate
+source /home/dwemer/python-tts/bin/activate || { echo "Error: Failed to activate venv"; exit 1; }

Also applies to: 9-9

🧰 Tools
🪛 Shellcheck (0.11.0)

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

(SC2164)

🤖 Prompt for AI Agents
start-deepspeed.sh lines 7 and 9: the cd and source commands can fail silently;
either enable strict shell failure handling at the top of the script (e.g., set
-euo pipefail) or add explicit checks immediately after each cd and source
invocation that detect failure, print a clear error message to stderr, and exit
with a non-zero status so the script stops on error.

Added symlink creation for CUDA libraries and updated environment variables for CUDA paths.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (6)
ddistro_install.sh (6)

16-76: Consistently use python3 -m pip instead of bare pip within the venv.

This issue was flagged in a previous review. Mixing bare pip and python3 -m pip can lead to ambiguity about which interpreter is used.

Replace all bare pip invocations with python3 -m pip throughout the script (lines 17, 19, 22–23, 36, 39, 61, 63, 66, 68, etc.). Example:

-pip install setuptools==68.1.2
+python3 -m pip install setuptools==68.1.2
-pip install --no-deps -r requirements.txt
+python3 -m pip install --no-deps -r requirements.txt

79-79: Check file existence before copying speaker sample.

This issue was flagged in a previous review. Copying without verifying the source file exists will fail with an unclear error.

+if [[ ! -f "/home/dwemer/TheNarrator.wav" ]]; then
+  echo "Error: sample file not found at /home/dwemer/TheNarrator.wav"
+  exit 1
+fi
 cp /home/dwemer/TheNarrator.wav speakers/TheNarrator.wav

3-3: Wrap cd with error handling.

This issue was flagged in a previous review but remains unaddressed. If the directory change fails, subsequent commands run in the wrong context.

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

27-27: Resolve site-packages path dynamically instead of hard-coding Python 3.11.

This issue was flagged in a previous review. Hard-coding python3.11 will fail silently on any other interpreter version (3.10, 3.12+). Notably, line 45 already demonstrates the correct approach using python3 -c 'import site; ...', but lines 27 and 73 still hard-code the path.

Apply this dynamic resolution to both line 27 and line 73:

+model_file="$(
+  python3 - <<'PY'
+import sysconfig
+print(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"]/' /home/dwemer/python-tts/lib/python3.11/site-packages/TTS/tts/models/xtts.py
+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"

Repeat this pattern for both occurrences (line 27 in the cu118 branch and line 73 in the cu128 branch).

Also applies to: 73-73


94-99: Resolve CUDA library paths dynamically instead of hard-coding Python 3.11.

This issue relates to the hard-coded site-packages path flagged elsewhere (lines 27, 73). Hard-coding python3.11 will fail silently on other interpreter versions.

-if [ -d "/home/dwemer/python-tts/lib/python3.11/site-packages/nvidia/cu13/lib/" ];
+cu13_lib_dir="$(python3 -c 'import sysconfig; print(sysconfig.get_path("purelib") + "/nvidia/cu13/lib")' 2>/dev/null)"
+if [ -n "$cu13_lib_dir" ] && [ -d "$cu13_lib_dir" ];
 then
-  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/dwemer/python-tts/lib/python3.11/site-packages/nvidia/cu13/lib/
-  export PATH=/home/dwemer/python-tts/lib/python3.11/site-packages/nvidia/cu13/bin:$PATH
-  export CUDA_HOME=/home/dwemer/python-tts/lib/python3.11/site-packages/nvidia/cu13
+  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$cu13_lib_dir
+  export PATH=$(python3 -c 'import sysconfig; print(sysconfig.get_path("purelib") + "/nvidia/cu13/bin")'):$PATH
+  export CUDA_HOME=$(python3 -c 'import sysconfig; print(sysconfig.get_path("purelib") + "/nvidia/cu13")')
 fi

103-103: Use python3 (or the venv's Python) instead of bare python.

This issue was flagged in a previous review. Using bare python may bypass the venv or use an incorrect interpreter.

-python -m xtts_api_server --listen $DEEPSPEED
+python3 -m xtts_api_server --listen $DEEPSPEED

Alternatively, use the venv's Python directly for stronger isolation:

"${VENV_DIR:-/home/dwemer/python-tts}/bin/python" -m xtts_api_server --listen $DEEPSPEED
🧹 Nitpick comments (3)
ddistro_install.sh (3)

89-89: Use read -r to prevent backslash interpretation.

The read command without -r will interpret backslashes as escape sequences, potentially causing unexpected behavior when users input certain characters.

-read
+read -r

101-101: Add defensive check for start.sh symlink.

The readlink command will fail silently if start.sh doesn't exist or isn't a symlink, and DEEPSPEED will be empty. Consider adding a check to confirm the file exists and provide clearer intent.

-readlink start.sh | grep -q '/home/dwemer/xtts-api-server/start-deepspeed.sh' && export DEEPSPEED="--deepspeed" ||  export DEEPSPEED=""
+if [ -L start.sh ]; then
+  readlink start.sh | grep -q 'start-deepspeed.sh' && export DEEPSPEED="--deepspeed" || export DEEPSPEED=""
+else
+  export DEEPSPEED=""
+fi

54-54: Remove or clarify commented-out code.

Lines 54 and 72 contain commented #pip install xtts-api-server #Fails with no explanation. These should either be removed or replaced with a clear TODO/FIXME explaining why installation fails and what the workaround is.

-	    #pip install xtts-api-server #Fails
+	    # TODO: xtts-api-server install fails; investigate dependency issue or install via editable mode (pip install -e .)

Alternatively, remove these lines entirely if they're no longer relevant.

Also applies to: 72-72

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5cf3f7e and 33efb27.

📒 Files selected for processing (1)
  • ddistro_install.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.11.0)
ddistro_install.sh

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

(SC2164)

Add cleanup step for previous deepspeed files.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (5)
ddistro_install.sh (5)

3-3: Guard the cd command with error handling.

If the directory change fails, subsequent commands will execute in the wrong context, corrupting the environment setup. Previously flagged; still unresolved.

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

87-89: Fix contradictory user messaging and flow.

The prompt tells the user to "wait for Uvicorn message" before starting the server, and then instructs them to "close this window"—which would kill the running process. This is confusing and incorrect. Clarify the sequence: the script will start the server immediately after the user presses Enter.

 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 "Press ENTER to start CHIM XTTS and download the selected model."
+echo "After startup, look for: 'Uvicorn running on http://0.0.0.0:8020 (Press CTRL+C to quit)'."
+read -r

1-2: Add strict error handling after shebang.

The script lacks set -euo pipefail for proper error propagation and safe defaults (exit on error, undefined variables, pipe failures). This allows the script to silently continue when commands fail.

 #!/bin/bash
+set -euo pipefail
 
 cd /home/dwemer/xtts-api-server

80-80: Verify speaker file exists before copying; parameterize paths.

The copy operation has no existence check and hard-codes the sample path, making it fragile. If the file is missing or in a different location, the command silently fails or produces a cryptic error. Previously flagged; still unresolved.

+SAMPLE_FILE="/home/dwemer/TheNarrator.wav"
+if [[ ! -f "$SAMPLE_FILE" ]]; then
+  echo "Error: sample file not found at $SAMPLE_FILE" >&2
+  exit 1
+fi
-cp /home/dwemer/TheNarrator.wav speakers/TheNarrator.wav
+cp "$SAMPLE_FILE" speakers/TheNarrator.wav

28-28: Resolve the site-packages path at runtime instead of hard-coding python3.11.

The sed path assumes python3.11 but python3 -m venv adapts to the installed Python version (3.10, 3.12, etc.). On any version other than 3.11, this command silently fails, leaving the patch unapplied. Previously flagged; still unresolved. Use the venv's interpreter to resolve the path dynamically.

-    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="$(/home/dwemer/python-tts/bin/python -c 'import sysconfig, pathlib; print(pathlib.Path(sysconfig.get_path("purelib")) / "TTS/tts/models/xtts.py")')"
+    if [[ ! -f "$model_file" ]]; then
+      echo "Error: xtts.py not found at $model_file" >&2
+      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"
🧹 Nitpick comments (4)
ddistro_install.sh (4)

18-27: Consistently use python3 -m pip for clarity and robustness.

Line 17 correctly uses python3 -m pip, but subsequent lines revert to bare pip. This inconsistency can lead to ambiguity about which interpreter is invoked. Standardize on python3 -m pip throughout.

-    pip install setuptools==68.1.2
-    # Install app requirements without auto-pulling torch/torchaudio from deps
-    pip install --no-deps -r requirements.txt
+    python3 -m pip install setuptools==68.1.2
+    # Install app requirements without auto-pulling torch/torchaudio from deps
+    python3 -m 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
+    python3 -m pip uninstall -y torch torchaudio torchcodec torchvision || true
+    python3 -m pip install --no-deps --no-cache-dir --index-url "$torch_url" "torch==${torch_ver}+${cu_tag}" "torchaudio==${torchaudio_ver}+${cu_tag}"
+    python3 -m pip check || true
     # Ensure fallback audio loader is available
-    pip install --no-cache-dir soundfile
+    python3 -m pip install --no-cache-dir soundfile

37-44: Standardize on python3 -m pip for consistency across all CUDA paths.

Both the CUDA 13.0 and CUDA 12.8 branches use bare pip inconsistently. Line 46 already demonstrates the correct pattern for dynamic resolution; apply the same discipline to all pip invocations.

Also applies to: 62-72


102-102: Resolve the start script symlink target using the venv's Python and parameterized paths.

This grep command hard-codes /home/dwemer/xtts-api-server/start-deepspeed.sh, making it brittle to path changes. Additionally, readlink output may be a relative symlink; use the venv's Python to compute it reliably.

-readlink start.sh | grep -q '/home/dwemer/xtts-api-server/start-deepspeed.sh' && export DEEPSPEED="--deepspeed" ||  export DEEPSPEED=""
+SYMLINK_TARGET="$(readlink -f start.sh)" || SYMLINK_TARGET=""
+[[ "$SYMLINK_TARGET" == *"start-deepspeed.sh"* ]] && export DEEPSPEED="--deepspeed" || export DEEPSPEED=""

3-5: Parameterize base directory and venv paths to improve portability and reusability.

Hard-coding /home/dwemer paths makes this script specific to one user and environment. Allow overrides via environment variables with sensible defaults so users can adapt it to their setup without editing the script.

Add near the top (after shebang and set -euo pipefail):

# Allow users to override paths via environment variables
BASE_DIR="${BASE_DIR:-$HOME/xtts-api-server}"
VENV_DIR="${VENV_DIR:-$HOME/python-tts}"
SAMPLE_FILE="${SAMPLE_FILE:-$HOME/TheNarrator.wav}"

cd "$BASE_DIR" || { echo "Error: cannot cd to $BASE_DIR"; exit 1; }
python3 -m venv "$VENV_DIR"
source "$VENV_DIR/bin/activate"

This allows users to run:

BASE_DIR=/opt/xtts VENV_DIR=/opt/venv ./ddistro_install.sh
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 33efb27 and 8164e94.

📒 Files selected for processing (1)
  • ddistro_install.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.11.0)
ddistro_install.sh

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

(SC2164)

# Ensure fallback audio loader is available
pip install --no-cache-dir soundfile
#pip install xtts-api-server #Fails
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

Resolve python version path dynamically (same as line 28 issue).

Line 74 repeats the hard-coded python3.11 path problem. Apply the same fix used for line 28: compute the site-packages 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="$(/home/dwemer/python-tts/bin/python -c 'import sysconfig, pathlib; print(pathlib.Path(sysconfig.get_path("purelib")) / "TTS/tts/models/xtts.py")')"
+    if [[ ! -f "$model_file" ]]; then
+      echo "Error: xtts.py not found at $model_file" >&2
+      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 74, the sed invocation uses a hard-coded
/home/dwemer/python3.11/.../site-packages path; compute the site-packages path
at runtime (as done at line 28) and use that variable in the sed command instead
of the literal path. Set a SITE_PKG variable by invoking the chosen python
interpreter to get site-packages (matching the interpreter used earlier), then
run sed against "$SITE_PKG/.../TTS/tts/models/xtts.py" so the script works
across Python versions and installs.

Comment on lines +95 to +100
if [ -d "/home/dwemer/python-tts/lib/python3.11/site-packages/nvidia/cu13/lib/" ];
then
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/dwemer/python-tts/lib/python3.11/site-packages/nvidia/cu13/lib/
export PATH=/home/dwemer/python-tts/lib/python3.11/site-packages/nvidia/cu13/bin:$PATH
export CUDA_HOME=/home/dwemer/python-tts/lib/python3.11/site-packages/nvidia/cu13
fi
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

Use runtime path resolution for CUDA libraries instead of hard-coded python3.11.

The conditional path and environment variables hard-code python3.11. This will fail silently on other Python versions.

-if [ -d "/home/dwemer/python-tts/lib/python3.11/site-packages/nvidia/cu13/lib/" ];
+CUDA_LIB_PATH="$(/home/dwemer/python-tts/bin/python -c 'import sysconfig, pathlib; p = pathlib.Path(sysconfig.get_path("purelib")) / "nvidia/cu13/lib"; print(p if p.exists() else "")')"
+if [ -n "$CUDA_LIB_PATH" ] && [ -d "$CUDA_LIB_PATH" ];
 then
-  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/dwemer/python-tts/lib/python3.11/site-packages/nvidia/cu13/lib/
-  export PATH=/home/dwemer/python-tts/lib/python3.11/site-packages/nvidia/cu13/bin:$PATH
-  export CUDA_HOME=/home/dwemer/python-tts/lib/python3.11/site-packages/nvidia/cu13
+  export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${CUDA_LIB_PATH}"
+  export PATH="$(dirname "$CUDA_LIB_PATH")/bin:$PATH"
+  export CUDA_HOME="$(dirname "$CUDA_LIB_PATH")/.."
 fi

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In ddistro_install.sh around lines 95-100, the script hard-codes a python3.11
site-packages path for CUDA libs; replace the hard-coded path with a
runtime-resolved site-packages base (call python to print the site-packages or
sysconfig path and store it in a variable) and then build the nvidia/cu13 lib
and bin paths from that variable before checking/setting LD_LIBRARY_PATH, PATH
and CUDA_HOME so the script works for other Python versions/environments.


readlink start.sh | grep -q '/home/dwemer/xtts-api-server/start-deepspeed.sh' && export DEEPSPEED="--deepspeed" || export DEEPSPEED=""

python -m xtts_api_server --listen $DEEPSPEED
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 | 🔴 Critical

Install the local package and use the venv's Python explicitly.

Line 104 attempts to run xtts_api_server without installing it first, and uses bare python instead of python3. The module is not importable unless installed (e.g., pip install -e . or pip install .). This is a critical blocker; previously flagged, still unresolved.

Add a local install step before this line (around line 84, after conf.sh):

# Install the local xtts_api_server package
python3 -m pip install -e . || python3 -m pip install .

Then update line 104:

-python -m xtts_api_server --listen $DEEPSPEED
+/home/dwemer/python-tts/bin/python -m xtts_api_server --listen $DEEPSPEED

Alternatively, add a console-script entrypoint in pyproject.toml so pip install . creates an executable:

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

Then invoke it directly:

xtts-api-server --listen $DEEPSPEED
🤖 Prompt for AI Agents
In ddistro_install.sh around lines 84 and 104: the script runs the module with a
bare `python` at line 104 without installing the package, so it won't be
importable; add a local install step after sourcing conf.sh (around line 84)
that runs the venv's pip via python3 (e.g., python3 -m pip install -e . ||
python3 -m pip install .) to install the package, and change the invocation on
line 104 to use the venv's python3 explicitly (e.g., python3 -m xtts_api_server
--listen $DEEPSPEED) or, alternatively, add a console-script entrypoint in
pyproject.toml so `pip install .` creates an executable and call that executable
instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants