Skip to content

v26.2.26#1644

Merged
ROBERT-MCDOWELL merged 1 commit intoDrewThomasson:v26from
ROBERT-MCDOWELL:v26
Feb 26, 2026
Merged

v26.2.26#1644
ROBERT-MCDOWELL merged 1 commit intoDrewThomasson:v26from
ROBERT-MCDOWELL:v26

Conversation

@ROBERT-MCDOWELL
Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings February 26, 2026 04:20
@ROBERT-MCDOWELL ROBERT-MCDOWELL merged commit dbe9f0e into DrewThomasson:v26 Feb 26, 2026
1 check passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts TTS engine initialization order so model-specific paths are computed before engine loading, and refactors a couple engines to store model_path on the instance for reuse during loading.

Changes:

  • Move load_engine() / _load_engine_zs() calls to occur after self.model_path is computed (vits, tacotron, glowtts, tortoise).
  • In fairseq and bark, compute and store self.model_path during __init__ and reuse it in load_engine().
  • Simplify fairseq/bark load logic by removing duplicate model-path derivation code.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/classes/tts_engines/vits.py Defer engine loading until after model_path is set.
lib/classes/tts_engines/tortoise.py Defer engine loading until after model_path is set.
lib/classes/tts_engines/tacotron.py Defer engine + zero-shot engine loading until after model_path is set.
lib/classes/tts_engines/glowtts.py Defer engine + zero-shot engine loading until after model_path is set.
lib/classes/tts_engines/fairseq.py Persist model_path in __init__ and use it in load_engine().
lib/classes/tts_engines/bark.py Persist model_path in __init__ and use it in load_engine().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

self.model_path = model_cfg['repo'].replace("[lang]", self.session['language'])
self.engine = self.load_engine()
self.engine_zs = self._load_engine_zs()
except Exception as e:
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

model_cfg = self.models[self.session['fine_tuned']] can throw KeyError and will be surfaced as a generic ValueError('__init__() error: ...') with only the missing dict key. To keep user-facing errors actionable, catch KeyError here and raise a more descriptive message indicating the invalid fine_tuned option.

Suggested change
except Exception as e:
except Exception as e:
# Provide a clearer error message when an invalid 'fine_tuned' option is used.
if isinstance(e, KeyError):
fine_tuned = None
try:
# Use get to avoid raising a second KeyError if the key is missing.
fine_tuned = self.session.get('fine_tuned')
except Exception:
# If accessing session fails for any reason, leave fine_tuned as None.
pass
available = None
if hasattr(self, 'models') and isinstance(self.models, dict):
try:
available = ', '.join(self.models.keys())
except Exception:
available = None
if available:
error = (
f"Invalid 'fine_tuned' option {fine_tuned!r} for TTS engine "
f"{self.session.get('tts_engine')!r}. "
f"Available options are: {available}"
)
else:
error = (
f"Invalid 'fine_tuned' option {fine_tuned!r} for TTS engine "
f"{self.session.get('tts_engine')!r}."
)
raise ValueError(error) from e

Copilot uses AI. Check for mistakes.
Comment on lines +24 to 26
model_cfg = self.models[self.session['fine_tuned']]
self.model_path = model_cfg['repo']
self.engine = self.load_engine()
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

model_cfg = self.models[self.session['fine_tuned']] will raise a bare KeyError if fine_tuned is invalid, which then gets wrapped into a generic ValueError('__init__() error: ...') and loses the more actionable context (which model key was invalid). Consider catching KeyError here and raising a clearer message like "Invalid fine_tuned model ''" (optionally chaining the original exception).

Copilot uses AI. Check for mistakes.
except Exception as e:
error = 'load_engine(): _load_api() failed'
raise RuntimeError(error) from e
engine = self._load_api(self.tts_key, self.model_path)
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

load_engine() no longer wraps _load_api() failures, so exceptions will bubble up without the consistent load_engine(): _load_api() failed context used by other engines in this package. Recommend restoring a try/except around _load_api() and re-raising a RuntimeError (with from e) for consistent, debuggable error reporting.

Suggested change
engine = self._load_api(self.tts_key, self.model_path)
try:
engine = self._load_api(self.tts_key, self.model_path)
except Exception as e:
error = f"load_engine(): _load_api() failed: {e}"
raise RuntimeError(error) from e

Copilot uses AI. Check for mistakes.
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.

2 participants