From ea292dd2e147f8dcaed24083d624f9fc4aa03d78 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 4 Sep 2024 22:23:28 +0530 Subject: [PATCH] Make piper the default on all platforms where it is available --- src/calibre/gui2/tts/types.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/calibre/gui2/tts/types.py b/src/calibre/gui2/tts/types.py index b1984cec4f..85e49f58cc 100644 --- a/src/calibre/gui2/tts/types.py +++ b/src/calibre/gui2/tts/types.py @@ -214,12 +214,12 @@ def available_engines() -> dict[str, EngineMetadata]: ), True) elif x == 'speechd': continue + if piper_cmdline(): + ans['piper'] = EngineMetadata('piper', _('The Piper Neural Speech Engine'), _( + 'The "piper" engine can track the currently spoken sentence on screen. It uses a neural network ' + 'for natural sounding voices. The neural network is run locally on your computer, it is fairly resource intensive to run.' + ), TrackingCapability.Sentence, can_change_pitch=False, voices_have_quality_metadata=True) if islinux: - if piper_cmdline(): - ans['piper'] = EngineMetadata('piper', _('The Piper Neural Speech Engine'), _( - 'The "piper" engine can track the currently spoken sentence on screen. It uses a neural network ' - 'for natural sounding voices. The neural network is run locally on your computer, it is fairly resource intensive to run.' - ), TrackingCapability.Sentence, can_change_pitch=False, voices_have_quality_metadata=True) from speechd.paths import SPD_SPAWN_CMD cmd = os.getenv("SPEECHD_CMD", SPD_SPAWN_CMD) if cmd and os.access(cmd, os.X_OK) and os.path.isfile(cmd): @@ -232,12 +232,12 @@ def available_engines() -> dict[str, EngineMetadata]: def default_engine_name() -> str: + if 'piper' in available_engines(): + return 'piper' if iswindows: return 'sapi' if tweaks.get('prefer_winsapi') else 'winrt' if ismacos: return 'darwin' - if 'piper' in available_engines(): - return 'piper' if 'speechd' in available_engines(): return 'speechd' return 'flite'