From ef8fbea5ff37a4145bdbed91fdc8a6bdfdfc81ea Mon Sep 17 00:00:00 2001
From: Patrick Poitras <patrick@pfpoitras.com>
Date: Wed, 6 May 2026 19:14:43 -0700
Subject: [PATCH] Disable piper

---
 setup/build.py                 | 8 ++++++++
 setup/commands.py              | 5 -----
 setup/resources.py             | 2 +-
 src/calibre/gui2/tts/types.py  | 5 +++--
 src/calibre/test_build.py      | 3 ++-
 src/calibre/utils/run_tests.py | 5 +++--
 6 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/setup/build.py b/setup/build.py
index 956ad7504f..54a5f1236a 100644
--- a/setup/build.py
+++ b/setup/build.py
@@ -444,6 +444,14 @@ def run(self, opts):
                 continue
             if not is_ext_allowed(self.compiling_for, ext):
                 continue
+################################################################################
+# Void linux patch. The piper extension relies on `onnx` which isn't
+# packaged for void. It would also require espeak-ng > 1.52 also unpackaged
+# (last release is Dec 2024 and is missing the
+#       espeak_TextToPhonemesWithTerminator() function.)
+################################################################################
+            if ext.name == "piper":
+                continue
             if ext.error:
                 if ext.optional:
                     self.warn(ext.error)
diff --git a/setup/commands.py b/setup/commands.py
index faba5b437a..96e5682ce6 100644
--- a/setup/commands.py
+++ b/setup/commands.py
@@ -31,7 +31,6 @@
     'manual',
     'mathjax',
     'osx',
-    'piper_voices',
     'pot',
     'publish',
     'publish_betas',
@@ -95,10 +94,6 @@
 
 hyphenation = Hyphenation()
 
-from setup.piper import PiperVoices
-
-piper_voices = PiperVoices()
-
 from setup.liberation import LiberationFonts
 
 liberation_fonts = LiberationFonts()
diff --git a/setup/resources.py b/setup/resources.py
index fbd918c5df..64a60bd0bf 100644
--- a/setup/resources.py
+++ b/setup/resources.py
@@ -104,7 +104,7 @@ def run(self, opts):
 class Resources(Command):  # {{{
 
     description = 'Compile various needed calibre resources'
-    sub_commands = ['liberation_fonts', 'mathjax', 'rapydscript', 'hyphenation', 'piper_voices']
+    sub_commands = ['liberation_fonts', 'mathjax', 'rapydscript', 'hyphenation']
 
     def run(self, opts):
         from calibre.utils.serialize import msgpack_dumps
diff --git a/src/calibre/gui2/tts/types.py b/src/calibre/gui2/tts/types.py
index a9ef058ae4..0db9b3dcc3 100644
--- a/src/calibre/gui2/tts/types.py
+++ b/src/calibre/gui2/tts/types.py
@@ -236,8 +236,9 @@ def qt_engine_metadata(name: str, human_name: str, desc: str, allows_choosing_au
             continue
 
     try:
-        import calibre_extensions.piper as check_that_piper_imports
-        del check_that_piper_imports
+        # import calibre_extensions.piper as check_that_piper_imports
+        # del check_that_piper_imports
+        pass
     except ImportError:
         pass
     else:
diff --git a/src/calibre/test_build.py b/src/calibre/test_build.py
index b60e2f1cd6..bfbed35e56 100644
--- a/src/calibre/test_build.py
+++ b/src/calibre/test_build.py
@@ -158,7 +158,8 @@ def test_plugins(self):
                     # Just check that the DLL can be loaded
                     ctypes.CDLL(os.path.join(plugins_loc, name + ('.dylib' if ismacos else '.so')))
                 continue
-            import_module('calibre_extensions.' + name)
+            if 'piper' not in name:
+                import_module('calibre_extensions.' + name)
 
     def test_lxml(self):
         from calibre.utils.cleantext import test_clean_xml_chars
diff --git a/src/calibre/utils/run_tests.py b/src/calibre/utils/run_tests.py
index 19853589ff..7e880dff58 100644
--- a/src/calibre/utils/run_tests.py
+++ b/src/calibre/utils/run_tests.py
@@ -190,8 +190,9 @@ def test_import_of_all_python_modules(self):
                 'calibre.utils.linux_trash', 'calibre.utils.open_with.linux',
                 'calibre.gui2.linux_file_dialogs',
             }
-        if 'SKIP_SPEECH_TESTS' in os.environ:
-            exclude_packages.add('calibre.gui2.tts')
+        exclude_packages.add('calibre.gui2.tts')
+        exclude_packages.add('calibre.utils.tts')
+        exclude_modules.add('calibre.gui2.tts.piper')
         if not isbsd:
             exclude_modules.add('calibre.devices.usbms.hal')
         d = os.path.dirname
-- 
2.54.0

