Skip to content

Fix Piper TTS voices stuck on "Loading voices..."#18

Merged
crisbbc merged 3 commits intomainfrom
copilot/replace-edge-tts-offline-alternative
Mar 18, 2026
Merged

Fix Piper TTS voices stuck on "Loading voices..."#18
crisbbc merged 3 commits intomainfrom
copilot/replace-edge-tts-offline-alternative

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 18, 2026

Switching to Piper TTS left the Voice tab permanently showing "Loading voices…" — voices never populated and the dropdown remained unusable.

Two independent bugs caused this:

  • parent_window never wired up (settings_window.py)VoiceTab was constructed without parent_window, so _load_voices() fetched voices in the background thread but the if self.parent_window: guard silently dropped the after() callback, meaning _apply_voices_ui() never ran.

  • Provider-unaware voice cache (tts_engine.py)get_available_voices() used a purely time-based cache. After switching providers the still-fresh cache returned the previous provider's voices; the Voice tab would silently display stale Edge TTS voices while Piper was active (or vice versa).

Changes

  • src/gui/settings_window.py — pass parent_window=self.window when constructing VoiceTab.

  • src/tts/tts_engine.py

    • Add _cached_provider: str field alongside the existing time-based cache.
    • Cache is only reused when both the timestamp and provider match; any provider change triggers a fresh fetch.
    • clear_voices_cache() now also resets _cached_provider.
    • Extract _get_active_provider_name() helper to avoid duplicating the settings lookup.
# Before: cache checked time only
if self._voices_cache is not None and time.time() - self._cache_timestamp < self._cache_duration:
    return self._voices_cache

# After: cache is also invalidated when the active provider changes
active_provider = self._get_active_provider_name()
if (
    self._voices_cache is not None
    and self._cached_provider == active_provider
    and time.time() - self._cache_timestamp < self._cache_duration
):
    return self._voices_cache
  • tests/test_tts_engine_cache.py — four new unit tests covering: same-provider cache hit, cache bust on Edge→Piper switch, cache bust on Piper→Edge switch, and clear_voices_cache() resetting provider tracking.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…ge TTS

Co-authored-by: k1rk11 <69209514+k1rk11@users.noreply.github.com>
Copilot AI changed the title [WIP] Replace edge_tts with offline open source neural alternative Add Piper TTS as an optional offline neural TTS provider Mar 18, 2026
Copilot AI requested a review from crisbbc March 18, 2026 12:35
Co-authored-by: k1rk11 <69209514+k1rk11@users.noreply.github.com>
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